Skip to content

Commit d064c72

Browse files
committed
Bump puppet_agent to a version that supports bookworm
1 parent 5d0eb6f commit d064c72

File tree

2 files changed

+78
-18
lines changed

2 files changed

+78
-18
lines changed

install.sh

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,25 @@ assert_unmodified_apt_config() {
301301
fi
302302
}
303303

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+
304309
# 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
308312
return 0
309-
else
310-
return 1
311313
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
312323
}
313324

314325
# Get command line arguments
@@ -368,7 +379,7 @@ fi
368379
# Track to handle puppet5 to puppet6
369380
if [ -f /opt/puppetlabs/puppet/VERSION ]; then
370381
installed_version=`cat /opt/puppetlabs/puppet/VERSION`
371-
elif which puppet >/dev/null 2>&1; then
382+
elif type -p puppet >/dev/null; then
372383
installed_version=`puppet --version`
373384
else
374385
installed_version=uninstalled
@@ -656,9 +667,28 @@ do_fetch() {
656667
return 0
657668
}
658669

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)..."
662692
run_cmd "perl -e 'use LWP::Simple; getprint(\$ARGV[0]);' '$1' > '$2' 2>$tmp_stderr"
663693
rc=$?
664694

@@ -669,13 +699,33 @@ do_perl() {
669699
unable_to_retrieve_package
670700
fi
671701

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
676704
fi
677705

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
679729
}
680730

681731
# do_download URL FILENAME
@@ -698,11 +748,19 @@ do_download() {
698748
do_fetch $1 $2 && return 0
699749
fi
700750

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
703761
fi
704762

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"
706764
unable_to_retrieve_package
707765
}
708766

@@ -856,6 +914,7 @@ case $platform in
856914
case $major_version in
857915
"10") deb_codename="buster";;
858916
"11") deb_codename="bullseye";;
917+
"12") deb_codename="bookworm";;
859918
esac
860919
filetype="deb"
861920
filename="${collection}-release-${deb_codename}.deb"
@@ -867,6 +926,7 @@ case $platform in
867926
"3") deb_codename="stretch";;
868927
"4") deb_codename="buster";;
869928
"5") deb_codename="bullseye";;
929+
"6") deb_codename="bookworm";;
870930
"21") deb_codename="jammy";;
871931
"20") deb_codename="focal";;
872932
"19") deb_codename="bionic";;

0 commit comments

Comments
 (0)