Skip to content

Commit 093890b

Browse files
committed
support download with apt-helper
1 parent 15f8033 commit 093890b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tasks/install_shell.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ assert_unmodified_apt_config() {
6666
fi
6767
}
6868

69+
# Check whether apt-helper is available
70+
exists_apt_helper() {
71+
test -x /usr/lib/apt/apt-helper
72+
}
73+
6974
# Check whether python3 and urllib.request are available
7075
exists_python3_urllib() {
7176
python3 -c 'import urllib.request' >/dev/null 2>&1
@@ -432,6 +437,19 @@ do_fetch() {
432437
return 0
433438
}
434439

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+
if test $rc -eq 0 && test -s "$2" ; then
446+
return 0
447+
fi
448+
449+
capture_tmp_stderr "apthelper"
450+
return 1
451+
}
452+
435453
do_python3_urllib() {
436454
info "Trying python3 (urllib.request)..."
437455
run_cmd "python3 -c 'import urllib.request ; urllib.request.urlretrieve(\"$1\", \"$2\")'" 2>$tmp_stderr
@@ -525,7 +543,11 @@ do_download() {
525543
do_python3_urllib $1 $2 && return 0
526544
fi
527545

528-
critical "Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
546+
if exists_apt_helper; then
547+
do_apt_helper $1 $2 && return 0
548+
fi
549+
550+
critical "Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3/apt-helper is found"
529551
unable_to_retrieve_package
530552
}
531553

0 commit comments

Comments
 (0)