From c10113909726c87ad16a22d803b5c71c51d4406e Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 24 Dec 2020 17:00:05 +0200 Subject: [PATCH] termux-tools: pkg: send more info in user-agent string Send termux-tools package version, build-time app package name and installation prefix. Just like with apt. --- packages/termux-tools/build.sh | 9 ++++++--- packages/termux-tools/pkg | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/termux-tools/build.sh b/packages/termux-tools/build.sh index d7093180d..1816ce7a6 100644 --- a/packages/termux-tools/build.sh +++ b/packages/termux-tools/build.sh @@ -36,9 +36,12 @@ termux_step_make_install() { termux-open termux-open-url termux-reload-settings termux-reset \ termux-setup-storage termux-wake-lock termux-wake-unlock termux-change-repo; do install -Dm700 $TERMUX_PKG_BUILDER_DIR/$script $TERMUX_PREFIX/bin/$script - sed -i -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \ - -e "s|@TERMUX_HOME@|${TERMUX_ANDROID_HOME}|g" \ - -e "s|@TERMUX_CACHE_DIR@|${TERMUX_CACHE_DIR}|g" \ + sed -i -e "s%\@TERMUX_APP_PACKAGE\@%${TERMUX_APP_PACKAGE}%g" \ + -e "s%\@TERMUX_BASE_DIR\@%${TERMUX_BASE_DIR}%g" \ + -e "s%\@TERMUX_CACHE_DIR\@%${TERMUX_CACHE_DIR}%g" \ + -e "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" \ + -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \ + -e "s%\@PACKAGE_VERSION\@%${TERMUX_PKG_VERSION}%g" \ $TERMUX_PREFIX/bin/$script done diff --git a/packages/termux-tools/pkg b/packages/termux-tools/pkg index dc9d4dad4..50870090d 100755 --- a/packages/termux-tools/pkg +++ b/packages/termux-tools/pkg @@ -63,9 +63,15 @@ select_mirror() { if [ -n "$(find @TERMUX_CACHE_DIR@/apt/pkgcache.bin -mmin -360 2>/dev/null)" ]; then if [ -n "${current_mirror}" ]; then echo -n "Checking availability of current mirror: " - if timeout 6 curl --connect-timeout 5 --user-agent 'Termux-PKG/1.0 mirror-checker' --head --fail --location "${current_mirror%/}/dists/stable/Release" >/dev/null 2>&1; then - echo "ok" - return + if timeout 6 curl \ + --head \ + --fail \ + --connect-timeout 5 \ + --location \ + --user-agent 'Termux-PKG/1.0 mirror-checker (termux-tools @PACKAGE_VERSION@) Termux (@TERMUX_APP_PACKAGE@; install-prefix:@TERMUX_PREFIX@)' \ + "${current_mirror%/}/dists/stable/Release" >/dev/null 2>&1; then + echo "ok" + return else echo "bad" fi @@ -77,9 +83,15 @@ select_mirror() { local w total_mirror_weight=0 for w in "${!mirrors[@]}"; do echo -n "[*] ${mirrors[$w]}: " - if timeout 6 curl --connect-timeout 5 --user-agent 'Termux-PKG/1.0 mirror-checker' --head --fail --location "${mirrors[$w]%/}/dists/stable/Release" >/dev/null 2>&1; then - echo "ok" - total_mirror_weight=$((total_mirror_weight + w)) + if timeout 6 curl \ + --head \ + --fail \ + --connect-timeout 5 \ + --location \ + --user-agent 'Termux-PKG/1.0 mirror-checker (termux-tools @PACKAGE_VERSION@) Termux (@TERMUX_APP_PACKAGE@; install-prefix:@TERMUX_PREFIX@)' \ + "${mirrors[$w]%/}/dists/stable/Release" >/dev/null 2>&1; then + echo "ok" + total_mirror_weight=$((total_mirror_weight + w)) else echo "bad" unset "mirrors[$w]"