From 346216843adca41f6ca7559905c8fb9280777fc4 Mon Sep 17 00:00:00 2001 From: TomIO Date: Tue, 3 Jun 2025 23:21:04 +0200 Subject: [PATCH 1/3] enhance(main/fd): generate completions at build time - Also fix a linter error (trailing whitespace, line 29) - Also ship `elvish` completions - and generate `zsh` completions instead of copying them --- packages/fd/build.sh | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/packages/fd/build.sh b/packages/fd/build.sh index 58688e1bff6f69b..e4d1dac9926eac5 100644 --- a/packages/fd/build.sh +++ b/packages/fd/build.sh @@ -4,6 +4,7 @@ TERMUX_PKG_LICENSE="Apache-2.0,MIT" TERMUX_PKG_LICENSE_FILE="LICENSE-APACHE,LICENSE-MIT" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="10.2.0" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://github.com/sharkdp/fd/archive/v${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=73329fe24c53f0ca47cd0939256ca5c4644742cb7c14cf4114c8c9871336d342 TERMUX_PKG_AUTO_UPDATE=true @@ -11,30 +12,23 @@ TERMUX_PKG_BUILD_IN_SRC=true termux_step_make() { termux_setup_rust - cargo build --jobs $TERMUX_PKG_MAKE_PROCESSES --target $CARGO_TARGET_NAME --release + cargo build --jobs "$TERMUX_PKG_MAKE_PROCESSES" --target "$CARGO_TARGET_NAME" --release } termux_step_make_install() { - install -Dm700 -t $TERMUX_PREFIX/bin target/${CARGO_TARGET_NAME}/release/fd + install -Dm700 -t "$TERMUX_PREFIX/bin" "target/${CARGO_TARGET_NAME}/release/fd" - install -Dm644 /dev/null "${TERMUX_PREFIX}"/share/bash-completion/completions/"${TERMUX_PKG_NAME}".bash - install -Dm644 /dev/null "${TERMUX_PREFIX}"/share/zsh/site-functions/_"${TERMUX_PKG_NAME}" - install -Dm644 /dev/null "${TERMUX_PREFIX}"/share/fish/vendor_completions.d/"${TERMUX_PKG_NAME}".fish -} - -termux_step_post_make_install() { # Manpages. install -Dm600 doc/"${TERMUX_PKG_NAME}".1 \ "${TERMUX_PREFIX}"/share/man/man1/"${TERMUX_PKG_NAME}".1 - - install -Dm600 contrib/completion/_"${TERMUX_PKG_NAME}" \ - "${TERMUX_PREFIX}"/share/zsh/site-functions/_"${TERMUX_PKG_NAME}" -} -termux_step_create_debscripts() { - cat <<- EOF > ./postinst - #!${TERMUX_PREFIX}/bin/sh - fd --gen-completions bash > ${TERMUX_PREFIX}/share/bash-completion/completions/fd.bash - fd --gen-completions fish > ${TERMUX_PREFIX}/share/fish/vendor_completions.d/fd.fish - EOF + # Shell completions + mkdir -p "${TERMUX_PREFIX}/share/zsh/site-functions" + mkdir -p "${TERMUX_PREFIX}/share/bash-completion/completions" + mkdir -p "${TERMUX_PREFIX}/share/fish/vendor_completions.d" + mkdir -p "${TERMUX_PREFIX}/share/elvish/lib" + cargo run -- --gen-completions zsh > "${TERMUX_PREFIX}/share/zsh/site-functions/_${TERMUX_PKG_NAME}" + cargo run -- --gen-completions bash > "${TERMUX_PREFIX}/share/bash-completion/completions/${TERMUX_PKG_NAME}" + cargo run -- --gen-completions fish > "${TERMUX_PREFIX}/share/fish/vendor_completions.d/${TERMUX_PKG_NAME}.fish" + cargo run -- --gen-completions elvish > "${TERMUX_PREFIX}/share/elvish/lib/${TERMUX_PKG_NAME}.elv" } From e3eba9dcef94dafa9fb7d665c06fb7e3ba5ce8e0 Mon Sep 17 00:00:00 2001 From: TomIO Date: Tue, 3 Jun 2025 23:25:32 +0200 Subject: [PATCH 2/3] chore(main/predict): linter fix - Trailing whitespace on line 25 - and minor build script cleanup --- packages/predict/build.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/predict/build.sh b/packages/predict/build.sh index fe48e3e9c50140b..14cb6df8a700f25 100644 --- a/packages/predict/build.sh +++ b/packages/predict/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="A Satellite Tracking/Orbital Prediction Program" TERMUX_PKG_LICENSE="GPL-2.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION=2.3.1 -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 TERMUX_PKG_SRCURL=https://www.qsl.net/kd2bd/predict-${TERMUX_PKG_VERSION}-termux.tar.gz TERMUX_PKG_SHA256=6eecccb21117e6ae57941659ac5d1d5f8cf99103ec8448e4fd8c076620bbd77b TERMUX_PKG_DEPENDS="ncurses, ncurses-ui-libs,play-audio,wget" @@ -12,17 +12,18 @@ TERMUX_PKG_BUILD_IN_SRC=true TERMUX_PKG_AUTO_UPDATE=true termux_step_pre_configure() { - rm ${TERMUX_PKG_SRCDIR}/configure + rm "${TERMUX_PKG_SRCDIR}/configure" } +# shellcheck disable=SC2086 # We actually want word splitting on those variables termux_step_make() { echo "char *predictpath={\"$TERMUX_PREFIX/opt/predict/\"}, soundcard=1, *version={\"$(cat .version)\"};" > predict.h $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wall -Wno-deprecated-non-prototype predict.c -lm -lncurses -o predict } termux_step_make_install() { - mkdir -p $TERMUX_PREFIX/opt/predict - + mkdir -p "$TERMUX_PREFIX"/opt/predict + install -Dm700 predict "$TERMUX_PREFIX"/opt/predict/predict install -Dm700 kepupdate "$TERMUX_PREFIX"/opt/predict/kepupdate cp -r ./default "$TERMUX_PREFIX"/opt/predict/ @@ -30,6 +31,6 @@ termux_step_make_install() { gzip -c "$PWD"/docs/man/predict.1 > "$TERMUX_PREFIX"/share/man/man1/predict.1.gz - ln -sfr "$TERMUX_PREFIX"/opt/predict/predict $TERMUX_PREFIX/bin/predict - ln -sfr "$TERMUX_PREFIX"/opt/predict/kepupdate $TERMUX_PREFIX/bin/kepupdate + ln -sfr "$TERMUX_PREFIX"/opt/predict/predict "$TERMUX_PREFIX"/bin/predict + ln -sfr "$TERMUX_PREFIX"/opt/predict/kepupdate "$TERMUX_PREFIX"/bin/kepupdate } From 22b212c8771e52a0d92f3c79d3b5e80f940f2299 Mon Sep 17 00:00:00 2001 From: TomIO Date: Tue, 3 Jun 2025 20:41:04 +0200 Subject: [PATCH 3/3] enhance(scripts/lint-packages): ensure version changes - also don't reset package count between repo channels - don't use `$var` condition values as a command - clean up various shellcheck warnings --- scripts/lint-packages.sh | 82 +++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 23 deletions(-) diff --git a/scripts/lint-packages.sh b/scripts/lint-packages.sh index 21210d9425f7b4f..49a21edf33fb227 100755 --- a/scripts/lint-packages.sh +++ b/scripts/lint-packages.sh @@ -46,7 +46,7 @@ check_package_license() { esac done - if ! "$license_ok"; then + if [[ "$license_ok" == 'false' ]]; then return 1 fi @@ -119,6 +119,26 @@ check_indentation() { return 0 } +# Check the latest commit that modified `$package` +# It must either: +# - Modify TERMUX_PKG_REVISION +# - Modify TERMUX_PKG_VERSION +# - Or specify one of the CI skip tags +check_version_change() { + local base_commit commit_diff package="$1" + base_commit="$(git merge-base --fork-point origin/master)" + commit_diff="$(git log --patch "${base_commit}.." -- "$package")" + + # If the diff is empty there's no commit modifying that package on this branch, which is a PASS. + [[ -z "$commit_diff" ]] && return + + grep -q \ + -e '^+TERMUX_PKG_REVISION=' \ + -e '^+TERMUX_PKG_VERSION=' \ + -e '\[no version check\]' <<< "$commit_diff" \ + || return 1 +} + lint_package() { local package_script local package_name @@ -139,7 +159,7 @@ lint_package() { break } done - (( ! ${#in_dir} )) && { + (( ! ${#in_dir} )) && { echo "FAIL - '$package_script' is not a directory" return 1 } @@ -151,10 +171,10 @@ lint_package() { echo "PASS" check_package_name "$package_name" || return 1 - local subpkg_script - for subpkg_script in $(dirname "$package_script")/*.subpackage.sh; do - test ! -f "$subpkg_script" && continue - local subpkg_name=$(basename "${subpkg_script%.subpackage.sh}") + local subpkg_script subpkg_name + for subpkg_script in "$(dirname "$package_script")"/*.subpackage.sh; do + [[ ! -f "$subpkg_script" ]] && continue + subpkg_name="$(basename "${subpkg_script%.subpackage.sh}")" check_package_name "$subpkg_name" || return 1 done @@ -185,8 +205,8 @@ lint_package() { echo -n "Indentation check: " local script - for script in "$package_script" $(dirname "$package_script")/*.subpackage.sh; do - test ! -f "$script" && continue + for script in "$package_script" "$(dirname "$package_script")"/*.subpackage.sh; do + [[ ! -f "$script" ]] && continue check_indentation "$script" || return 1 done echo "PASS" @@ -211,6 +231,20 @@ lint_package() { return 1 fi echo "PASS" + + echo -n "Version change check: " + if ! check_version_change "$package_script"; then + echo "FAILED" + echo + echo "Version of '$package_name' has not changed." + echo "Either 'TERMUX_PKG_REVISION' or 'TERMUX_PKG_VERSION'" + echo "need to be modified when changing a package build." + echo "Alternatively you can add '[no version check]'." + echo "To the commit message to skip this check." + echo + return 1 + fi + echo "PASS" echo # Fields checking is done in subshell since we will source build.sh. @@ -221,6 +255,7 @@ lint_package() { # Using API 24 here. TERMUX_PKG_API_LEVEL=24 + # shellcheck source=/dev/null . "$package_script" pkg_lint_error=false @@ -349,7 +384,7 @@ lint_package() { done unset url - if "$urls_ok"; then + if [[ "$urls_ok" == 'true' ]]; then echo "PASS" fi unset urls_ok @@ -505,7 +540,7 @@ lint_package() { done <<< "$TERMUX_PKG_RM_AFTER_INSTALL" unset file_path - if "$file_path_ok"; then + if [[ "$file_path_ok" == 'true' ]]; then echo "PASS" fi unset file_path_ok @@ -527,7 +562,7 @@ lint_package() { done <<< "$TERMUX_PKG_CONFFILES" unset file_path - if "$file_path_ok"; then + if [[ "$file_path_ok" == 'true' ]]; then echo "PASS" fi unset file_path_ok @@ -544,7 +579,7 @@ lint_package() { fi fi - if "$pkg_lint_error"; then + if [[ "$pkg_lint_error" == 'true' ]]; then exit 1 fi exit 0 @@ -558,7 +593,6 @@ lint_package() { } linter_main() { - local package_counter=0 local problems_found=false local package_script @@ -568,18 +602,18 @@ linter_main() { break fi - (( package_counter++ )) + : $(( package_counter++ )) done - if "$problems_found"; then + if [[ "$problems_found" == 'true' ]]; then echo "================================================================" echo echo "A problem has been found in '$(realpath --relative-to="$TERMUX_SCRIPTDIR" "$package_script")'." echo "Checked $package_counter packages before the first error was detected." echo echo "================================================================" - - return 1 + unset package_counter + exit 1 fi echo "================================================================" @@ -588,14 +622,16 @@ linter_main() { echo "Everything seems ok." echo echo "================================================================" - - return 0 + return } +package_counter=0 if (( $# )); then - linter_main "$@" || exit 1 + linter_main "$@" + unset package_counter else - for repo_dir in $(jq --raw-output 'del(.pkg_format) | keys | .[]' $TERMUX_SCRIPTDIR/repo.json); do - linter_main $repo_dir/*/build.sh - done || exit 1 + for repo_dir in $(jq --raw-output 'del(.pkg_format) | keys | .[]' "$TERMUX_SCRIPTDIR/repo.json"); do + linter_main "$repo_dir"/*/build.sh + done + unset package_counter fi