File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ assert_unmodified_apt_config() {
6666 fi
6767}
6868
69+ # Check whether python3 and urllib.request are available
70+ exists_python3_urllib () {
71+ python3 -c ' import urllib.request' > /dev/null 2>&1
72+ }
73+
6974# Check whether perl and LWP::Simple module are installed
7075exists_perl_lwp () {
7176 if perl -e ' use LWP::Simple;' > /dev/null 2>&1 ; then
@@ -427,6 +432,25 @@ do_fetch() {
427432 return 0
428433}
429434
435+ do_python3_urllib () {
436+ info " Trying python3 (urllib.request)..."
437+ run_cmd " python3 -c 'import urllib.request ; urllib.request.urlretrieve(\" $1 \" , \" $2 \" )'" 2> $tmp_stderr
438+ rc=$?
439+
440+ # check for 404
441+ if grep " 404: Not Found" $tmp_stderr 2>&1 > /dev/null ; then
442+ critical " ERROR 404"
443+ unable_to_retrieve_package
444+ fi
445+
446+ if test $rc -eq 0 && test -s " $2 " ; then
447+ return 0
448+ fi
449+
450+ capture_tmp_stderr " perl"
451+ return 1
452+ }
453+
430454# do_perl_lwp URL FILENAME
431455do_perl_lwp () {
432456 info " Trying perl (LWP::Simple)..."
@@ -497,7 +521,11 @@ do_download() {
497521 do_perl_ff $1 $2 && return 0
498522 fi
499523
500- critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch is found"
524+ if exists_python3_urllib; then
525+ do_python3_urllib $1 $2 && return 0
526+ fi
527+
528+ critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
501529 unable_to_retrieve_package
502530}
503531
You can’t perform that action at this time.
0 commit comments