@@ -66,6 +66,11 @@ assert_unmodified_apt_config() {
66
66
fi
67
67
}
68
68
69
+ # Check whether apt-helper is available
70
+ exists_apt_helper () {
71
+ test -x /usr/lib/apt/apt-helper
72
+ }
73
+
69
74
# Check whether python3 and urllib.request are available
70
75
exists_python3_urllib () {
71
76
python3 -c ' import urllib.request' > /dev/null 2>&1
@@ -432,6 +437,27 @@ do_fetch() {
432
437
return 0
433
438
}
434
439
440
+ do_apt_helper () {
441
+ info " Trying apt-helper..."
442
+ run_cmd " /usr/lib/apt/apt-helper download-file '$1 ' '$2 '" 2> $tmp_stderr
443
+ rc=$?
444
+
445
+ # check for 404
446
+ grep " E: Failed to fetch .* 404 " $tmp_stderr 2>&1 > /dev/null
447
+ if test $? -eq 0; then
448
+ critical " ERROR 404"
449
+ unable_to_retrieve_package
450
+ fi
451
+
452
+ # check for bad return status or empty output
453
+ if test $rc -ne 0 && test ! -s " $2 " ; then
454
+ capture_tmp_stderr " apthelper"
455
+ return 1
456
+ fi
457
+
458
+ return 0
459
+ }
460
+
435
461
do_python3_urllib () {
436
462
info " Trying python3 (urllib.request)..."
437
463
run_cmd " python3 -c 'import urllib.request ; urllib.request.urlretrieve(\" $1 \" , \" $2 \" )'" 2> $tmp_stderr
@@ -525,7 +551,11 @@ do_download() {
525
551
do_python3_urllib $1 $2 && return 0
526
552
fi
527
553
528
- critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
554
+ if exists_apt_helper; then
555
+ do_apt_helper $1 $2 && return 0
556
+ fi
557
+
558
+ critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3/apt-helper is found"
529
559
unable_to_retrieve_package
530
560
}
531
561
0 commit comments