From c86229dd998091d01898b2c6a6203b914466e026 Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Tue, 2 Apr 2024 02:44:12 +0500 Subject: [PATCH] enhance(scripts,main/android-tools,main/libllvm): replace `TERMUX_ENV__S_TERMUX` in patch files, currently for `$TERMUX_EXEC__PROC_SELF_EXE` Related pull https://github.com/termux/termux-exec/pull/24 --- packages/android-tools/termux-exec.patch | 6 +++--- packages/libllvm/llvm-lib-Support-Unix-Path.inc.patch | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/android-tools/termux-exec.patch b/packages/android-tools/termux-exec.patch index 681df7ae37524c6..d243abef6333999 100644 --- a/packages/android-tools/termux-exec.patch +++ b/packages/android-tools/termux-exec.patch @@ -5,7 +5,7 @@ #if defined(__linux__) std::string path; - android::base::Readlink("/proc/self/exe", &path); -+ if (const char *tmp = std::getenv("TERMUX_EXEC__PROC_SELF_EXE")) ++ if (const char *tmp = std::getenv("@TERMUX_ENV__S_TERMUX_EXEC@PROC_SELF_EXE")) + path.assign(tmp); + else + android::base::Readlink("/proc/self/exe", &path); @@ -35,7 +35,7 @@ - ssize_t exPathLen = readlink("/proc/self/exe", exPath, sizeof(exPath)); + ssize_t exPathLen; + const char *tmp; -+ if (tmp = getenv("TERMUX_EXEC__PROC_SELF_EXE")) { ++ if (tmp = getenv("@TERMUX_ENV__S_TERMUX_EXEC@PROC_SELF_EXE")) { + strncpy(exPath, tmp, sizeof(exPath)); + exPathLen = strlen(exPath) + } else { @@ -51,7 +51,7 @@ bool RunAs::Prepare() { // run-as can't run /data/local/tmp/simpleperf directly. So copy simpleperf binary if needed. - if (!android::base::Readlink("/proc/self/exe", &simpleperf_path_)) { -+ if (const char *tmp = std::getenv("TERMUX_EXEC__PROC_SELF_EXE")) ++ if (const char *tmp = std::getenv("@TERMUX_ENV__S_TERMUX_EXEC@PROC_SELF_EXE")) + simpleperf_path_.assign(tmp); + else if (!android::base::Readlink("/proc/self/exe", &simpleperf_path_)) { PLOG(ERROR) << "ReadLink failed"; diff --git a/packages/libllvm/llvm-lib-Support-Unix-Path.inc.patch b/packages/libllvm/llvm-lib-Support-Unix-Path.inc.patch index 13c804e8dbfb3b3..1fd29922a27b31e 100644 --- a/packages/libllvm/llvm-lib-Support-Unix-Path.inc.patch +++ b/packages/libllvm/llvm-lib-Support-Unix-Path.inc.patch @@ -6,7 +6,7 @@ diff -u -r ../orig-src/llvm/lib/Support/Unix/Path.inc ./llvm/lib/Support/Unix/Pa if (getprogpath(exe_path, argv0) != NULL) return exe_path; +#elif defined(__ANDROID__) // termux-exec linker wrapping does not work with /proc/self/exe -+ const char *termux_self_exe = std::getenv("TERMUX_EXEC__PROC_SELF_EXE"); ++ const char *termux_self_exe = std::getenv("@TERMUX_ENV__S_TERMUX_EXEC@PROC_SELF_EXE"); + if (termux_self_exe != NULL) return std::string(termux_self_exe); + if (char *real_path = realpath("/proc/self/exe", nullptr)) { + std::string ret = std::string(real_path);