Skip to content

Commit

Permalink
enhance(main/termux-exec): add support for v2.0.0
Browse files Browse the repository at this point in the history
Related pull termux/termux-exec#24

e
  • Loading branch information
agnostic-apollo committed Jan 5, 2025
1 parent 2c6642a commit 5ef9f88
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 4 deletions.
13 changes: 13 additions & 0 deletions packages/termux-exec/basename.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Fix `implicit declaration of function 'basename' is invalid in C99`
---

diff -uNr a/src/file/file_utils.c b/src/file/file_utils.c
--- a/src/file/file_utils.c
+++ b/src/file/file_utils.c
@@ -1,5 +1,6 @@
#define _GNU_SOURCE
#include <errno.h>
+#include <libgen.h> /* for basename(3) */
#include <limits.h>
#include <regex.h>
#include <stdio.h>
30 changes: 26 additions & 4 deletions packages/termux-exec/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
TERMUX_PKG_HOMEPAGE=https://github.com/termux/termux-exec
TERMUX_PKG_DESCRIPTION="An execve() wrapper to make /bin and /usr/bin shebangs work"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_VERSION=0.4
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://github.com/termux/termux-exec/archive/v$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=9a8d42d211a7d461d61dcd4e3ef984014c2c2c696cfd6394bae389af13572627
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1:1.0
TERMUX_PKG_SRCURL=https://github.com/termux/termux-exec/archive/v${TERMUX_PKG_VERSION:2}.tar.gz
TERMUX_PKG_SHA256=b977592f197bf3a87e8a005ea0ccefb3e144edc81d5e3dc8d1ad1a12512f4a68
TERMUX_PKG_ESSENTIAL=true
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_MAKE_ARGS="TERMUX_EXEC_PKG__VERSION=${TERMUX_PKG_VERSION} TERMUX_EXEC_PKG__ARCH=${TERMUX_ARCH} \
TERMUX__NAME=${TERMUX__NAME} TERMUX__LNAME=${TERMUX__LNAME} \
TERMUX_APP__PACKAGE_NAME=${TERMUX_APP__PACKAGE_NAME} TERMUX_APP__DATA_DIR=${TERMUX_APP__DATA_DIR} \
TERMUX__ROOTFS=${TERMUX__ROOTFS} TERMUX__PREFIX=${TERMUX__PREFIX} \
TERMUX__PREFIX__BIN_DIR=${TERMUX__PREFIX__BIN_DIR} TERMUX__PREFIX__TMP_DIR=${TERMUX__PREFIX__TMP_DIR} \
TERMUX_ENV__S_ROOT=${TERMUX_ENV__S_ROOT} \
TERMUX_ENV__SS_TERMUX=${TERMUX_ENV__SS_TERMUX} TERMUX_ENV__S_TERMUX=${TERMUX_ENV__S_TERMUX} \
TERMUX_ENV__SS_TERMUX_APP=${TERMUX_ENV__SS_TERMUX_APP} TERMUX_ENV__S_TERMUX_APP=${TERMUX_ENV__S_TERMUX_APP} \
TERMUX_ENV__SS_TERMUX_API_APP=${TERMUX_ENV__SS_TERMUX_API_APP} TERMUX_ENV__S_TERMUX_API_APP=${TERMUX_ENV__S_TERMUX_API_APP} \
TERMUX_ENV__SS_TERMUX_ROOTFS=${TERMUX_ENV__SS_TERMUX_ROOTFS} TERMUX_ENV__S_TERMUX_ROOTFS=${TERMUX_ENV__S_TERMUX_ROOTFS} \
TERMUX_ENV__SS_TERMUX_CORE=${TERMUX_ENV__SS_TERMUX_CORE} TERMUX_ENV__S_TERMUX_CORE=${TERMUX_ENV__S_TERMUX_CORE} \
TERMUX_ENV__SS_TERMUX_CORE__TESTS=${TERMUX_ENV__SS_TERMUX_CORE__TESTS} TERMUX_ENV__S_TERMUX_CORE__TESTS=${TERMUX_ENV__S_TERMUX_CORE__TESTS} \
TERMUX_ENV__SS_TERMUX_EXEC=${TERMUX_ENV__SS_TERMUX_EXEC} TERMUX_ENV__S_TERMUX_EXEC=${TERMUX_ENV__S_TERMUX_EXEC} \
TERMUX_ENV__SS_TERMUX_EXEC__TESTS=${TERMUX_ENV__SS_TERMUX_EXEC__TESTS} TERMUX_ENV__S_TERMUX_EXEC__TESTS=${TERMUX_ENV__S_TERMUX_EXEC__TESTS} \
TERMUX_APP__NAMESPACE=${TERMUX_APP__NAMESPACE} \
TERMUX_APP__SHELL_ACTIVITY__COMPONENT_NAME=${TERMUX_APP__SHELL_ACTIVITY__COMPONENT_NAME} TERMUX_APP__SHELL_SERVICE__COMPONENT_NAME=${TERMUX_APP__SHELL_SERVICE__COMPONENT_NAME}"

