@@ -301,14 +301,25 @@ assert_unmodified_apt_config() {
301
301
fi
302
302
}
303
303
304
+ # Check whether python3 and urllib.request are available
305
+ exists_python3_urllib () {
306
+ python3 -c ' import urllib.request' > /dev/null 2>&1
307
+ }
308
+
304
309
# Check whether perl and LWP::Simple module are installed
305
- exists_perl () {
306
- if perl -e ' use LWP::Simple;' > /dev/null 2>&1
307
- then
310
+ exists_perl_lwp () {
311
+ if perl -e ' use LWP::Simple;' > /dev/null 2>&1 ; then
308
312
return 0
309
- else
310
- return 1
311
313
fi
314
+ return 1
315
+ }
316
+
317
+ # Check whether perl and File::Fetch module are installed
318
+ exists_perl_ff () {
319
+ if perl -e ' use File::Fetch;' > /dev/null 2>&1 ; then
320
+ return 0
321
+ fi
322
+ return 1
312
323
}
313
324
314
325
# Get command line arguments
368
379
# Track to handle puppet5 to puppet6
369
380
if [ -f /opt/puppetlabs/puppet/VERSION ]; then
370
381
installed_version=` cat /opt/puppetlabs/puppet/VERSION`
371
- elif which puppet > /dev/null 2>&1 ; then
382
+ elif type -p puppet > /dev/null; then
372
383
installed_version=` puppet --version`
373
384
else
374
385
installed_version=uninstalled
@@ -656,9 +667,28 @@ do_fetch() {
656
667
return 0
657
668
}
658
669
659
- # do_perl URL FILENAME
660
- do_perl () {
661
- info " Trying perl..."
670
+ do_python3_urllib () {
671
+ info " Trying python3 (urllib.request)..."
672
+ run_cmd " python3 -c 'import urllib.request ; urllib.request.urlretrieve(\" $1 \" , \" $2 \" )'" 2> $tmp_stderr
673
+ rc=$?
674
+
675
+ # check for 404
676
+ if grep " 404: Not Found" $tmp_stderr 2>&1 > /dev/null ; then
677
+ critical " ERROR 404"
678
+ unable_to_retrieve_package
679
+ fi
680
+
681
+ if test $rc -eq 0 && test -s " $2 " ; then
682
+ return 0
683
+ fi
684
+
685
+ capture_tmp_stderr " perl"
686
+ return 1
687
+ }
688
+
689
+ # do_perl_lwp URL FILENAME
690
+ do_perl_lwp () {
691
+ info " Trying perl (LWP::Simple)..."
662
692
run_cmd " perl -e 'use LWP::Simple; getprint(\$ ARGV[0]);' '$1 ' > '$2 ' 2>$tmp_stderr "
663
693
rc=$?
664
694
@@ -669,13 +699,33 @@ do_perl() {
669
699
unable_to_retrieve_package
670
700
fi
671
701
672
- # check for bad return status or empty output
673
- if test $rc -ne 0 || test ! -s " $2 " ; then
674
- capture_tmp_stderr " perl"
675
- return 1
702
+ if test $rc -eq 0 && test -s " $2 " ; then
703
+ return 0
676
704
fi
677
705
678
- return 0
706
+ capture_tmp_stderr " perl"
707
+ return 1
708
+ }
709
+
710
+ # do_perl_ff URL FILENAME
711
+ do_perl_ff () {
712
+ info " Trying perl (File::Fetch)..."
713
+ run_cmd " perl -e 'use File::Fetch; use File::Copy; my \$ ff = File::Fetch->new(uri => \$ ARGV[0]); my \$ outfile = \$ ff->fetch() or die \$ ff->server; copy(\$ outfile, \$ ARGV[1]) or die \" copy failed: \$ !\" ; unlink(\$ outfile) or die \" delete failed: \$ !\" ;' '$1 ' '$2 ' 2>>$tmp_stderr "
714
+ rc=$?
715
+
716
+ # check for 404
717
+ grep " HTTP response: 404" $tmp_stderr 2>&1 > /dev/null
718
+ if test $? -eq 0 ; then
719
+ critical " ERROR 404"
720
+ unable_to_retrieve_package
721
+ fi
722
+
723
+ if test $rc -eq 0 && test -s " $2 " ; then
724
+ return 0
725
+ fi
726
+
727
+ capture_tmp_stderr " perl"
728
+ return 1
679
729
}
680
730
681
731
# do_download URL FILENAME
@@ -698,11 +748,19 @@ do_download() {
698
748
do_fetch $1 $2 && return 0
699
749
fi
700
750
701
- if exists_perl; then
702
- do_perl $1 $2 && return 0
751
+ if exists_perl_lwp; then
752
+ do_perl_lwp $1 $2 && return 0
753
+ fi
754
+
755
+ if exists_perl_ff; then
756
+ do_perl_ff $1 $2 && return 0
757
+ fi
758
+
759
+ if exists_python3_urllib; then
760
+ do_python3_urllib $1 $2 && return 0
703
761
fi
704
762
705
- critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple is found"
763
+ critical " Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
706
764
unable_to_retrieve_package
707
765
}
708
766
@@ -856,6 +914,7 @@ case $platform in
856
914
case $major_version in
857
915
" 10" ) deb_codename=" buster" ;;
858
916
" 11" ) deb_codename=" bullseye" ;;
917
+ " 12" ) deb_codename=" bookworm" ;;
859
918
esac
860
919
filetype=" deb"
861
920
filename=" ${collection} -release-${deb_codename} .deb"
@@ -867,6 +926,7 @@ case $platform in
867
926
" 3" ) deb_codename=" stretch" ;;
868
927
" 4" ) deb_codename=" buster" ;;
869
928
" 5" ) deb_codename=" bullseye" ;;
929
+ " 6" ) deb_codename=" bookworm" ;;
870
930
" 21" ) deb_codename=" jammy" ;;
871
931
" 20" ) deb_codename=" focal" ;;
872
932
" 19" ) deb_codename=" bionic" ;;
0 commit comments