@@ -69,6 +69,11 @@ assert_unmodified_apt_config() {
69
69
fi
70
70
}
71
71
72
+ # Check whether apt-helper is available
73
+ exists_apt_helper () {
74
+ test -x /usr/lib/apt/apt-helper
75
+ }
76
+
72
77
# Check whether python3 and urllib.request are available
73
78
exists_python3_urllib () {
74
79
python3 -c ' import urllib.request' > /dev/null 2>&1
@@ -430,6 +435,27 @@ do_fetch() {
430
435
return 0
431
436
}
432
437
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
+
433
459
do_python3_urllib () {
434
460
info " Trying python3 (urllib.request)..."
435
461
run_cmd " python3 -c 'import urllib.request ; urllib.request.urlretrieve(\" $1 \" , \" $2 \" )'" 2> $tmp_stderr
@@ -523,7 +549,11 @@ do_download() {
523
549
do_python3_urllib $1 $2 && return 0
524
550
fi
525
551
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"
527
557
unable_to_retrieve_package
528
558
}
529
559
0 commit comments