@@ -25,10 +25,24 @@ DRIVER_ARCH=${TARGETARCH/amd64/x86_64} && DRIVER_ARCH=${DRIVER_ARCH/arm64/aarch6
2525
2626echo " DRIVER_ARCH is $DRIVER_ARCH "
2727
28+ # Run apt-get -qq quietly, on failure print actual error to stdout and exit.
29+ _apt_quiet () {
30+ local err_file
31+ err_file=$( mktemp)
32+ trap " rm -f \" $err_file \" " RETURN
33+ if ! apt-get -qq " $@ " 2> " $err_file " ; then
34+ echo " ERROR: apt-get failed (exit $? ): $* "
35+ echo " apt-get stderr:"
36+ cat " $err_file "
37+ return 1
38+ fi
39+ return 0
40+ }
41+
2842_enable_fips_if_required () {
2943 if [[ -n " ${UBUNTU_PRO_TOKEN} " && ${KERNEL_VERSION} =~ " fips" ]]; then
3044 echo " Ubuntu Pro token and FIPS kernel detected"
31- apt-get -qq install --no-install-recommends ubuntu-advantage-tools > /dev/null
45+ _apt_quiet install --no-install-recommends ubuntu-advantage-tools
3246
3347 # This workaround is needed in Ubuntu 24.04 as OpenSSL attempts to leverage the FIPS provider
3448 # when the underlying kernel is FIPS enabled.
@@ -39,7 +53,7 @@ _enable_fips_if_required() {
3953 echo " Enabling FIPS apt repo access..."
4054 pro enable --access-only --assume-yes fips-updates
4155 echo " Installing the OpenSSL FIPS modules"
42- apt-get -qq install --no-install-recommends ubuntu-fips-userspace > /dev/null
56+ _apt_quiet install --no-install-recommends ubuntu-fips-userspace
4357
4458 # With the OpenSSL FIPS module installed, OpenSSL can now work with the default settings,
4559 unset OPENSSL_FORCE_FIPS_MODE
@@ -49,7 +63,7 @@ _enable_fips_if_required() {
4963_update_package_cache () {
5064 if [ " ${PACKAGE_TAG:- } " != " builtin" ]; then
5165 echo " Updating the package cache..."
52- if ! apt-get -qq update; then
66+ if ! _apt_quiet update; then
5367 echo " ERROR: Failed to update package cache. " \
5468 " Ensure that the cluster can access the proper networks."
5569 exit 1
@@ -99,11 +113,11 @@ _install_prerequisites() (
99113 mkdir -p /lib/modules/${KERNEL_VERSION} /proc
100114
101115 echo " Installing Linux kernel headers..."
102- apt-get -qq install --no-install-recommends linux-headers-${KERNEL_VERSION} > /dev/null
116+ _apt_quiet install --no-install-recommends linux-headers-${KERNEL_VERSION}
103117
104118 echo " Installing Linux kernel module files..."
105- apt-get -qq download linux-image-${KERNEL_VERSION} && dpkg -x linux-image* .deb .
106- { apt-get -qq download linux-modules-${KERNEL_VERSION} && dpkg -x linux-modules* .deb . || true ; } 2> /dev/null
119+ _apt_quiet download linux-image-${KERNEL_VERSION} && dpkg -x linux-image* .deb .
120+ { _apt_quiet download linux-modules-${KERNEL_VERSION} && dpkg -x linux-modules* .deb . || true ; }
107121 mv lib/modules/${KERNEL_VERSION} /modules.* /lib/modules/${KERNEL_VERSION}
108122 mv lib/modules/${KERNEL_VERSION} /kernel /lib/modules/${KERNEL_VERSION}
109123 depmod ${KERNEL_VERSION}
@@ -121,7 +135,7 @@ _install_prerequisites() (
121135# Cleanup the prerequisites installed above.
122136_remove_prerequisites () {
123137 if [ " ${PACKAGE_TAG:- } " != " builtin" ]; then
124- apt-get -qq purge linux-headers-${KERNEL_VERSION} > /dev/null
138+ _apt_quiet purge linux-headers-${KERNEL_VERSION}
125139 # TODO remove module files not matching an existing driver package.
126140 fi
127141}
0 commit comments