From patchwork Thu Apr 14 21:21:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1617466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KfXTS6b8Mz9sG6 for ; Fri, 15 Apr 2022 07:21:48 +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 1nf6uL-0008J5-GO; Thu, 14 Apr 2022 21:21:41 +0000 Received: from mail-pl1-f181.google.com ([209.85.214.181]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nf6uG-0008A2-EV for kernel-team@lists.ubuntu.com; Thu, 14 Apr 2022 21:21:36 +0000 Received: by mail-pl1-f181.google.com with SMTP id y6so5748618plg.2 for ; Thu, 14 Apr 2022 14:21:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6w3mCKtHbYUL/rJnK1Ab48Te4WpeMvZnanGtCkR0XsY=; b=YDJ+axWPXMjZt254tIIUplF87Ekql3kcSj8G6y0OEEjJJ3wLb5xmUZPCdC7FsSL2YL r3n+7I67emlVNAQvYCyEmzbS9nDHosOSWpt9nt3qBFA6+AcrowHezodrOJ3i9BpA45tc fe+ML/C8EMTtFXK6ztbatxe5p1I5Zb68PJZlw/AM5jsIOlt53paW1XuHwPuXxdCwS3lq RyqMcOLWuboWsVvwnTl9kWHZADI6veenqEcUraUOwIVKaaRPZ1kmxxpGq6MhRoayEPQP /OgwOn1UuYhfh7xh2iOOmSo4/3bW9HkCeNp9JTuV38HwCwLAvlI5lgEobpINNhXU+5MA jVyA== X-Gm-Message-State: AOAM530c9yeGr27XRfdGOvDoOos9R6jJPM8snJZmP8hdrhH6/RWeAfyZ HKsKLxpuUZkSyJGsSnG+QGdDngInzz4= X-Google-Smtp-Source: ABdhPJyTbQ2ImmCbivOrKfkYnjr1kpTC2ijkLyJ2mtzFtQZxiDZHtyV7g5FMd1bzZ/Bq5NbqDVcZbw== X-Received: by 2002:a17:90b:17cb:b0:1ca:7772:1abe with SMTP id me11-20020a17090b17cb00b001ca77721abemr551885pjb.162.1649971292744; Thu, 14 Apr 2022 14:21:32 -0700 (PDT) Received: from yewun.. (218-173-153-1.dynamic-ip.hinet.net. [218.173.153.1]) by smtp.gmail.com with ESMTPSA id b2-20020a056a000a8200b004f1111c66afsm783481pfl.148.2022.04.14.14.21.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 14:21:32 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/7][RFC][LRM][Unstable] debian: generalize template generation for multiple modules Date: Fri, 15 Apr 2022 05:21:21 +0800 Message-Id: <20220414212123.3616050-6-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220414212123.3616050-1-vicamo.yang@canonical.com> References: <20220414212123.3616050-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.181; envelope-from=vicamo@gmail.com; helo=mail-pl1-f181.google.com 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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "You-Sheng Yang (vicamo)" BugLink: https://bugs.launchpad.net/bugs/1962515 Signed-off-by: You-Sheng Yang (vicamo) --- debian/rules.in | 3 +- debian/scripts/gen-rules.lrg | 22 +++--- debian/scripts/gen-rules.lrm | 103 ++++++++++++++++------------ debian/scripts/gen-rules.lrs | 37 +++++++--- debian/templates/nvidia.postinst.in | 14 ++-- debian/templates/nvidia.prerm.in | 4 +- 6 files changed, 111 insertions(+), 72 deletions(-) diff --git a/debian/rules.in b/debian/rules.in index 2301329..f438500 100755 --- a/debian/rules.in +++ b/debian/rules.in @@ -103,7 +103,8 @@ define install_control = sed -e 's/@abiname@/$(src_abi)/g' \ -e 's/@localversion@/-$(2)/g' \ -e 's/@image-stem@/$(instfile)/g' \ - -e 's/@nvidia-ver@/$(4)/g' \ + -e 's/@module@/$(3)/g' \ + -e 's/@suffix-short@/$(4)/g' \ <"$$template" >"$$script"; \ done endef diff --git a/debian/scripts/gen-rules.lrg b/debian/scripts/gen-rules.lrg index 0c19b8f..fd16fa5 100755 --- a/debian/scripts/gen-rules.lrg +++ b/debian/scripts/gen-rules.lrg @@ -122,14 +122,20 @@ do fi targets=$(echo "$pkg_archs" | sed -e 's/\>"debian/control.interlock-up" <= ${src_lrm_version}) [${pkg_archs}], + linux-objects-${module}-${suffix_minus}-${src_abi}-${flavour} (>= ${src_lrm_version}) [${pkg_archs}], EOL # debian/rules.gen @@ -138,14 +144,14 @@ EOL # $package $version $suffix_minus $suffix_under $suffix_short $targets:: - install -d \$(custom_dir)/${src_abi}-${flavour}/signatures/nvidia-${suffix_short} - cp -rp /lib/modules/${src_abi}-${flavour}/kernel/nvidia-${suffix_short}/bits \$(custom_dir)/${src_abi}-${flavour}/signatures/nvidia-${suffix_short} + install -d \$(custom_dir)/${src_abi}-${flavour}/signatures/${module}-${suffix_short} + cp -rp /lib/modules/${src_abi}-${flavour}/kernel/${module}-${suffix_short}/bits \$(custom_dir)/${src_abi}-${flavour}/signatures/${module}-${suffix_short} ( \ - cd \$(custom_dir)/${src_abi}-${flavour}/signatures/nvidia-${suffix_short}/bits || exit 1; \ + cd \$(custom_dir)/${src_abi}-${flavour}/signatures/${module}-${suffix_short}/bits || exit 1; \ sh BUILD unsigned || exit 1; \ mv *.ko ..; \ ) - rm -rf \$(custom_dir)/${src_abi}-${flavour}/signatures/nvidia-${suffix_short}/bits + rm -rf \$(custom_dir)/${src_abi}-${flavour}/signatures/${module}-${suffix_short}/bits EOL done <"debian/dkms-versions" diff --git a/debian/scripts/gen-rules.lrm b/debian/scripts/gen-rules.lrm index a24629a..fd4a1d2 100755 --- a/debian/scripts/gen-rules.lrm +++ b/debian/scripts/gen-rules.lrm @@ -32,9 +32,11 @@ src_sigs_version=${src_version} mkdir -p "debian/control.d" : >"debian/control.interlock-up" -: >"debian/control.d/meta-nvidia" -: >"debian/control.d/nvidia" -: >"debian/control.d/migrate-nvidia" +for module in nvidia; do + : >"debian/control.d/meta-${module}" + : >"debian/control.d/${module}" + : >"debian/control.d/migrate-${module}" +done : >"debian/control.d/transitionals-local" : >"debian/control.d/signatures" @@ -130,9 +132,15 @@ EOL fi targets=$(echo "$pkg_archs" | sed -e 's/\>"debian/rules.gen" <= \$(nvidia_${suffix_under}_upstream_version))" +dkms_${module}_${suffix_under}_version=\$(shell gawk '/^${package} / { print \$\$2; }' debian/dkms-versions) +${module}_${suffix_under}_upstream_version=\$(shell echo "\$(dkms_${module}_${suffix_under}_version)" | cut -d '-' -f 1) +gencontrol_flags += -Vdkms:${module}-${suffix_minus}-modules="${module}-dkms-${suffix_minus} (= \$(dkms_${module}_${suffix_under}_version))" +gencontrol_flags += -Vadditional-deps:${module}-${suffix_minus}="nvidia-kernel-common-${suffix_minus} (<= \$(${module}_${suffix_under}_upstream_version)-1), nvidia-kernel-common-${suffix_minus} (>= \$(${module}_${suffix_under}_upstream_version))" test:: @echo $package $version $suffix_minus $suffix_under $suffix_short $targets $targets:: rm -rf \$(dkms_dir)/build \$(dkms_dir)/source mkdir -p \$(dkms_dir)/build \$(dkms_dir)/source - install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour} - install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/usr/lib/linux/triggers - \$(call install_control,linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour},${flavour},nvidia,${suffix_short},postinst postrm prerm config templates) - install -d debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour} - \$(call build_dkms, \$(src_abi)-${flavour}, linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}, \$(CURDIR)/debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/lib/modules/\$(src_abi)-${flavour}/kernel, "", nvidia-${suffix_short}, pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-kernel-source-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-dkms-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb) + install -d debian/linux-modules-${module}-${suffix_minus}-\$(src_abi)-${flavour} + install -d debian/linux-modules-${module}-${suffix_minus}-\$(src_abi)-${flavour}/usr/lib/linux/triggers + \$(call install_control,linux-modules-${module}-${suffix_minus}-\$(src_abi)-${flavour},${flavour},${module},${suffix_short},postinst postrm prerm config templates) + install -d debian/linux-objects-${module}-${suffix_minus}-\$(src_abi)-${flavour} + \$(call build_dkms, \$(src_abi)-${flavour}, linux-objects-${module}-${suffix_minus}-\$(src_abi)-${flavour}, \$(CURDIR)/debian/linux-objects-${module}-${suffix_minus}-\$(src_abi)-${flavour}/lib/modules/\$(src_abi)-${flavour}/kernel, "", ${module}-${suffix_short}, pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-kernel-source-${suffix_minus}_\$(dkms_${module}_${suffix_under}_version)_\$(arch).deb pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-dkms-${suffix_minus}_\$(dkms_${module}_${suffix_under}_version)_\$(arch).deb) EOL - # debian/control.d/meta-nvidia - cat - >>"debian/control.d/meta-nvidia" <>"debian/control.d/meta-${module}" < Architecture: ${pkg_archs} Section: kernel -Provides: \${dkms:nvidia-${suffix_minus}-modules}, nvidia-prebuilt-kernel +Provides: \${dkms:${module}-${suffix_minus}-modules}, ${module}-prebuilt-kernel Depends: \${misc:Depends}, - linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}), - \${additional-deps:nvidia-${suffix_minus}}, -Description: Extra drivers for nvidia-${suffix_minus} for the ${flavour}\${variant:suffix} flavour - Install extra signed nvidia-${suffix_minus} modules compatible with the ${flavour}\${variant:suffix} flavour. + linux-modules-${module}-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}), + \${additional-deps:${module}-${suffix_minus}}, +Description: Extra drivers for ${module}-${suffix_minus} for the ${flavour}\${variant:suffix} flavour + Install extra signed ${module}-${suffix_minus} modules compatible with the ${flavour}\${variant:suffix} flavour. EOL - # debian/control.d/nvidia - cat - >>"debian/control.d/nvidia" <>"debian/control.d/${module}" < Architecture: ${pkg_archs} Section: kernel @@ -185,15 +193,15 @@ Depends: \${misc:Depends}, \${shlibs:Depends}, binutils, -Description: Linux kernel nvidia modules for version ${src_abi} (objects) - This package contains the Linux kernel nvidia modules for version ${src_abi}. +Description: Linux kernel ${module} modules for version ${src_abi} (objects) + This package contains the Linux kernel ${module} modules for version ${src_abi}. . You likely do not want to install this package directly. Instead, install the - one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages, + one of the linux-modules-${module}-${suffix_minus}-${flavour}* meta-packages, which will ensure that upgrades work correctly, and that supporting packages are also installed. -Package: linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour} +Package: linux-modules-${module}-${suffix_minus}-${src_abi}-${flavour} Build-Profiles: Architecture: ${pkg_archs} Section: kernel @@ -203,40 +211,45 @@ Depends: \${misc:Depends}, \${shlibs:Depends}, linux-image-${src_abi}-${flavour} | linux-image-unsigned-${src_abi}-${flavour}, - linux-signatures-nvidia-${src_abi}-${flavour} (= ${src_sigs_version}), - linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}), - \${additional-deps:nvidia-${suffix_minus}}, -Description: Linux kernel nvidia modules for version ${src_abi} - This package pulls together the Linux kernel nvidia modules for + linux-signatures-${module}-${src_abi}-${flavour} (= ${src_sigs_version}), + linux-objects-${module}-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}), + \${additional-deps:${module}-${suffix_minus}}, +Description: Linux kernel ${module} modules for version ${src_abi} + This package pulls together the Linux kernel ${module} modules for version ${src_abi} with the appropriate signatures. . You likely do not want to install this package directly. Instead, install the - one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages, + one of the linux-modules-${module}-${suffix_minus}-${flavour}* meta-packages, which will ensure that upgrades work correctly, and that supporting packages are also installed. EOL - # debian/control.d/migrate-nvidia + # debian/control.d/migrate-${module} for cmd in $extra do case "$cmd" in transition=*) from="${cmd#transition=}" - from_minus=$(echo "$from" | sed -e 's/nvidia-graphics-drivers-//') + case "$package" in + nvidia-*) + from_minus=$(echo "$from" | sed -e 's/nvidia-graphics-drivers-//') + ;; + *) + echo "EE: unsupported transition for $package" 1>&2 + exit 1 + ;; + esac echo "II: general transition $from -> $package ($from_minus -> $suffix_minus) $pkg_archs" - cat - >>"debian/control.d/migrate-nvidia" <>"debian/control.d/migrate-${module}" <>"debian/rules.gen" <>"debian/rules.gen" <>debian/linux-signatures-nvidia-${src_abi}-${flavour}.install; \ + pkg=\$\$(basename "\$\$stream"); \ + echo "\$\$stream/* /lib/modules/${src_abi}-${flavour}/kernel/\$\$pkg/bits" >>debian/linux-signatures-${module}-${src_abi}-${flavour}.install; \ done EOL - cat - >>"debian/control.signatures" <>"debian/control.signatures" < Architecture: ${archs} Section: kernel Priority: optional Depends: linux-image-${src_abi}-${flavour} | linux-image-unsigned-${src_abi}-${flavour}, Built-Using: \${linux:BuiltUsing} -Description: Linux kernel signatures for nvidia modules for version ${src_abi}-${flavour} - This package contains the Linux kernel signatures nvidia modules for +Description: Linux kernel signatures for ${module} modules for version ${src_abi}-${flavour} + This package contains the Linux kernel signatures ${module} modules for version ${src_abi}-${flavour}. . You likely do not want to install this package directly. EOL + done <"debian/dkms-versions" done <"debian/package.config" cat "debian/control.common" "debian/control.signatures" | sed \ diff --git a/debian/templates/nvidia.postinst.in b/debian/templates/nvidia.postinst.in index 663631f..d367ee4 100755 --- a/debian/templates/nvidia.postinst.in +++ b/debian/templates/nvidia.postinst.in @@ -4,7 +4,7 @@ set -e version=@abiname@@localversion@ image_path=/boot/@image-stem@-$version -bits=/lib/modules/$version/kernel/nvidia-@nvidia-ver@/bits +bits=/lib/modules/$version/kernel/@module@-@suffix-short@/bits if [ "$1" != configure ]; then exit 0 @@ -22,12 +22,12 @@ if ! ubiquity_live; then . /usr/share/debconf/confmodule fi -conf=/etc/default/linux-modules-nvidia +conf=/etc/default/linux-modules-@module@ latelink='' [ -f "$conf" ] && . "$conf" case "$latelink" in true|false|'') ;; -*) echo "linux-modules-nvidia: latelink specifier invalid, ignored" 1>&2 +*) echo "linux-modules-@module@: latelink specifier invalid, ignored" 1>&2 latelink='' ;; esac @@ -45,8 +45,8 @@ if [ "$RET" != "$latelink" ]; then # If you change this file run one of the commands below to pull existing # installed packages into compliance: # -# sudo dpkg-reconfigure linux-modules-nvidia-$(uname -r) -# sudo dpkg-reconfigure $(dpkg -l 'linux-modules-nvidia-*' | awk '/^ii/ { print $2 }') +# sudo dpkg-reconfigure linux-modules-@module@-$(uname -r) +# sudo dpkg-reconfigure $(dpkg -l 'linux-modules-@module@-*' | awk '/^ii/ { print $2 }') latelink=$RET EOM @@ -59,13 +59,13 @@ fi if [ "$RET" = 'true' ]; then ( cd "$bits" || exit 1 - echo "linux-image-nvidia-$version: constructing .ko files" + echo "linux-image-@module@-$version: constructing .ko files" /bin/sh ./BUILD ) else ( cd "$bits" || exit 1 - echo "linux-image-nvidia-$version: removing .ko files" + echo "linux-image-@module@-$version: removing .ko files" /bin/sh ./CLEAN ) fi diff --git a/debian/templates/nvidia.prerm.in b/debian/templates/nvidia.prerm.in index f8b8e3e..38cafaa 100755 --- a/debian/templates/nvidia.prerm.in +++ b/debian/templates/nvidia.prerm.in @@ -3,7 +3,7 @@ set -e version=@abiname@@localversion@ -bits=/lib/modules/$version/kernel/nvidia-@nvidia-ver@/bits +bits=/lib/modules/$version/kernel/@module@-@suffix-short@/bits if [ "$1" != remove ]; then exit 0 @@ -12,7 +12,7 @@ fi # Clear out the build image before we lose the ability to do so. ( cd "$bits" || exit 1 - echo "linux-image-nvidia-$version: removing .ko files" + echo "linux-image-@module@-$version: removing .ko files" /bin/sh ./CLEAN )