这是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
30 changes: 12 additions & 18 deletions packages/fd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,31 @@ 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
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"
}
13 changes: 7 additions & 6 deletions packages/predict/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -12,24 +12,25 @@ 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/
cp -r ./vocalizer "$TERMUX_PREFIX"/opt/predict/

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
}
82 changes: 59 additions & 23 deletions scripts/lint-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ check_package_license() {
esac
done

if ! "$license_ok"; then
if [[ "$license_ok" == 'false' ]]; then
return 1
fi

Expand Down Expand Up @@ -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
Expand All @@ -139,7 +159,7 @@ lint_package() {
break
}
done
(( ! ${#in_dir} )) && {
(( ! ${#in_dir} )) && {
echo "FAIL - '$package_script' is not a directory"
return 1
}
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -349,7 +384,7 @@ lint_package() {
done
unset url

if "$urls_ok"; then
if [[ "$urls_ok" == 'true' ]]; then
echo "PASS"
fi
unset urls_ok
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -544,7 +579,7 @@ lint_package() {
fi
fi

if "$pkg_lint_error"; then
if [[ "$pkg_lint_error" == 'true' ]]; then
exit 1
fi
exit 0
Expand All @@ -558,7 +593,6 @@ lint_package() {
}

linter_main() {
local package_counter=0
local problems_found=false
local package_script

Expand All @@ -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 "================================================================"
Expand All @@ -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