这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/package_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.TERMUXBOT2_TOKEN }}
BUILD_PACKAGES: "true"
TERMUX_DOCKER__CONTAINER_EXEC_COMMAND__PRE_CHECK_IF_WILL_BUILD_PACKAGES: "true"
CREATE_ISSUE: "true"
GIT_COMMIT_PACKAGES: "true"
GIT_PUSH_PACKAGES: "true"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ jobs:
if: ${{ steps.build-info.outputs.skip-building != 'true' }}
env:
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
TERMUX_DOCKER__CONTAINER_EXEC_COMMAND__PRE_CHECK_IF_WILL_BUILD_PACKAGES: "true"
Copy link
Member Author

@robertkirkman robertkirkman Jul 5, 2025

Choose a reason for hiding this comment

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

I assume that this would be the appropriate place to enable this in CI.

I have tested this on my own GitHub Actions in this run, on the ecl package, which has TERMUX_PKG_EXCLUDED_ARCHES="i686, x86_64":

https://github.com/robertkirkman/termux-packages/actions/runs/16082984132/job/45390315328

It is working. What happens in practice is, for the i686 and x86_64 jobs, the "build" workflow step very quickly completes without building anything, but showing a green success mark, not red failed or gray skipped, and an artifact does upload. However, what is in the artifact is just nothing except a .placeholder file, which is empty, and a built_termux-main_packages.txt file, which contains the list of packages that would have been built if the build were not skipped, in this test "ecl".

@twaik do you think this is proper behavior to happen, or should it be adjusted to be different in any way?

run: |
declare -a packages=()
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
Expand Down
87 changes: 87 additions & 0 deletions scripts/bin/build-package-dry-run-simulation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

set -e -u

# This script is in '$TERMUX_SCRIPTDIR/scripts/bin/'.
TERMUX_SCRIPTDIR=$(cd "$(realpath "$(dirname "$0")")"; cd ../..; pwd)
DRY_RUN_SCRIPT_NAME=$(basename "$0")
BUILDSCRIPT_NAME="build-package.sh"
TERMUX_ARCH="aarch64"
TERMUX_DEBUG_BUILD="false"
TERMUX_PACKAGES_DIRECTORIES="
packages
root-packages
x11-packages
"

# Please keep synchronized with the logic of lines 468-547 of 'build-package.sh'.
declare -a PACKAGE_LIST=()
while (($# >= 1)); do
case "$1" in
*"/$BUILDSCRIPT_NAME") ;;
-a)
if [ $# -lt 2 ]; then
echo "$DRY_RUN_SCRIPT_NAME: Option '-a' requires an argument"
exit 1
fi
shift 1
if [ -z "$1" ]; then
echo "$DRY_RUN_SCRIPT_NAME: Argument to '-a' should not be empty."
exit 1
fi
TERMUX_ARCH="$1"
;;
-d) TERMUX_DEBUG_BUILD="true" ;;
-*) ;;
*) PACKAGE_LIST+=("$1") ;;
esac
shift 1
done

# Please keep synchronized with the logic of lines 592-656 of 'build-package.sh'.
for ((i=0; i<${#PACKAGE_LIST[@]}; i++)); do
TERMUX_PKG_NAME=$(basename "${PACKAGE_LIST[i]}")
TERMUX_PKG_BUILDER_DIR=
for package_directory in $TERMUX_PACKAGES_DIRECTORIES; do
if [ -d "${TERMUX_SCRIPTDIR}/${package_directory}/${TERMUX_PKG_NAME}" ]; then
TERMUX_PKG_BUILDER_DIR="${TERMUX_SCRIPTDIR}/$package_directory/$TERMUX_PKG_NAME"
break
fi
done
if [ -z "${TERMUX_PKG_BUILDER_DIR}" ]; then
echo "$DRY_RUN_SCRIPT_NAME: No package $TERMUX_PKG_NAME found in any of the enabled repositories. Are you trying to set up a custom repository?"
exit 1
fi
TERMUX_PKG_BUILDER_SCRIPT="$TERMUX_PKG_BUILDER_DIR/build.sh"

# Please keep synchronized with the logic of lines 2-50 of 'scripts/build/termux_step_start_build.sh'.
if [ "${TERMUX_ARCH}" != "all" ] && \
grep -qE "^TERMUX_PKG_EXCLUDED_ARCHES=.*${TERMUX_ARCH}" "$TERMUX_PKG_BUILDER_SCRIPT"; then
echo "$DRY_RUN_SCRIPT_NAME: Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH"
continue
fi

if [ "${TERMUX_DEBUG_BUILD}" = "true" ] && \
grep -qE "^TERMUX_PKG_HAS_DEBUG=.*false" "$TERMUX_PKG_BUILDER_SCRIPT"; then
echo "$DRY_RUN_SCRIPT_NAME: Skipping building debug build for $TERMUX_PKG_NAME"
continue
fi

echo "$DRY_RUN_SCRIPT_NAME: Ending dry run simulation ($BUILDSCRIPT_NAME would have continued building $TERMUX_PKG_NAME)"
exit 0
done

if [ ${#PACKAGE_LIST[@]} -gt 0 ]; then
# At least one package name was parsed, but none of them reached "exit 0",
# so exit with return value 85 (EX_C__NOOP) to indicate that no packages would have been built.
echo "$DRY_RUN_SCRIPT_NAME: Ending dry run simulation ($BUILDSCRIPT_NAME would not have built any packages)"
exit 85 # EX_C__NOOP
fi

# If this point is reached, assume that a combination of arguments
# that is either invalid or is not implemented in this script
# has been used, and that the real 'build-package.sh'
# needs to be run so that its own parser can interpret the arguments
# and display the appropriate message.
echo "$DRY_RUN_SCRIPT_NAME: Ending dry run simulation (unknown arguments, pass to the real $BUILDSCRIPT_NAME for more information)"
exit 0
28 changes: 28 additions & 0 deletions scripts/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@ set -e -u

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

BUILDSCRIPT_NAME="build-package.sh"

if [ "${1:-}" = "-p" ] || [ "${1:-}" = "--pre-check-if-will-build-packages" ]; then
shift 1
TERMUX_DOCKER__CONTAINER_EXEC_COMMAND__PRE_CHECK_IF_WILL_BUILD_PACKAGES="true"
fi

# If 'build-package-dry-run-simulation.sh' does not return 85 (EX_C__NOOP), or if
# $1 (the first argument passed to this script which runs docker) does not contain
# $BUILDSCRIPT_NAME, this condition will evaluate false and this script which
# runs docker will continue.
if [ "${TERMUX_DOCKER__CONTAINER_EXEC_COMMAND__PRE_CHECK_IF_WILL_BUILD_PACKAGES:-}" = "true" ]; then
case "${1:-}" in
*"/$BUILDSCRIPT_NAME")
RETURN_VALUE=0
OUTPUT="$("$TERMUX_SCRIPTDIR/scripts/bin/build-package-dry-run-simulation.sh" "$@" 2>&1)" || RETURN_VALUE=$?
if [ $RETURN_VALUE -ne 0 ]; then
echo "$OUTPUT" 1>&2
if [ $RETURN_VALUE -eq 85 ]; then # EX_C__NOOP
echo "$0: Exiting since '$BUILDSCRIPT_NAME' would not have built any packages"
exit 0
fi
exit $RETURN_VALUE
fi
;;
esac
fi

CONTAINER_HOME_DIR=/home/builder
UNAME=$(uname)
if [ "$UNAME" = Darwin ]; then
Expand Down