From 9c5b634c5f64e7fd708924c211d7d21b85d370ef Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Wed, 9 Sep 2020 02:46:46 +0800 Subject: [PATCH] Propose a better way to fetch latest source url. It is reasonable to pass headers like `User-Agent`, see https://github.com/v2ray/v2ray-core/issues/2373. Also I don't think it's a good idea to fetch source code url from webpages like `https://www.boost.org/users/download/`, they are definitely not designed for machine-readable. And we should prefer to fetch url from REST API response from GitHub. --- qbittorrent-nox-static-glibc.sh | 34 +++++++++++++++++++-------------- qbittorrent-nox-static-musl.sh | 34 +++++++++++++++++++-------------- qbittorrent-nox-staticish.sh | 34 +++++++++++++++++++-------------- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/qbittorrent-nox-static-glibc.sh b/qbittorrent-nox-static-glibc.sh index 261f7c23..a888d5d9 100644 --- a/qbittorrent-nox-static-glibc.sh +++ b/qbittorrent-nox-static-glibc.sh @@ -234,27 +234,33 @@ export gawk_url="http://ftp.gnu.org/gnu/gawk/$(curl -sNL http://ftp.gnu.org/gnu/ # export glibc_url="http://ftp.gnu.org/gnu/libc/$(curl -sNL http://ftp.gnu.org/gnu/libc/ | grep -Eo 'glibc-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' | sort -V | tail -1)" export glibc_url="http://ftp.gnu.org/gnu/libc/glibc-2.31.tar.gz" # -export zlib_github_tag="$(curl -sNL https://github.com/madler/zlib/releases | grep -Eom1 'v1.2.([0-9]{1,2})')" -export zlib_url="https://github.com/madler/zlib/archive/$zlib_github_tag.tar.gz" +export zlib_github_tag="$(curl ${PROXY} -H "Accept: application/json" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0" -sSNL \ + https://api.github.com/repos/madler/zlib/tags?per_page=32 | grep 'name' | cut -d\" -f4 | grep -Em1 '1\.2\.')" +export zlib_url='https://github.com/madler/zlib/archive/'"$zlib_github_tag"'.tar.gz' # -export icu_url="$(curl -sNL https://api.github.com/repos/unicode-org/icu/releases/latest | grep -Eom1 'ht(.*)icu4c(.*)-src.tgz')" +export icu_url="$(curl ${PROXY} -H "Accept: application/json" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0" -sSNL \ + https://api.github.com/repos/unicode-org/icu/releases/latest | grep 'browser_download_url' | cut -d\" -f4 | grep -Em1 'icu4c(.+)-src.tgz')" # -export openssl_github_tag="$(curl -sNL https://github.com/openssl/openssl/releases | grep -Eom1 'OpenSSL_1_1_([0-9][a-z])')" -export openssl_url="https://github.com/openssl/openssl/archive/$openssl_github_tag.tar.gz" +export openssl_github_tag="$(curl ${PROXY} -H "Accept: application/json" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0" -sSNL \ + https://api.github.com/repos/openssl/openssl/tags?per_page=32 | grep 'name' | cut -d\" -f4 | grep -Em1 'OpenSSL_1_1_[0-9][a-z]')" +export openssl_url='https://github.com/openssl/openssl/archive/'"$openssl_github_tag"'.tar.gz' # -export boost_version="$(curl -sNL https://www.boost.org/users/download/ | sed -rn 's#(.*)e">Version (.*\.[0-9]{1,2})Version (.*\.[0-9]{1,2})Version (.*\.[0-9]{1,2})