From patchwork Fri May 28 10:42:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri John Ledkov X-Patchwork-Id: 1485205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fs1V82BH9z9sW4; Fri, 28 May 2021 20:42:40 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lmZwq-0006Ky-UB; Fri, 28 May 2021 10:42:36 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lmZwo-0006Ks-Pk for kernel-team@lists.ubuntu.com; Fri, 28 May 2021 10:42:34 +0000 Received: from mail-wr1-f72.google.com ([209.85.221.72]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmZwo-0007Mw-IJ for kernel-team@lists.ubuntu.com; Fri, 28 May 2021 10:42:34 +0000 Received: by mail-wr1-f72.google.com with SMTP id h104-20020adf90710000b029010de8455a3aso862386wrh.12 for ; Fri, 28 May 2021 03:42:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LRFph38ZWKKNId0GwVG1W1wVZbFFXlKVsvh1XdNGrqo=; b=Kpb430C1HQdvCCgRXmO8PcSX1vfpecNUvGWDKY88gUaavnHfjhRwQzUluCCluNlsFI 0fixwY//327Y7mzrJubGV6WwBlw7Hw6QLeV+21Qaew3ikUyhy6JLh2WPXLenNJ3TIO/V THuAkJIJ2hJCS/xBBv3r5kkspS0N9wfG67TewvMngHZngweRzkWQZiEtutuQcuU3Ucop J+XBlSPLCIZrCaToviXVEEnILIgM2+aE8Opu2oiYpPmIUrAnEgnGwnMPCX4czJqWDUg7 lEKEq8IhdaNBtj474JZLhyhtgdACWhZOtEA6Qjw5QpgbhWQ3StKXSheGe8z3fwSL+t02 AGdw== X-Gm-Message-State: AOAM5304SSsIe7pvx1zEt04ZPiQGZujy0apeKyyILLSaRrYrEV9CK5lZ MUyTpVoSRA88XcYtmhnoR3ft2leBNAIa4Btg1c+Z6gtzdKOwSYzF8z9oUmOpFr0Xf43X1IHArfB d29klIkcNfaC8J4Sm+vZ6oxf2VrZh66PMXaNdBh21Ig== X-Received: by 2002:adf:ee44:: with SMTP id w4mr7702117wro.415.1622198553838; Fri, 28 May 2021 03:42:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyIWeAIlYhkec7kwnvKN3EuSguhmCMEmDYmOh7Eg4fay5IIUbxk7TUem2aeSnWtKrpuNWmfw== X-Received: by 2002:adf:ee44:: with SMTP id w4mr7702088wro.415.1622198553524; Fri, 28 May 2021 03:42:33 -0700 (PDT) Received: from localhost ([2a01:4b00:85fd:d700:4914:2f01:ecaa:a59a]) by smtp.gmail.com with ESMTPSA id o8sm7004723wrx.4.2021.05.28.03.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 03:42:33 -0700 (PDT) From: Dimitri John Ledkov To: kernel-team@lists.ubuntu.com Subject: [linux-base][IHGFB] use linux-update-symlinks in xx-update-initrd-links Date: Fri, 28 May 2021 11:42:20 +0100 Message-Id: <20210528104220.191853-1-dimitri.ledkov@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: timo.aaltonen@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Currently there is inconsistency between the commands that linux-image.deb package installation calls, and what installkernel script calls. In linux-image postinst linux-update-symlinks is called; whereas installkernel script does not call it. Rewrite xx-update-initrd-links from custom implementation, to a call to linux-update-symlinks but only when installkernel script calls the postinst.d run-parts. This way installkernel does exactly what linux-image.deb installation would do, including honoring settings in /etc/kernel-img.conf that installers have been providing in older series. Drop duplicated calls to initramfs-tools, multiple postinst.d must not call update-initramfs. postinst.d snippted to do that already is called and shipped by the initramfs-tools package. Acked-by: Krzysztof Kozlowski Acked-by: Stefan Bader 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