diff --git a/AppRun.c.patch b/AppRun.c.patch index 49b98ab..edf2497 100644 --- a/AppRun.c.patch +++ b/AppRun.c.patch @@ -1,34 +1,44 @@ -https://github.com/AppImage/AppImageKit/blob/ddcb5b98073ec251cbddda7a4eaa17545f06bbff/AppRun.c - --- a/AppRun.c +++ b/AppRun.c -@@ -164,6 +164,10 @@ - char *old_env; - size_t length; - const char *format; -+ checkrt(usr_in_appdir); +@@ -38,7 +38,7 @@ + exit( 1 ); \ + } while (0); + +-#define NEW_LD_LIBRARY_PATH "LD_LIBRARY_PATH=./lib/:./lib/i386-linux-gnu/:./lib/x86_64-linux-gnu/:./lib32/:./lib64/:../lib/:../lib/i386-linux-gnu/:../lib/x86_64-linux-gnu/:../lib32/:../lib64/:%s" ++#define NEW_LD_LIBRARY_PATH "LD_LIBRARY_PATH=%s./lib/:./lib/i386-linux-gnu/:./lib/x86_64-linux-gnu/:./lib32/:./lib64/:../lib/:../lib/i386-linux-gnu/:../lib/x86_64-linux-gnu/:../lib32/:../lib64/:%s" + #define NEW_PATH "PATH=./bin/:./sbin/:./games/:../bin/:../sbin/:%s" + #define NEW_PYTHONPATH "PYTHONPATH=./share/pyshared/:%s" + #define NEW_XDG_DATA_DIRS "XDG_DATA_DIRS=./share/:%s" +@@ -138,8 +138,8 @@ + char *env, *new_env[7]; + + env = getenv("LD_LIBRARY_PATH") ?: ""; +- new_env[0] = malloc( strlen(NEW_LD_LIBRARY_PATH) + strlen(env) ); +- sprintf( new_env[0], NEW_LD_LIBRARY_PATH, env ); ++ new_env[0] = malloc( strlen(NEW_LD_LIBRARY_PATH) + strlen(optional) + strlen(env) ); ++ sprintf( new_env[0], NEW_LD_LIBRARY_PATH, optional, env ); + // printf( " using %s\n", new_env[0] ); + putenv( new_env[0] ); + +@@ -179,6 +179,11 @@ + // printf( " using %s\n", new_env[6] ); + putenv( new_env[6] ); + ++ checkrt(); + + if (optional_ld_preload) + putenv(optional_ld_preload); ++ + /* Run */ + ret = execvp(executable, argv); - /* https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHOME */ - SET_NEW_ENV(new_pythonhome, appdir_s, "PYTHONHOME=%s/usr/", appdir); -@@ -172,7 +176,7 @@ - SET_NEW_ENV(new_path, appdir_s*5 + strlen(old_env), "PATH=%s/usr/bin/:%s/usr/sbin/:%s/usr/games/:%s/bin/:%s/sbin/:%s", appdir, appdir, appdir, appdir, appdir, old_env); - - old_env = getenv("LD_LIBRARY_PATH") ?: ""; -- SET_NEW_ENV(new_ld_library_path, appdir_s*10 + strlen(old_env), "LD_LIBRARY_PATH=%s/usr/lib/:%s/usr/lib/i386-linux-gnu/:%s/usr/lib/x86_64-linux-gnu/:%s/usr/lib32/:%s/usr/lib64/:%s/lib/:%s/lib/i386-linux-gnu/:%s/lib/x86_64-linux-gnu/:%s/lib32/:%s/lib64/:%s", appdir, appdir, appdir, appdir, appdir, appdir, appdir, appdir, appdir, appdir, old_env); -+ SET_NEW_ENV(new_ld_library_path, appdir_s*10 + strlen(old_env), "LD_LIBRARY_PATH=%s%s/usr/lib/:%s/usr/lib/i386-linux-gnu/:%s/usr/lib/x86_64-linux-gnu/:%s/usr/lib32/:%s/usr/lib64/:%s/lib/:%s/lib/i386-linux-gnu/:%s/lib/x86_64-linux-gnu/:%s/lib32/:%s/lib64/:%s", optional, appdir, appdir, appdir, appdir, appdir, appdir, appdir, appdir, appdir, appdir, old_env); - - old_env = getenv("PYTHONPATH") ?: ""; - SET_NEW_ENV(new_pythonpath, appdir_s + strlen(old_env), "PYTHONPATH=%s/usr/share/pyshared/:%s", appdir, old_env); -@@ -201,6 +205,9 @@ - if (ret == -1) - die("Error executing '%s': %s\n", exe, strerror(error)); +@@ -187,6 +192,9 @@ + die( "Error executing '%s'; return code: %d\n", executable, ret ); + } + free(optional); + if (optional_ld_preload) + free(optional_ld_preload); - free(line); - free(desktop_file); - free(usr_in_appdir); + free(new_env[6]); + free(new_env[5]); + free(new_env[4]); diff --git a/checkrt.c b/checkrt.c index 3a97ae5..0382fa6 100644 --- a/checkrt.c +++ b/checkrt.c @@ -41,14 +41,14 @@ ret = fscanf(f, "%s", sym); (void)ret; \ pclose(f); -#define CXXDIR "optional/libstdc++" -#define GCCDIR "optional/libgcc" -#define EXEC_SO "optional/exec.so" +#define CXXDIR "./optional/libstdc++" +#define GCCDIR "./optional/libgcc" +#define EXEC_SO "./optional/exec.so" char *optional = NULL; char *optional_ld_preload = NULL; -void checkrt(char *usr_in_appdir) +void checkrt() { int ret; FILE *f; @@ -58,8 +58,8 @@ void checkrt(char *usr_in_appdir) char stdcxx_bundle_sym[LINE_SIZE], gcc_bundle_sym[LINE_SIZE]; int stdcxx_sys_ver=1, stdcxx_bundle_ver=0, gcc_sys_ver=1, gcc_bundle_ver=0; - char *stdcxx_bundle_lib = "./" CXXDIR "/libstdc++.so.6"; - char *gcc_bundle_lib = "./" GCCDIR "/libgcc_s.so.1"; + char *stdcxx_bundle_lib = CXXDIR "/libstdc++.so.6"; + char *gcc_bundle_lib = GCCDIR "/libgcc_s.so.1"; const char *format = "tr '\\0' '\\n' < '%s' | grep -e '%s' | tail -n1"; if (access(stdcxx_bundle_lib, F_OK) == 0) { @@ -94,7 +94,6 @@ void checkrt(char *usr_in_appdir) int bundle_cxx = 0; int bundle_gcc = 0; - size_t len = strlen(usr_in_appdir); if (stdcxx_bundle_ver > stdcxx_sys_ver) bundle_cxx = 1; @@ -103,23 +102,21 @@ void checkrt(char *usr_in_appdir) bundle_gcc = 1; if (bundle_cxx == 1 || bundle_gcc == 1) { - len = strlen(EXEC_SO) + 12 + len; - optional_ld_preload = malloc(len); - sprintf(optional_ld_preload, "LD_PRELOAD=%s/" EXEC_SO, usr_in_appdir); - optional_ld_preload[len] = '\0'; + optional_ld_preload = malloc(strlen(EXEC_SO) + 12); + sprintf(optional_ld_preload, "LD_PRELOAD=" EXEC_SO); } if (bundle_cxx == 1 && bundle_gcc == 0) { - optional = malloc(strlen(CXXDIR) + 2 + len); - sprintf(optional, "%s/" CXXDIR ":", usr_in_appdir); + optional = malloc(strlen(CXXDIR) + 2); + sprintf(optional, CXXDIR ":"); } else if (bundle_cxx == 0 && bundle_gcc == 1) { - optional = malloc(strlen(GCCDIR) + 2 + len); - sprintf(optional, "%s/" GCCDIR ":", usr_in_appdir); + optional = malloc(strlen(GCCDIR) + 2); + sprintf(optional, GCCDIR ":"); } else if (bundle_cxx == 1 && bundle_gcc == 1) { - optional = malloc(strlen(GCCDIR) + strlen(CXXDIR) + 4 + len*2); - sprintf(optional, "%s/" GCCDIR ":%s/" CXXDIR ":", usr_in_appdir, usr_in_appdir); + optional = malloc(strlen(GCCDIR) + strlen(CXXDIR) + 3); + sprintf(optional, GCCDIR ":" CXXDIR ":"); } else { - optional = malloc(2); + optional = malloc(1); sprintf(optional, "%s", ""); } } diff --git a/checkrt.h b/checkrt.h index aafe389..29f3365 100644 --- a/checkrt.h +++ b/checkrt.h @@ -1,3 +1,3 @@ extern char *optional; extern char *optional_ld_preload; -extern void checkrt(char *usr_in_appdir); +extern void checkrt(void);