这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d3fe257
scripts(.editorconfig): use space indentation for `properties.sh`
agnostic-apollo Nov 19, 2024
96eefda
enhance(scripts/properties.sh): add all standardized Termux constants…
agnostic-apollo Mar 21, 2025
0e4a258
fix(scripts): do not delete `/home/builder/.termux-build` build direc…
agnostic-apollo Apr 1, 2024
8526c61
enhance(scripts): add support to build a package from a local source …
agnostic-apollo Apr 1, 2024
7731908
fix(scripts): fix building a package from a local git repository set …
agnostic-apollo Apr 1, 2024
f579c50
fix(scripts): quote variables (primarily) for `rm` commands
agnostic-apollo Apr 1, 2024
11d51ed
change(scripts): rename `TERMUX_NO_CLEAN` variable to `TERMUX_PKGS__B…
agnostic-apollo Apr 1, 2024
9159eab
fix(build-package.sh): fix passing flags to sub `build-package.sh` pr…
agnostic-apollo Apr 2, 2024
ac43018
enhance(build-package.sh): add -r option to remove all package build …
agnostic-apollo Apr 2, 2024
4d621c1
fix(build-package.sh): update `-c` flag help
agnostic-apollo Mar 5, 2025
a85aa09
scripts(build-package.sh): use `grep` directly instead of `cat | grep…
agnostic-apollo Sep 10, 2024
3b9bed8
fix(termux-bootstrap-second-stage.sh): do not exit with the wrong "se…
agnostic-apollo Nov 11, 2024
2f72c31
fix(termux-bootstrap-second-stage.sh): ensure running with Termux uid
agnostic-apollo Dec 14, 2024
5ea7272
fix(clean.sh): do not delete `TERMUX__ROOTFS` top level directory as …
agnostic-apollo Nov 11, 2024
2f3ee4c
fix(build-package.sh): fix wrong prefix variable being used to create…
agnostic-apollo Nov 11, 2024
71057fa
enhance(build-package.sh): add `termux_step_strip_elf_symbols` and `t…
agnostic-apollo Mar 3, 2025
72d0348
enhance(build-package.sh): extract `termux_step_create_debscripts()` …
agnostic-apollo Mar 4, 2025
e4829b1
addpkg(main/termux-core): init
agnostic-apollo Feb 26, 2025
7b6ac13
bump(main/termux-core): 0.1.0
agnostic-apollo Mar 22, 2025
f971824
enhance(main/termux-exec): add support for v1:2.0.0
agnostic-apollo Oct 28, 2024
eaf26b3
bump(main/termux-exec): 1:2.0.0
agnostic-apollo Feb 26, 2025
2d5e109
addpkg(main/tudo): 1.0.0
agnostic-apollo Dec 14, 2024
d601524
addpkg(main/sudo): 1.0.0
agnostic-apollo Dec 14, 2024
6b3a32c
ci(packages|package_updates): fix `No such file or directory` errors …
agnostic-apollo Dec 20, 2024
b55d562
ci(packages): remove unused packages loop from free additional disk s…
agnostic-apollo Dec 20, 2024
1a2eb24
ci(packages|package_updates): fix indexed arrays being used as string…
agnostic-apollo Dec 20, 2024
4c916b3
scripts(setup-ubuntu|setup-archlinux): do not use hardcoded `/data` p…
agnostic-apollo Dec 21, 2024
8a03e33
fix(scripts/Dockerfile): create termux-packages repo directory hierar…
agnostic-apollo Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ indent_size = 2
[ndk-patches/*.h]
indent_style = tab

[scripts/properties.sh]
indent_style = space
indent_size = 4

[scripts/utils/**.sh]
indent_style = space
indent_size = 4
6 changes: 3 additions & 3 deletions .github/workflows/package_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ jobs:
GIT_COMMIT_PACKAGES: "false"
GIT_PUSH_PACKAGES: "false"
run: |
declare -a packages
declare -a packages=()
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
if [ -f "./built_${repo}_packages.txt" ]; then
packages+=($(cat "./built_${repo}_packages.txt"))
fi
done
if [ -n "$packages" ]; then
Expand Down
64 changes: 35 additions & 29 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,26 @@ jobs:
fi
done

declare -a packages
declare -a packages=()
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
if [ -f "./built_${repo}_packages.txt" ]; then
packages+=($(cat "./built_${repo}_packages.txt"))
fi
done

echo "packages: ${packages[*]}"

docker='true'
[ -n "$packages" ] && if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then
docker='false'
if [[ "${#packages[@]}" -gt 0 ]]; then
for pkg in "${packages[@]}"; do
if grep -qFx "$pkg" ./scripts/big-pkgs.list; then
docker='false'
break
fi
done
fi

echo "docker-build=$docker" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
# Build local Docker image if setup scripts were changed.
Expand All @@ -191,30 +199,22 @@ jobs:

- name: Lint packages
run: |
declare -a package_recipes
declare -a package_recipes=()
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
package_recipes="$package_recipes $(cat ./built_${repo}_packages.txt | repo_path=${repo_path} awk '{print ENVIRON["repo_path"]"/"$1"/build.sh"}')"
if [ -f "./built_${repo}_packages.txt" ]; then
package_recipes+=($(cat "./built_${repo}_packages.txt" | repo_path="${repo_path}" awk '{print ENVIRON["repo_path"]"/"$1"/build.sh"}'))
fi
done

if [ -n "$package_recipes" ]; then
./scripts/lint-packages.sh $package_recipes
if [[ "${#package_recipes[@]}" -gt 0 ]]; then
./scripts/lint-packages.sh "${package_recipes[@]}"
fi

- name: Free additional disk space (if needed)
env:
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
run: |
declare -a packages
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
fi
done

if [ "$DOCKER_BUILD" == 'false' ]; then
./scripts/setup-ubuntu.sh
sudo apt install ninja-build
Expand All @@ -229,18 +229,22 @@ jobs:
env:
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
run: |
declare -a packages
declare -a packages=()
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
if [ -f "./built_${repo}_packages.txt" ]; then
packages+=($(cat "./built_${repo}_packages.txt"))
fi
done

if [ "$DOCKER_BUILD" == 'false' ]; then
NDK=$ANDROID_NDK ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh -I -C -a ${{ matrix.target_arch }} $packages
elif [ -n "$packages" ]; then
./scripts/run-docker.sh ./build-package.sh -I -C -a ${{ matrix.target_arch }} $packages
echo "packages: ${packages[*]}"

if [[ "${#packages[@]}" -gt 0 ]]; then
if [ "$DOCKER_BUILD" == 'false' ]; then
NDK="$ANDROID_NDK" ANDROID_HOME="$ANDROID_SDK_ROOT" ./build-package.sh -I -C -a "${{ matrix.target_arch }}" "${packages[@]}"
else
./scripts/run-docker.sh ./build-package.sh -I -C -a "${{ matrix.target_arch }}" "${packages[@]}"
fi
fi

- name: Generate build artifacts
Expand All @@ -258,10 +262,12 @@ jobs:

# Move only debs from built_packages into debs/ folder before
# creating an archive.
while read -r pkg; do
# Match both $pkg.deb and $pkg-static.deb.
find output \( -name "$pkg_*.deb" -o -name "$pkg-static_*.deb" \) -type f -print0 | xargs -0r mv -t debs/
done < <(cat ./debs/built_${repo}_packages.txt)
if [ -f "./debs/built_${repo}_packages.txt" ] && [ -d "output" ]; then
while read -r pkg; do
# Match both $pkg.deb and $pkg-static.deb.
find output \( -name "$pkg_*.deb" -o -name "$pkg-static_*.deb" \) -type f -print0 | xargs -0r mv -t debs/
done < <(cat "./debs/built_${repo}_packages.txt")
fi
done

# Files containing certain symbols (e.g. ":") will cause failure in actions/upload-artifact.
Expand Down
72 changes: 42 additions & 30 deletions build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,22 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_create_pacman_subpackages.sh"
# shellcheck source=scripts/build/termux_step_massage.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_massage.sh"

# Function to run strip symbols during termux_step_massage
# shellcheck source=scripts/build/termux_step_strip_elf_symbols.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_strip_elf_symbols.sh"

# Function to run termux-elf-cleaner during termux_step_massage
# shellcheck source=scripts/build/termux_step_elf_cleaner.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_elf_cleaner.sh"

# Hook for packages after massage step
termux_step_post_massage() {
return
}

# Hook function to create {pre,post}install, {pre,post}rm-scripts and similar
termux_step_create_debscripts() {
return
}
# Function to create {pre,post}install, {pre,post}rm-scripts and similar
# shellcheck source=scripts/build/termux_step_create_debscripts.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_debscripts.sh"

# Convert Debian maintainer scripts into pacman-compatible installation hooks.
# This is used only when creating pacman packages.
Expand Down Expand Up @@ -390,21 +397,23 @@ fi

# Check if the package is in the compiled list
termux_check_package_in_built_packages_list() {
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH" ] && termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH' not found."
cat "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH" | grep -q " $1 "
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH" ] && \
termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH' not found."
grep -q " $1 " "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH"
return $?
}

# Adds a package to the list of built packages if it is not in the list
termux_add_package_to_built_packages_list() {
if ! termux_check_package_in_built_packages_list "$1"; then
echo -n "$1 " >> $TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH
echo -n "$1 " >> "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH"
fi
}

# Check if the package is in the compiling list
termux_check_package_in_building_packages_list() {
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH" ] && termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH' not found."
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH" ] && \
termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH' not found."
grep -q "^${1}$" "$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH"
return $?
}
Expand All @@ -422,9 +431,9 @@ _show_usage() {
echo
echo "Available options:"
[ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && echo " -a The architecture to build for: aarch64(default), arm, i686, x86_64 or all."
echo " -d Build with debug symbols."
echo " -c Continue building."
echo " -c Continue previous build."
echo " -C Cleanup already built packages on low disk space."
echo " -d Build with debug symbols."
echo " -D Build a disabled package in disabled-packages/."
echo " -f Force build even if package has already been built."
echo " -F Force build even if package and its dependencies have already been built."
Expand All @@ -433,6 +442,10 @@ _show_usage() {
echo " -L The package and its dependencies will be based on the same library."
echo " -q Quiet build."
echo " -Q Loud build -- set -x debug output."
echo " -r Remove all package build dependent dirs that '-f/-F'"
echo " flags alone would not remove, like cache dir containing "
echo " package sources and host build dir. Ignored if '-f/-F'"
echo " flags are not passed."
echo " -w Install dependencies without version binding."
echo " -s Skip dependency check."
echo " -o Specify directory where to put built packages. Default: output/."
Expand Down Expand Up @@ -492,23 +505,18 @@ while (($# >= 1)); do
-i)
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
termux_error_exit "./build-package.sh: option '-i' is not available for on-device builds"
elif [ "$TERMUX_PREFIX" != "/data/data/com.termux/files/usr" ]; then
termux_error_exit "./build-package.sh: option '-i' is available only when TERMUX_APP_PACKAGE is 'com.termux'"
else
export TERMUX_INSTALL_DEPS=true
fi
;;
-I)
if [ "$TERMUX_PREFIX" != "/data/data/com.termux/files/usr" ]; then
termux_error_exit "./build-package.sh: option '-I' is available only when TERMUX_APP_PACKAGE is 'com.termux'"
else
export TERMUX_INSTALL_DEPS=true
export TERMUX_NO_CLEAN=true
fi
export TERMUX_INSTALL_DEPS=true
export TERMUX_PKGS__BUILD__RM_ALL_PKGS_BUILT_MARKER_AND_INSTALL_FILES=false
;;
-L) export TERMUX_GLOBAL_LIBRARY=true;;
-q) export TERMUX_QUIET_BUILD=true;;
-Q) set -x;;
-r) export TERMUX_PKGS__BUILD__RM_ALL_PKG_BUILD_DEPENDENT_DIRS=true;;
-w) export TERMUX_WITHOUT_DEPVERSION_BINDING=true;;
-s) export TERMUX_SKIP_DEPCHECK=true;;
-o)
Expand All @@ -533,8 +541,8 @@ unset -f _show_usage

# Dependencies should be used from repo only if they are built for
# same package name.
if [ "$TERMUX_REPO_PACKAGE" != "$TERMUX_APP_PACKAGE" ]; then
echo "Ignoring -i option to download dependencies since repo package name ($TERMUX_REPO_PACKAGE) does not equal app package name ($TERMUX_APP_PACKAGE)"
if [ "$TERMUX_REPO_APP__PACKAGE_NAME" != "$TERMUX_APP_PACKAGE" ]; then
echo "Ignoring -i option to download dependencies since repo package name ($TERMUX_REPO_APP__PACKAGE_NAME) does not equal app package name ($TERMUX_APP_PACKAGE)"
TERMUX_INSTALL_DEPS=false
fi

Expand Down Expand Up @@ -588,12 +596,20 @@ for ((i=0; i<${#PACKAGE_LIST[@]}; i++)); do
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ] && [ -n "${TERMUX_ARCH+x}" ] && [ "${TERMUX_ARCH}" = 'all' ]; then
for arch in 'aarch64' 'arm' 'i686' 'x86_64'; do
env TERMUX_ARCH="$arch" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh \
${TERMUX_FORCE_BUILD+-f} ${TERMUX_INSTALL_DEPS+-i} ${TERMUX_IS_DISABLED+-D} \
${TERMUX_DEBUG_BUILD+-d} ${TERMUX_OUTPUT_DIR+-o $TERMUX_OUTPUT_DIR} \
${TERMUX_FORCE_BUILD_DEPENDENCIES+-F} ${TERMUX_GLOBAL_LIBRARY+-L} \
${TERMUX_WITHOUT_DEPVERSION_BINDING+-w} ${TERMUX_CLEANUP_BUILT_PACKAGES_ON_LOW_DISK_SPACE+-C} \
--format ${TERMUX_PACKAGE_FORMAT:=debian} \
--library ${TERMUX_PACKAGE_LIBRARY:=bionic} "${PACKAGE_LIST[i]}"
$(test "${TERMUX_CLEANUP_BUILT_PACKAGES_ON_LOW_DISK_SPACE:-}" = "true" && echo "-C") \
$(test "${TERMUX_DEBUG_BUILD:-}" = "true" && echo "-d") \
$(test "${TERMUX_IS_DISABLED:-}" = "true" && echo "-D") \
$({ test "${TERMUX_FORCE_BUILD:-}" = "true" && test "${TERMUX_FORCE_BUILD_DEPENDENCIES:-}" != "true"; } && echo "-f") \
$({ test "${TERMUX_FORCE_BUILD:-}" = "true" && test "${TERMUX_FORCE_BUILD_DEPENDENCIES:-}" = "true"; } && echo "-F") \
$({ test "${TERMUX_INSTALL_DEPS:-}" = "true" && test "${TERMUX_PKGS__BUILD__RM_ALL_PKGS_BUILT_MARKER_AND_INSTALL_FILES:-}" != "false"; } && echo "-i") \
$({ test "${TERMUX_INSTALL_DEPS:-}" = "true" && test "${TERMUX_PKGS__BUILD__RM_ALL_PKGS_BUILT_MARKER_AND_INSTALL_FILES:-}" = "false"; } && echo "-I") \
$(test "${TERMUX_GLOBAL_LIBRARY:-}" = "true" && echo "-L") \
$(test -n "${TERMUX_OUTPUT_DIR:-}" && echo "-o $TERMUX_OUTPUT_DIR") \
$(test "${TERMUX_PKGS__BUILD__RM_ALL_PKG_BUILD_DEPENDENT_DIRS:-}" = "true" && echo "-r") \
$(test "${TERMUX_WITHOUT_DEPVERSION_BINDING:-}" = "true" && echo "-w") \
$(test -n "${TERMUX_PACKAGE_FORMAT:-}" && echo "--format $TERMUX_PACKAGE_FORMAT") \
$(test -n "${TERMUX_PACKAGE_LIBRARY:-}" && echo "--library $TERMUX_PACKAGE_LIBRARY") \
"${PACKAGE_LIST[i]}"
done
exit
fi
Expand Down Expand Up @@ -628,10 +644,6 @@ for ((i=0; i<${#PACKAGE_LIST[@]}; i++)); do
termux_step_setup_variables
termux_step_handle_buildarch

if [ "$TERMUX_CONTINUE_BUILD" == "false" ]; then
termux_step_setup_build_folders
fi

termux_step_cleanup_packages
termux_step_start_build

Expand Down
54 changes: 37 additions & 17 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,48 @@ fi
chmod +w -R "$TERMUX_TOPDIR" || true
fi

# For on-device build cleanup /data shouldn't be erased.
# For on-device build cleanup Termux app data directory shouldn't be erased.
if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then
if [[ ! "$TERMUX_BASE_DIR" =~ ^(/[^/]+)+$ ]]; then
echo "TERMUX_BASE_DIR '$TERMUX_BASE_DIR' is not an absolute path under rootfs '/'." 1>&2
exit 1
fi
if [[ "$TERMUX_BASE_DIR" =~ ^/[^/]+$ ]]; then
# Use `/rootfs` as is.
rootfs_top_level_dir="$TERMUX_BASE_DIR"
for variable_name in TERMUX__PREFIX TERMUX_APP__DATA_DIR CGCT_DIR; do
variable_value="${!variable_name:-}"
if [[ ! "$variable_value" =~ ^(/[^/]+)+$ ]]; then
echo "The $variable_name '$variable_value' is not an absolute path under rootfs '/' while running 'clean.sh'." 1>&2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these two could use a rename.
And probably also a comment because I just had to reference the man page to remember that ${!var} is an indirection, not a key lookup (${!arr[i]}).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which two and comment what? ${!var} is pretty common and loop items are clearly variable names anyways being expanded to a value.

exit 1
fi
done

# If `TERMUX__PREFIX` is under `TERMUX_APP__DATA_DIR`, then
# just delete the entire `TERMUX_APP__DATA_DIR`. Otherwise,
# only delete `TERMUX__PREFIX` since its parent directories could
# be a critical directory in `TERMUX_REGEX__INVALID_TERMUX_PREFIX_PATHS`.
# This should not be an issue as package files are only packed
# from `TERMUX_PREFIX_CLASSICAL` via `termux_step_extract_into_massagedir()`.
if [[ "$TERMUX__PREFIX" == "$TERMUX_APP__DATA_DIR" ]] || \
[[ "$TERMUX__PREFIX" == "$TERMUX_APP__DATA_DIR/"* ]]; then
deletion_dir="$TERMUX_APP__DATA_DIR"
else
# Get `/path/` from `/path/to/rootfs`.
rootfs_top_level_dir="${TERMUX_BASE_DIR%"${TERMUX_BASE_DIR#/*/}"}"
deletion_dir="$TERMUX__PREFIX"
fi

if [[ ! "$CGCT_DIR" =~ ^(/[^/]+)+$ ]] || [[ "$CGCT_DIR" == "$TERMUX_BASE_DIR" ]]; then
echo "CGCT_DIR '$CGCT_DIR' is not an absolute path under rootfs '/' or equals TERMUX_BASE_DIR." 1>&2
exit 1
fi
if [[ -e "$deletion_dir" ]]; then
if [[ ! -d "$deletion_dir" ]]; then
echo "A non-directory file exists at deletion directory '$deletion_dir' for TERMUX__PREFIX while running 'clean.sh'." 1>&2
exit 1
fi

# Escape '\$[](){}|^.?+*' with backslashes
cgct_dir_escaped="$(printf "%s" "$CGCT_DIR" | sed -zE -e 's/[][\.|$(){}?+*^]/\\&/g')"
find "$rootfs_top_level_dir" -mindepth 1 -regextype posix-extended ! -regex "^$cgct_dir_escaped(/.*)?" -delete 2>/dev/null || true
# If deletion directory is under rootfs `/` or not accessible
# by current user, like the `builder` user in Termux docker
# cannot access root owned directories.
if [[ ! -r "$deletion_dir" ]] || [[ ! -w "$deletion_dir" ]] || [[ ! -x "$deletion_dir" ]]; then
echo "The deletion directory '$deletion_dir' for TERMUX__PREFIX is not readable, writable or searchable while running 'clean.sh'." 1>&2
echo "Try running 'clean.sh' with 'sudo'." 1>&2
exit 1
fi

# Escape '\$[](){}|^.?+*' with backslashes.
cgct_dir_escaped="$(printf "%s" "$CGCT_DIR" | sed -zE -e 's/[][\.|$(){}?+*^]/\\&/g')"
find "$deletion_dir" -mindepth 1 -regextype posix-extended ! -regex "^$cgct_dir_escaped(/.*)?" -delete 2>/dev/null || true
fi
fi

rm -Rf "$TERMUX_TOPDIR"
Expand Down
27 changes: 27 additions & 0 deletions packages/sudo/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
TERMUX_PKG_HOMEPAGE=https://github.com/agnostic-apollo/sudo
TERMUX_PKG_DESCRIPTION="A wrapper script to drop to the supported shells or execute shell script files or their text passed as an argument as the root (superuser) user in the Termux app"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@agnostic-apollo"
TERMUX_PKG_VERSION=1.0.0
TERMUX_PKG_SRCURL=https://github.com/agnostic-apollo/sudo/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=3ebbc7c034cb184da46d253d8c9f90935de05161d2292aed5417d5a662a46ea9
TERMUX_PKG_DEPENDS="bash"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_PLATFORM_INDEPENDENT=true
TERMUX_PKG_CONFLICTS="tsu"
TERMUX_PKG_REPLACES="tsu"
TERMUX_PKG_EXTRA_MAKE_ARGS="SUDO_PKG__VERSION=${TERMUX_PKG_VERSION} SUDO_PKG__ARCH=${TERMUX_ARCH} \
TERMUX__NAME=${TERMUX__NAME} TERMUX__LNAME=${TERMUX__LNAME} \
TERMUX_APP__NAME=${TERMUX_APP__NAME} \
TERMUX_APP__PACKAGE_NAME=${TERMUX_APP__PACKAGE_NAME} TERMUX_APP__DATA_DIR=${TERMUX_APP__DATA_DIR} \
TERMUX__ROOTFS=${TERMUX__ROOTFS} TERMUX__HOME=${TERMUX__HOME} TERMUX__PREFIX=${TERMUX__PREFIX} \
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_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/"
}
Loading