这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a3cce46
enhance(scripts/properties.sh): add all standardized Termux constants…
agnostic-apollo Mar 21, 2025
5b55537
enhance(scripts): add support to build a package from a local source …
agnostic-apollo Dec 15, 2024
73a9509
fix(clean.sh): do not delete `TERMUX__ROOTFS` top level directory as …
agnostic-apollo Dec 15, 2024
a1c26c3
enhance(build-package.sh): add `termux_step_strip_elf_symbols` and `t…
agnostic-apollo Mar 3, 2025
4d2e460
enhance(build-package.sh): extract `termux_step_create_debscripts()` …
agnostic-apollo Mar 4, 2025
4e17417
enhance(.gitignore): make consistent with `master` branch
agnostic-apollo Dec 15, 2024
70b18ee
bump(main/termux-am-socket): 1.5.0
agnostic-apollo Dec 15, 2024
39d574b
addpkg(main/termux-core): init
agnostic-apollo Mar 22, 2025
1885fd3
fix(main/termux-core): fix `environment is too large for exec` error …
agnostic-apollo Dec 16, 2024
fc70e03
bump(main/termux-core): 0.1.0
agnostic-apollo Mar 22, 2025
5f2c28b
enhance(main/termux-exec): add support for v1:2.0.0
agnostic-apollo Mar 22, 2025
d867d31
enhance(main/termux-exec): enable aborting execve() with a debug erro…
agnostic-apollo Mar 22, 2025
3b0487b
bump(main/termux-exec): 1:2.0.0
agnostic-apollo Mar 1, 2025
c344517
addpkg(main/sudo): 1.0.0
agnostic-apollo Dec 15, 2024
925a3dc
addpkg(main/tudo): 1.0.0
agnostic-apollo Dec 15, 2024
c3f0d73
fix(scripts/Dockerfile): create termux-packages repo directory hierar…
agnostic-apollo Dec 21, 2024
25e8499
setup scripts: do not use sudo if already running under root
agnostic-apollo Dec 22, 2024
5807601
scripts(setup-ubuntu|setup-archlinux): do not use hardcoded `/data` p…
agnostic-apollo Dec 22, 2024
fe53183
enhance(main/termux-tools): export `libtermux-exec-ld-preload.so` for…
agnostic-apollo Mar 21, 2025
323c33b
enhance(main/termux-tools): sync `termux-info` with `termux-tools pac…
agnostic-apollo Mar 21, 2025
13058f0
bump(main/termux-tools): 0.78
agnostic-apollo Mar 21, 2025
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
39 changes: 35 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
### Vim ###
# Vim
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
/debs/
### Vagrant ###
scripts/*.log

# Vagrant
scripts/.vagrant/

# Logs
scripts/*.log
/*.log

# Misc archives
/*\.deb
/*\.zip
/*\.tar
/*\.tar\.*

# Source files.
/sources/

# GitHub Actions build artifacts
debs*
checksum*

# Built *.deb files.
/debs/
/output/

# Preinstalled build tools.
/build-tools/

# Predownloaded packages sources.
/packages/*/cache
/root-packages/*/cache
/x11-packages/*/cache

