update-kernel: Add undocumented --verbose option

Show executed apt-get commands.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
Виталий Чикунов 2022-04-06 03:04:07 +03:00
parent 13c7b3e673
commit 2029c44606
2 changed files with 16 additions and 8 deletions

View File

@ -24,13 +24,13 @@ COPY update-kernel remove-old-kernels /usr/sbin/
# Install base kernel for upgrading later.
# Check if the kernel appeared.
RUN toilet -w 150 First install && \
update-kernel -t std-def -f && \
update-kernel -v -t std-def -f && \
ls -l /boot/vmlinuz /boot/vmlinuz-std-def /boot/initrd.img /boot/initrd-std-def.img && \
ls -l /boot/$(readlink /boot/vmlinuz)
# Second call should succeed not installing anything, thus
# no -f for it to fail if it will try to install something.
RUN update-kernel -t std-def
RUN update-kernel -v -t std-def
# Forward to some future.
RUN \
@ -40,8 +40,8 @@ RUN \
# Update kernel.
RUN toilet Upgrading && \
update-kernel -t std-def -f && \
update-kernel -l && \
update-kernel -v -t std-def -f && \
update-kernel -v -l && \
ls -la /boot
# There now should be two kernels.

View File

@ -78,7 +78,7 @@ module_install() {
;;
esac
# shellcheck disable=SC2086
apt-get install -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true -y $dryrun "$module"
V apt-get install -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true -y $dryrun "$module"
else
export modules_to_install="$modules_to_install $1"
fi
@ -110,7 +110,7 @@ ufver() {
}
#parse command line options
TEMP=$(getopt -n "$PROG" -o a,i,l,f,y,t:,r:,n,h -l interactive,list,all,force,type:,release:,dry-run,help -- "$@") || show_help
TEMP=$(getopt -n "$PROG" -o a,i,l,f,y,t:,r:,v,n,h -l interactive,list,all,force,type:,release:,verbose,dry-run,help -- "$@") || show_help
eval set -- "$TEMP"
while :; do
@ -129,6 +129,8 @@ while :; do
;;
-r|--release) shift ; release="$1"
;;
-v|--verbose) verbose=1
;;
-n|--dry-run) dryrun="--download-only"
;;
-h|--help) show_help
@ -136,6 +138,12 @@ while :; do
shift
done
if [ -n "$verbose" ]; then
V() { echo >&2 "+ $*"; "$@"; }
else
V() { "$@"; }
fi
if [ -n "$interactive" ] && [ -n "$force" ]; then
show_usage '--force and --interactive are mutually exclusive options.'
fi
@ -380,7 +388,7 @@ fi
# install kernel iff we are working in interactive mode
if [ -n "$interactive" ]; then
# shellcheck disable=SC2086
apt-get install -y $dryrun "kernel-image-$kernel_flavour#$kmaxver" $modules_to_install \
V apt-get install -y $dryrun "kernel-image-$kernel_flavour#$kmaxver" $modules_to_install \
|| fatal "failed to install kernel-image-$kernel_flavour-$kmaxver"
modules_to_install=
fi
@ -416,7 +424,7 @@ done
# (in which case all of them already installed)
if [ -z "$interactive" ]; then
# shellcheck disable=SC2086
apt-get install -y $dryrun "kernel-image-$kernel_flavour#$kmaxver" $modules_to_install \
V apt-get install -y $dryrun "kernel-image-$kernel_flavour#$kmaxver" $modules_to_install \
|| fatal "failed to install kernel-image-$kernel_flavour-$kmaxver with modules"
fi