diff -Nru linux-base-4.5ubuntu7/debian/changelog linux-base-4.5ubuntu8/debian/changelog --- linux-base-4.5ubuntu7/debian/changelog 2021-05-17 16:55:34.000000000 +0100 +++ linux-base-4.5ubuntu8/debian/changelog 2021-05-27 10:43:52.000000000 +0100 @@ -1,3 +1,12 @@ +linux-base (4.5ubuntu8) impish; urgency=medium + + * Rewrite xx-update-initrd-links to use linux-update-symlinks. This will + now make installkernel behaviour match the linux-image-*.postinst + behaviour exactly with respect to creating & updating vmlinu? and + initrd.img symlinks in / or /boot. LP: #1929255 + + -- Dimitri John Ledkov Thu, 27 May 2021 10:43:52 +0100 + linux-base (4.5ubuntu7) impish; urgency=medium * Check for update-initramfs being installed before running the postinst diff -Nru linux-base-4.5ubuntu7/debian/rules linux-base-4.5ubuntu8/debian/rules --- linux-base-4.5ubuntu7/debian/rules 2020-06-25 18:23:24.000000000 +0100 +++ linux-base-4.5ubuntu8/debian/rules 2021-05-27 10:43:52.000000000 +0100 @@ -7,3 +7,7 @@ ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) perl -Ilib -MTest::Harness -e 'runtests(@ARGV)' lib/t/*.t endif + +override_dh_install: + dh_install + chmod -v +x debian/linux-base/etc/kernel/postinst.d/* diff -Nru linux-base-4.5ubuntu7/etc/kernel/postinst.d/xx-update-initrd-links linux-base-4.5ubuntu8/etc/kernel/postinst.d/xx-update-initrd-links --- linux-base-4.5ubuntu7/etc/kernel/postinst.d/xx-update-initrd-links 2021-05-17 16:55:34.000000000 +0100 +++ linux-base-4.5ubuntu8/etc/kernel/postinst.d/xx-update-initrd-links 2021-05-27 10:43:32.000000000 +0100 @@ -1,88 +1,24 @@ #!/bin/sh set -e -command -v update-initramfs >/dev/null 2>&1 || exit 0 - -VERBOSE=true - -# If softlinks are maintained, then either under /boot or otherwise /. If -# neither location contains a vmlinuz, then no softlinks are maintained. -if [ -L /boot/vmlinu? ]; then - dir="/boot/" -elif [ -L /vmlinu? ]; then - dir="/" -else - dir="" -fi - -if [ "$dir" = "" ]; then - exit 0 -fi - -# avoid running multiple times -if [ -n "$DEB_MAINT_PARAMS" ]; then - eval set -- "$DEB_MAINT_PARAMS" - if [ -z "$1" ] || [ "$1" != "configure" ]; then - exit 0 - fi -fi - -create_link() { - local tgt=$1 - local src=$2 - local dir=$(dirname $src) - local kver=${tgt#initrd.img*-} - - # Running installkernel multiple times with the same kernel will - # create backups of the binary in the form of vmlinu?-.old - # However by then the modules have been replaced and also there is - # no way to build the initramfs with that name. - if [ ! -f "${dir}/${tgt}" ]; then - case $tgt in - initrd.img-*.old) - # installkernel should create a copy of the initrd - # when it copies a kernel image. This is only a hack - # before there is no matching file at all. - kver=${kver%.old} - cp ${dir}/initrd.img-$kver ${dir}/$tgt - ;; - *) - # This is present just as double safety net. By all means - # the actual initrd should already be created by a previous - # postinst script. - INITRAMFS_TOOLS_KERNEL_HOOK=1 \ - update-initramfs -c -k ${kver} - ;; - esac - fi - - $VERBOSE && echo "Softlink: ${src} -> ${tgt}" - cd ${dir} && ln -sf ${tgt} ${src} -} - -$VERBOSE && echo "Testing softlinks in $dir..." - -for f in $(find $dir -maxdepth 1 -regex '.*vmlinu.\(\.old\)?'); do - if [ -e $f ]; then - kernel=$(basename $f) - initrd="initrd.img${kernel#vmlinu?}" - tgt_kernel="$(readlink $f)" - tgt_initrd="initrd.img${tgt_kernel#vmlinu?}" - if [ ! -L "${dir}${initrd}" -o ! -e "${dir}${initrd}" ]; then - $VERBOSE && echo "${dir}${initrd} does not exist or is not a link" - create_link ${tgt_initrd} ${dir}${initrd} - else - cur_initrd=$(readlink ${dir}${initrd}) - if [ "${cur_initrd}" != "${tgt_initrd}" ]; then - $VERBOSE && echo "${dir}${initrd} invalid target (${cur_initrd})" - create_link ${tgt_initrd} ${dir}${initrd} - else - $VERBOSE && echo "${dir}${initrd} -> ${tgt_initrd} (ok)" - fi - fi - else - $VERBOSE && echo "Broken link: $f (skip)" - fi -done +# installkernel script calls postinst.d without any DEB_MAINT_PARAMS set +# linux-image-* postinst calls postinst.d with DEB_MAINT_PARAMS set +# do nothing in case linux-image-* calls this, as it already calls `linux-update-symlinks` +[ -z "$DEB_MAINT_PARAMS" ] || exit 0 + +# installkernel must call postinst.d with two args, version & image_path +version="$1" +image_path="$2" + +[ -n "$version" ] || exit 0 +[ -n "$image_path" ] || exit 0 + +# call linux-update-symlinks in install mode, which will correctly +# update vmlinuz & initrd.img symlinks. Even if initrd.img does not +# exist yet, or has already been created by the initramfs-update +# postinst.d hook. It will also honor kernel_img.conf settings to +# link_in_boot yes/no. Thus matching behaviour of linux-image-* +# postinst call to linux-update-symlinks. +linux-update-symlinks install $version $image_path exit 0