diff mbox series

[6/7,RFC,LRM,Unstable] debian: move lrm debian/rules.gen generation to sed template

Message ID 20220414212123.3616050-7-vicamo.yang@canonical.com
State New
Headers show
Series Build presigned iwlwifi dkms modules | expand

Commit Message

You-Sheng Yang April 14, 2022, 9:21 p.m. UTC
From: "You-Sheng Yang (vicamo)" <vicamo.yang@canonical.com>

BugLink: https://bugs.launchpad.net/bugs/1962515

Signed-off-by: You-Sheng Yang (vicamo) <vicamo.yang@canonical.com>
---
 debian/rules.in.nvidia       | 16 ++++++++++++++++
 debian/scripts/gen-rules.lrm | 27 +++++++++------------------
 2 files changed, 25 insertions(+), 18 deletions(-)
 create mode 100644 debian/rules.in.nvidia
diff mbox series

Patch

diff --git a/debian/rules.in.nvidia b/debian/rules.in.nvidia
new file mode 100644
index 0000000..eb4baff
--- /dev/null
+++ b/debian/rules.in.nvidia
@@ -0,0 +1,16 @@ 
+
+# @package@ @version@ @suffix_minus@ @suffix_under@
+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-@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)
diff --git a/debian/scripts/gen-rules.lrm b/debian/scripts/gen-rules.lrm
index fd4a1d2..165dfbe 100755
--- a/debian/scripts/gen-rules.lrm
+++ b/debian/scripts/gen-rules.lrm
@@ -145,24 +145,15 @@  EOL
 		echo "II: build $package for $flavour $pkg_archs"
 
 		# debian/rules.gen
-		cat - >>"debian/rules.gen" <<EOL
-
-# $package $version $suffix_minus $suffix_under
-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-${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
+		sed -e "s/@flavour@/${flavour}/g" \
+			-e "s/@package@/${package}/g" \
+			-e "s/@version@/${version}/g" \
+			-e "s/@targets@/${targets}/g" \
+			-e "s/@module@/${module}/g" \
+			-e "s/@suffix_minus@/${suffix_minus}/g" \
+			-e "s/@suffix_under@/${suffix_under}/g" \
+			-e "s/@suffix_short@/${suffix_short}/g" \
+			"debian/rules.in.${module}" >>"debian/rules.gen"
 
 		# debian/control.d/meta-${module}
 		cat - >>"debian/control.d/meta-${module}" <<EOL