mirror of
https://github.com/termux/termux-packages.git
synced 2024-12-11 23:00:52 +00:00
82 lines
2.8 KiB
Diff
82 lines
2.8 KiB
Diff
--- a/client/app_start.cpp
|
|
+++ b/client/app_start.cpp
|
|
@@ -81,6 +81,10 @@
|
|
|
|
#include "app.h"
|
|
|
|
+#ifdef __ANDROID__
|
|
+#include <stdlib.h> // getenv(), setenv(), unsetenv()
|
|
+char helper_path[] = "@TERMUX_PREFIX@/bin/proot";
|
|
+#endif
|
|
|
|
#ifdef _WIN32
|
|
// Dynamically link to these functions at runtime;
|
|
@@ -1125,6 +1129,49 @@
|
|
//
|
|
umask(2);
|
|
retval = execv(switcher_path, argv);
|
|
+#ifdef __ANDROID__
|
|
+#if defined(__aarch64__) || defined(__arm__)
|
|
+ } else if (strstr(exec_name, "unknown-linux-gnu")) {
|
|
+#elif defined(__x86_64__) || defined(__i386__)
|
|
+ } else if (strstr(exec_name, "pc-linux-gnu")) {
|
|
+#endif
|
|
+ // experimental GNU/Linux tasks support via proot
|
|
+ argv[0] = helper_path;
|
|
+ argv[1] = buf;
|
|
+ parse_command_line(cmdline, argv+2);
|
|
+ // unsure this debug copied from above works or not
|
|
+ if (log_flags.task_debug) {
|
|
+ debug_print_argv(argv);
|
|
+ }
|
|
+ // backup and unset LD_PRELOAD var for proot
|
|
+ char *old_env = getenv("LD_PRELOAD");
|
|
+ unsetenv("LD_PRELOAD");
|
|
+ // helper_path must be valid and exists to work
|
|
+ retval = execv(helper_path, argv);
|
|
+ // set LD_PRELOAD var back
|
|
+ setenv("LD_PRELOAD", old_env, 1);
|
|
+ free(old_env);
|
|
+#if defined(__aarch64__)
|
|
+ } else if (strstr(exec_name, "arm-android-linux-gnu")) {
|
|
+#elif defined(__x86_64__)
|
|
+ } else if (strstr(exec_name, "x86-android-linux-gnu")) {
|
|
+#endif
|
|
+#if defined(__aarch64__) || defined(__x86_64__)
|
|
+ // fix Termux 32bit compatibility on 64bit devices
|
|
+ // should be no longer required as its fixed on
|
|
+ // termux-exec side, kept for references
|
|
+ // https://github.com/termux/termux-exec/pull/17
|
|
+ argv[0] = buf;
|
|
+ parse_command_line(cmdline, argv+1);
|
|
+ // backup and unset LD_PRELOAD var
|
|
+ char *old_env = getenv("LD_PRELOAD");
|
|
+ unsetenv("LD_PRELOAD");
|
|
+ retval = execv(buf, argv);
|
|
+ // set LD_PRELOAD var back
|
|
+ setenv("LD_PRELOAD", old_env, 1);
|
|
+ free(old_env);
|
|
+#endif
|
|
+#endif // __ANDROID__
|
|
} else {
|
|
argv[0] = buf;
|
|
parse_command_line(cmdline, argv+1);
|
|
@@ -1147,6 +1194,17 @@
|
|
);
|
|
}
|
|
|
|
+#ifdef __ANDROID__
|
|
+ // get debug info from client not from forked task
|
|
+#if defined(__aarch64__) || defined(__arm__)
|
|
+ if (strstr(exec_name, "unknown-linux-gnu")) {
|
|
+#elif defined(__x86_64__) || defined(__i386__)
|
|
+ if (strstr(exec_name, "pc-linux-gnu")) {
|
|
+#endif
|
|
+ msg_printf(NULL, MSG_INFO, "Helper: Running %s via %s\n", exec_name, helper_path);
|
|
+ }
|
|
+#endif // __ANDROID__
|
|
+
|
|
#endif
|
|
set_task_state(PROCESS_EXECUTING, "start");
|
|
return 0;
|