termux_step_install_license() {
mkdir -p "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/licenses"
mv "$TERMUX_PKG_SRCDIR/LICENSE" "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/copyright"
mv "$TERMUX_PKG_SRCDIR/licenses/"* "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/licenses/"
}
23 changes: 23 additions & 0 deletions packages/termux-exec/memcpy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Fix `implicit declaration of function 'mempcpy' is invalid in C99`
---

diff -uNr a/src/exec/exec_variants.c b/src/exec/exec_variants.c
--- a/src/exec/exec_variants.c
+++ b/src/exec/exec_variants.c
@@ -43,6 +43,16 @@

static const char* LOG_TAG = "exec";

+#ifdef __ANDROID__
+# ifndef ANDROID_MEMPCPY
+# define ANDROID_MEMPCPY 1
+static __inline__ void* mempcpy(void* dest, void const* src, size_t n)
+{
+ return memcpy(dest, src, n) + n;
+}
+# endif
+#endif
+
int execl_hook(bool hook, int variant, const char *name, const char *argv0, va_list ap) {
if (hook) {
logErrorDebug(LOG_TAG, "<----- %s() hooked ----->", EXEC_VARIANTS_STR[variant]);
1 change: 1 addition & 0 deletions scripts/build/termux_step_patch_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ termux_step_patch_package() {
-e "s%\@TERMUX_ENV__S_TERMUX_APP\@%${TERMUX_ENV__S_TERMUX_APP}%g" \
-e "s%\@TERMUX_ENV__S_TERMUX_API_APP\@%${TERMUX_ENV__S_TERMUX_API_APP}%g" \
-e "s%\@TERMUX_ENV__S_TERMUX_ROOTFS\@%${TERMUX_ENV__S_TERMUX_ROOTFS}%g" \
-e "s%\@TERMUX_ENV__S_TERMUX_EXEC\@%${TERMUX_ENV__S_TERMUX_EXEC}%g" \
"$patch" | patch --silent -p1
done
shopt -u nullglob
Expand Down
51 changes: 51 additions & 0 deletions scripts/properties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,57 @@ TERMUX_ENV__SS_TERMUX_CORE__TESTS="CORE__TESTS__"
# Default value: `TERMUX_CORE__TESTS__`
##
TERMUX_ENV__S_TERMUX_CORE__TESTS="${TERMUX_ENV__S_ROOT}${TERMUX_ENV__SS_TERMUX_CORE__TESTS}"



##
# Termux environment variables `termux-exec` sub scope.
#
# **Do not modify this!** This is considered a constant `termux-exec`
# sub scope for Termux execution environment that's used by external
# programs that do not use the termux packages building infrastructure
# and rely on `$TERMUX_ENV__S_ROOT` environment variable exported by
# Termux app containing the root scope to generate the value for
# `$TERMUX_ENV__S_TERMUX_EXEC` and variable names under it.**
#
# Default value: `EXEC__`
##
TERMUX_ENV__SS_TERMUX_EXEC="EXEC__"

##
# Termux environment variables `termux-exec` scope.
#
# **Do not modify this!**
#
# Default value: `TERMUX_EXEC__`
##
TERMUX_ENV__S_TERMUX_EXEC="${TERMUX_ENV__S_ROOT}${TERMUX_ENV__SS_TERMUX_EXEC}"


##
# Termux environment variables `termux-exec-tests` sub scope.
#
# **Do not modify this!** This is considered a constant
# `termux-exec-tests` sub scope for Termux execution environment
# that's used by `termux-exec` package to generate the value for
# `$TERMUX_ENV__S_TERMUX_EXEC__TESTS` and variable names under it.**
#
# Default value: `TERMUX_EXEC__TESTS__`
##
TERMUX_ENV__SS_TERMUX_EXEC__TESTS="EXEC__TESTS__"

##
# Termux environment variables `termux-exec-tests` scope.
#
# **Do not modify this!**
#
# Default value: `TERMUX_EXEC__TESTS__`
##
TERMUX_ENV__S_TERMUX_EXEC__TESTS="${TERMUX_ENV__S_ROOT}${TERMUX_ENV__SS_TERMUX_EXEC__TESTS}"



##
# Termux environment variables `termux-am-socket` sub scope.
#
# **Do not modify this!** This is considered a constant `termux-am-socket`
Expand Down

0 comments on commit 5ef9f88

Please sign in to comment.