From c7e7ede002d57f09494b7e7337fb50919004e4cb Mon Sep 17 00:00:00 2001 From: amazingfate Date: Thu, 14 Nov 2024 17:06:40 +0800 Subject: [PATCH 1/2] apt-utils.sh: get base-files package version from GHA --- lib/functions/general/apt-utils.sh | 45 +++++++++++++----------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/lib/functions/general/apt-utils.sh b/lib/functions/general/apt-utils.sh index a5c8123ca578..be397f57b117 100644 --- a/lib/functions/general/apt-utils.sh +++ b/lib/functions/general/apt-utils.sh @@ -9,7 +9,6 @@ function apt_find_upstream_package_version_and_download_url() { declare sought_package_name="${1}" - declare -a package_info_download_urls=() declare first_letter_of_sought_package_name="${sought_package_name:0:1}" declare mirror_with_slash="undetermined/" @@ -17,15 +16,15 @@ function apt_find_upstream_package_version_and_download_url() { Ubuntu) # Only LTS releases have an "-updates" repo that is worth looking into if [[ "${RELEASE}" == "focal" || "${RELEASE}" == "jammy" ]]; then # @TODO: release info information, is_ubuntu_release_lts() or similar - package_info_download_urls+=("https://packages.ubuntu.com/${RELEASE}-updates/${ARCH}/${sought_package_name}/download") + package_download_release=${RELEASE}-updates else - package_info_download_urls+=("https://packages.ubuntu.com/${RELEASE}/${ARCH}/${sought_package_name}/download") + package_download_release=${RELEASE} fi mirror_with_slash="${UBUNTU_MIRROR}" ;; Debian) - package_info_download_urls+=("https://packages.debian.org/${RELEASE}/${ARCH}/${sought_package_name}/download") + package_download_release=${RELEASE} mirror_with_slash="${DEBIAN_MIRROR}" ;; @@ -41,35 +40,29 @@ function apt_find_upstream_package_version_and_download_url() { declare base_down_url="http://${mirror_with_slash}pool/main/${first_letter_of_sought_package_name}/${sought_package_name}" - declare index package_info_download_url - # loop over the package_info_download_urls with index and value - for index in "${!package_info_download_urls[@]}"; do - package_info_download_url="${package_info_download_urls[$index]}" - display_alert "Testing URL" "${package_info_download_url}" "debug" - - declare package_info_download_url_file - package_info_download_url_file="$(mktemp)" - curl --silent --show-error --max-time 10 "${package_info_download_url}" > "${package_info_download_url_file}" || true # don't fail - declare package_info_download_url_file_package_name # grep the file for the package name. parse "name" - package_info_download_url_file_package_name="$(grep -oP '(?<=)[^<]+' "${package_info_download_url_file}" | grep "^${sought_package_name}_" | head -n 1)" - rm -f "${package_info_download_url_file}" - - display_alert "Package name parsed" "${package_info_download_url_file_package_name}" "debug" - if [[ "${package_info_download_url_file_package_name}" == "${sought_package_name}_"* ]]; then - found_package_filename="${package_info_download_url_file_package_name}" - found_package_down_url="${base_down_url}/${found_package_filename}" - display_alert "Found package filename" "${found_package_filename} in url ${package_info_download_url}" "debug" - break - fi - done + # get json with latest pacakge info generated by GHA + case "${GITHUB_MIRROR}" in + "ghproxy") + package_info_download_url="https://ghp.ci/https://raw.githubusercontent.com/amazingfate/deb-files-parser/refs/heads/master/${sought_package_name}.json" + ;; + *) + package_info_download_url="https://raw.githubusercontent.com/amazingfate/deb-files-parser/refs/heads/master/${sought_package_name}.json" + ;; + esac + package_info_download_url_file="$(mktemp)" + curl --silent --show-error --max-time 10 $package_info_download_url -o $package_info_download_url_file + found_package_filename=$(jq -r .[\"${package_download_release}\"].${ARCH} $package_info_download_url_file) if [[ "${found_package_filename}" == "${sought_package_name}_"* ]]; then display_alert "Found upstream base-files package filename" "${found_package_filename}" "info" else - display_alert "Could not find package filename for '${sought_package_name}' in '${package_info_download_urls[*]}'" "looking for ${sought_package_name}" "warn" + display_alert "Could not find package filename for '${sought_package_name}' in distro repo" "looking for ${sought_package_name}, found_package_filename is ${found_package_filename}" "warn" return 1 fi + found_package_down_url="${base_down_url}/${found_package_filename}" + display_alert "Found package filename" "${found_package_filename} in url ${found_package_down_url}" "debug" + # Now we have the package name, lets parse out the version. found_package_version="$(echo "${found_package_filename}" | grep -oP '(?<=_)[^_]+(?=_)')" display_alert "Found base-files upstream package version" "${found_package_version}" "info" From 583abf1a118114461e7a86a26dcccfce78f6c473 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Thu, 14 Nov 2024 18:06:42 +0100 Subject: [PATCH 2/2] Switch to action artifacts that was moved to .org --- lib/functions/general/apt-utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/functions/general/apt-utils.sh b/lib/functions/general/apt-utils.sh index be397f57b117..c0e1bc715a77 100644 --- a/lib/functions/general/apt-utils.sh +++ b/lib/functions/general/apt-utils.sh @@ -43,10 +43,10 @@ function apt_find_upstream_package_version_and_download_url() { # get json with latest pacakge info generated by GHA case "${GITHUB_MIRROR}" in "ghproxy") - package_info_download_url="https://ghp.ci/https://raw.githubusercontent.com/amazingfate/deb-files-parser/refs/heads/master/${sought_package_name}.json" + package_info_download_url="https://ghp.ci/https://raw.githubusercontent.com/armbian/armbian.github.io/refs/heads/data/data/${sought_package_name}.json" ;; *) - package_info_download_url="https://raw.githubusercontent.com/amazingfate/deb-files-parser/refs/heads/master/${sought_package_name}.json" + package_info_download_url="https://github.armbian.com/${sought_package_name}.json" ;; esac package_info_download_url_file="$(mktemp)"