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() {
66
66
fi
67
67
}
68
68
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
+
69
74
# Check whether perl and LWP::Simple module are installed
70
75
exists_perl_lwp () {
71
76
if perl -e ' use LWP::Simple;' > /dev/null 2>&1 ; then
@@ -427,6 +432,25 @@ do_fetch() {
427
432
return 0
428
433
}
429
434
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
+
430
454
# do_perl_lwp URL FILENAME
431
455
do_perl_lwp () {
432
456
info " Trying perl (LWP::Simple)..."
@@ -497,7 +521,11 @@ do_download() {
497
521
do_perl_ff $1 $2 && return 0
498
522
fi
499
523
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"
501
529
unable_to_retrieve_package
502
530
}
503
531
You can’t perform that action at this time.
0 commit comments