Skip to content

Commit

Permalink
cli: Add new method for getting package information
Browse files Browse the repository at this point in the history
packages.debian.org has been down a lot lately, so builds could not finish since the build system wants to find out the package name and version for `base-files`.
Use `Packages.gz` from the mirrors as an alternative method to search for this information.
  • Loading branch information
ColorfulRhino committed Jun 19, 2024
1 parent b2aea3b commit 5a29f91
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/functions/general/apt-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,25 @@ function apt_find_upstream_package_version_and_download_url() {
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"
return 1
display_alert "Could not find package filename for '${sought_package_name}' in '${package_info_download_urls[*]}'" "Trying alternative method to get ${sought_package_name}" "warn"
# Try alternative method since packages.debian.org is down often
# Use -N with wget so it always downloads the latest file, overwriting the local one if it exists
run_host_command_logged wget --no-verbose -N https://${mirror_with_slash}/dists/${RELEASE}/main/binary-${ARCH}/Packages.gz
run_host_command_logged gzip -d -f Packages.gz
declare package_filename_from_packages
package_filename_from_packages="$(grep -A 25 "Package: ${sought_package_name}" Packages | grep "Filename:" | awk '{print $2}')" # Format example: pool/main/b/base-files/base-files_13.3_arm64.deb

found_package_down_url=="http://${mirror_with_slash}${package_filename_from_packages}"
found_package_filename="$(echo $found_package_down_url | awk -F'/' '{print $NF}')"

# Test again, same as if statement above
if [[ "${found_package_filename}" == "${sought_package_name}_"* ]]; then
display_alert "Found upstream base-files package filename" "${found_package_filename}" "info"
run_host_command_logged rm -f Packages
else
display_alert "Could not find package filename for '${sought_package_name}' in '${found_package_down_url}'" "looking for ${sought_package_name} with the alternative method" "warn"
return 1
fi
fi

# Now we have the package name, lets parse out the version.
Expand Down

0 comments on commit 5a29f91

Please sign in to comment.