@@ -69,6 +69,11 @@ assert_unmodified_apt_config() {
6969 fi
7070}
7171
72+ # Check whether apt-helper is available
73+ exists_apt_helper () {
74+ test -x /usr/lib/apt/apt-helper
75+ }
76+
7277# Check whether python3 and urllib.request are available
7378exists_python3_urllib () {
7479 python3 -c ' import urllib.request' > /dev/null 2>&1
@@ -430,6 +435,27 @@ do_fetch() {
430435 return 0
431436}
432437
438+ do_apt_helper () {
439+ info " Trying apt-helper..."
440+ run_cmd " /usr/lib/apt/apt-helper download-file '$1 ' '$2 '" 2> $tmp_stderr
441+ rc=$?
442+
443+ # check for 404
444+ grep " E: Failed to fetch .* 404 " $tmp_stderr 2>&1 > /dev/null
445+ if test $? -eq 0; then
446+ critical " ERROR 404"
447+ unable_to_retrieve_package
448+ fi
449+
450+ # check for bad return status or empty output
451+ if test $rc -ne 0 && test ! -s " $2 " ; then
452+ capture_tmp_stderr " apthelper"
453+ return 1
454+ fi
455+
456+ return 0
457+ }
458+
433459do_python3_urllib () {
434460 info " Trying python3 (urllib.request)..."
435461 run_cmd " python3 -c 'import urllib.request ; urllib.request.urlretrieve(\" $1 \" , \" $2 \" )'" 2> $tmp_stderr
@@ -523,7 +549,11 @@ do_download() {
523549 do_python3_urllib $1 $2 && return 0
524550 fi
525551
526- critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
552+ if exists_apt_helper; then
553+ do_apt_helper $1 $2 && return 0
554+ fi
555+
556+ critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3/apt-helper is found"
527557 unable_to_retrieve_package
528558}
529559
0 commit comments