# Temp .git directories for packages built from local sources "file://"
/*.git
15 changes: 11 additions & 4 deletions build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_create_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
Expand All @@ -184,10 +192,9 @@ termux_step_post_massage() {
# shellcheck source=scripts/build/termux_step_create_datatar.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_create_datatar.sh"

# 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"

# Create the build deb file. Not to be overridden by package scripts.
# shellcheck source=scripts/build/termux_step_create_debfile.sh
Expand Down
53 changes: 47 additions & 6 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/sh
#!/bin/bash
# clean.sh - clean everything.
set -e -u

TERMUX_SCRIPTDIR=$(cd "$(realpath "$(dirname "$0")")"; pwd)

. "$TERMUX_SCRIPTDIR/scripts/properties.sh"

# Checking if script is running on Android with 2 different methods.
# Needed for safety to prevent execution of potentially dangerous
# operations such as 'rm -rf /data/*' on Android device.
Expand Down Expand Up @@ -38,10 +42,47 @@ fi
chmod +w -R "$TERMUX_TOPDIR"
fi

if $TERMUX_ON_DEVICE_BUILD; then
# For on-device build cleanup /data shouldn't be erased.
rm -Rf "$TERMUX_TOPDIR"
else
rm -Rf /data/* "$TERMUX_TOPDIR"
# For on-device build cleanup Termux app data directory shouldn't be erased.
if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then
for variable_name in TERMUX__PREFIX TERMUX_APP__DATA_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
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` 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
deletion_dir="$TERMUX__PREFIX"
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

# 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

find "$deletion_dir" -mindepth 1 -delete 2>/dev/null || true
fi
fi

rm -Rf "$TERMUX_TOPDIR"
} 5< "$TERMUX_BUILD_LOCK_FILE"
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/"
}
16 changes: 14 additions & 2 deletions packages/termux-am-socket/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ TERMUX_PKG_HOMEPAGE=https://github.com/termux/termux-am-socket
TERMUX_PKG_DESCRIPTION="A faster version of am with less features that only works while Termux is running"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.3.0
TERMUX_PKG_VERSION=1.5.0
TERMUX_PKG_SRCURL=https://github.com/termux/termux-am-socket/archive/refs/tags/${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=a0ac6f1733b0545b0a71de60615b6d4f781fb9e018d1841160308ed992c77997
TERMUX_PKG_SHA256=5175023c7fd675492451a72d06b75c772f257685b69fe117227bae5a5e6f5494
TERMUX_PKG_DEPENDS="libc++"

termux_step_post_get_source() {

for file in "${TERMUX_PKG_SRCDIR}/"*; do
sed -i'' -E -e "s|^(TERMUX_AM_SOCKET_VERSION=).*|\1$TERMUX_PKG_FULLVERSION|" \
-e "s|\@TERMUX_APP_PACKAGE\@|${TERMUX_APP_PACKAGE}|g" \
-e "s|\@TERMUX_APPS_DIR\@|${TERMUX_APPS_DIR}|g" \
"$file"
done

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
##### @TERMUX_CORE__BASH__TERMUX_APPS_INFO_ENV_VARIABLE@ to be replaced at build time. #####

##### @TERMUX_CORE__BASH__TERMUX_APPS_INFO_APP_VERSION_NAME@ replaced at build time. (START) #####

##
# Get/Unset variable values of the app version name environment
# variables `*_APP__APP_VERSION_NAME` for Termux app `TERMUX_APP__`,
# its plugin apps `TERMUX_*_APP__` and external apps `*_APP__` app
# scoped that exist in the `termux-apps-info.env` file, with support
# for validation of values.
#
# **See Also:**
# - @TERMUX_CORE_PKG__REPO_URL@/blob/master/site/pages/en/projects/docs/usage/utils/termux/shell/command/environment/termux-apps-info-app-version-name.md
# - @TERMUX_CORE_PKG__REPO_URL@/blob/master/app/main/scripts/termux/shell/command/environment/termux-apps-info-app-version-name.bash.in
# - @TERMUX_PKGS__REPO_URL@/blob/master/packages/termux-core/app/main/scripts/termux/shell/command/environment/termux_core__bash__termux_apps_info_app_version_name
# .
# - @TERMUX_CORE_PKG__REPO_URL@/blob/master/site/pages/en/projects/docs/usage/utils/termux/shell/command/environment/termux-apps-info-env-variable.md
# - @TERMUX_CORE_PKG__REPO_URL@/blob/master/app/main/scripts/termux/shell/command/environment/termux-apps-info-env-variable.bash.in
# - @TERMUX_PKGS__REPO_URL@/blob/master/packages/termux-core/app/main/scripts/termux/shell/command/environment/termux_core__bash__termux_apps_info_env_variable
# .
# - @TERMUX_CORE_PKG__REPO_URL@/blob/master/site/pages/en/projects/docs/usage/utils/termux/shell/command/environment/termux-scoped-env-variable.md
# - @TERMUX_CORE_PKG__REPO_URL@/blob/master/app/main/scripts/termux/shell/command/environment/termux-scoped-env-variable.bash.in
# - @TERMUX_PKGS__REPO_URL@/blob/master/packages/termux-core/app/main/scripts/termux/shell/command/environment/termux_core__bash__termux_scoped_env_variable
#
#
# `termux_core__bash__termux_apps_info_app_version_name` `get-value` [`<command_options>`] \
# `<output_mode>` `<scoped_var_scope_mode>`
# `termux_core__bash__termux_apps_info_app_version_name` `unset-value` \
# `<scoped_var_scope_mode>`
##
termux_core__bash__termux_apps_info_app_version_name() {

local return_value

local command_type="${1:-}"
[ $# -gt 0 ] && shift 1

if [ "$command_type" = "get-value" ]; then
local opt; local opt_arg; local OPTARG=""; local OPTIND=1;

local extended_validator='r+=^(()|((googleplay\.)?[0-9].*))$'
local skip_sourcing_option="--skip-sourcing-if-cur-app-var"

if [ $# -eq 0 ]; then
echo "No arguments passed for the 'get-value' command. \
The 'termux_core__bash__termux_apps_info_app_version_name' function expects 2 arguments." 1>&2
return 64 # EX__USAGE
fi

while getopts ":-:" opt; do
opt_arg="${OPTARG:-}"
case "${opt}" in
-)
case "${OPTARG}" in *?=*) opt_arg="${OPTARG#*=}";; *) opt_arg="";; esac
case "${OPTARG}" in
extended-validator=?*)
extended_validator="$opt_arg"
;;
extended-validator | extended-validator=)
echo "No argument set for arg option '--${OPTARG%=*}'." 1>&2
return 64 # EX__USAGE
;;
skip-sourcing)
skip_sourcing_option="--skip-sourcing"
;;
skip-sourcing=*)
echo "Arguments not allowed for flag option '--${OPTARG%=*}': \`--${OPTARG:-}\`." 1>&2
return 64 # EX__USAGE
;;
'')
break # End of options `--`.
;;
*)
echo "Unknown option: '--${OPTARG:-}'." 1>&2
return 64 # EX__USAGE
;;
esac
;;
:)
echo "No argument passed for arg option '-$OPTARG'." 1>&2
return 64 # EX__USAGE
;;
\?)
echo "Unknown option${OPTARG:+": '-${OPTARG:-}'"}." 1>&2
return 64 # EX__USAGE
;;
esac
done
shift $((OPTIND - 1)) # Remove already processed arguments from arguments array.

if [ $# -lt 2 ]; then
echo "Invalid argument count $# for the 'get-value' command. \
The 'termux_core__bash__termux_apps_info_app_version_name' function expects 2 arguments." 1>&2
printf 'Arguments: %s\n' "$*" 1>&2
return 64 # EX__USAGE
fi

local output_mode="${1:-}"
local scoped_var_scope_mode="${2:-}"
elif [ "$command_type" = "unset-value" ]; then
local scoped_var_scope_mode="${1:-}"
else
echo "The command '$command_type' passed to 'termux_core__bash__termux_apps_info_app_version_name' is not valid." 1>&2
return 64 # EX__USAGE
fi


if [ "$command_type" = "get-value" ]; then
local __app_version_name=""

if [ "$output_mode" != ">" ] && [ "$output_mode" != "-" ]; then
# A valid environment variable name (like `TERMUX__VAR`) or a bash array variable (like `TERMUX__ARRAY[0]`).
local valid_bash_variable_name_regex='^[a-zA-Z_][a-zA-Z0-9_]*(\[[0-9]+\])?$' # ' single quote for linter error false positive against `IFS=$'\n'`

# If `output_mode` is not a valid environment variable name.
if [[ ! "$output_mode" =~ $valid_bash_variable_name_regex ]]; then
echo "The output_mode '$output_mode' argument passed to \
'termux_core__bash__termux_apps_info_app_version_name' is not a valid environment variable name, or equal to \`>\` or \`-\`." 1>&2
return 64 # EX__USAGE
fi
fi


return_value=0
termux_core__bash__termux_apps_info_env_variable get-value \
"$skip_sourcing_option" __app_version_name \
"$scoped_var_scope_mode" "APP_VERSION_NAME" "$extended_validator" || return_value=$?


# If getting version name of the Termux app but failed to get it,
# likely due to Termux app scoped `APP_VERSION_NAME` environment
# variable not being exported if running in Termux app version
# `<= 0.119.0` (as `TERMUX_ENV__S_ROOT` environment variable is
# not exported), then fallback to reading the old/deprecated
# `TERMUX_VERSION` environment variable.
# This may give outdated/wrong values if running in a plugin
# app like Termux:Float app and Termux app got updated in the
# background, as `TERMUX_VERSION` would be set to the version
# at the time the Termux:Float shell was started, and not the
# updated version.
if [ $return_value -eq 0 ] && [ -z "$__app_version_name" ] && \
{ [ "$scoped_var_scope_mode" = cn="termux-app" ] || [ "$scoped_var_scope_mode" = ss="APP__" ]; } && \
[ -z "${TERMUX_ENV__S_ROOT:-}" ]; then
return_value=0
termux_core__bash__termux_scoped_env_variable get-value \
__app_version_name "" "" "$extended_validator" "${TERMUX_VERSION:-}" || return_value=$?
fi


# If either above commands failed.
if [ $return_value -ne 0 ]; then
# If a valid value not found.
if [ $return_value -eq 81 ]; then # C_EX__NOT_FOUND
# Set output variable in `output_mode` to an empty string
# since it may already be set, as callers may try to use
# that wrong value without checking the exit code.
# We unset after reading the values, otherwise if
# `var_to_get_name` generated in
# `termux_core__bash__termux_scoped_env_variable()` is
# equal to output variable in `output_mode` passed to this
# function, then `var_to_get_name` would get unset before
# its read.
if [ "$output_mode" != ">" ] && [ "$output_mode" != "-" ]; then
printf -v "$output_mode" "%s" "" || return $?
fi
fi
return $return_value
fi


# If a valid value found.
if [ "$output_mode" = ">" ]; then
printf "%s" "$__app_version_name"
return $?
elif [ "$output_mode" != "-" ]; then
printf -v "$output_mode" "%s" "$__app_version_name"
return $?
else
return 0
fi
elif [ "$command_type" = "unset-value" ]; then
termux_core__bash__termux_scoped_env_variable unset-value \
"$scoped_var_scope_mode" "APP_VERSION_NAME" || return $?

if [ "$scoped_var_scope_mode" = cn="termux-app" ] || \
[ "$scoped_var_scope_mode" = ss="APP__" ]; then
unset TERMUX_VERSION
fi

return 0
fi

}

##### @TERMUX_CORE__BASH__TERMUX_APPS_INFO_APP_VERSION_NAME@ replaced at build time. (END) #####
Loading