diff mbox series

[REVIEW,3/4,linux-meta] UBUNTU: [Debian] Use variant information to generate debian/control

Message ID 20191203222657.1152249-17-seth.forshee@canonical.com
State New
Headers show
Series None | expand

Commit Message

Seth Forshee Dec. 3, 2019, 10:26 p.m. UTC
Use the variant list from debian/variants to generate meta
packages for all variants imported from the kernel. While at it,
update the syntax used for variable substitution in the control
templates for consistency. If no debian/variants files is
present, assume the primary variant.

linux-source and linux-crashdump should only be generated for the
primary (i.e. "--") variant. Move these to
debian/control.d/primary so that they can be omitted whenever the
primary variant is not present.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 debian/control.common         | 25 ++-------------
 debian/control.d/generic      | 12 ++++----
 debian/control.d/generic-lpae | 10 +++---
 debian/control.d/lowlatency   | 12 ++++----
 debian/control.d/primary      | 19 ++++++++++++
 debian/control.d/snapdragon   | 10 +++---
 debian/control.d/virtual      | 18 +++++------
 debian/rules                  | 57 +++++++++++++++++++++++------------
 8 files changed, 89 insertions(+), 74 deletions(-)
 create mode 100644 debian/control.d/primary
diff mbox series

Patch

diff --git a/debian/control.common b/debian/control.common
index 2c05c0c9838b..fbe34ac6c7c2 100644
--- a/debian/control.common
+++ b/debian/control.common
@@ -1,31 +1,10 @@ 
-Source: linux-meta@SUFFIX@
+Source: @META_SOURCE@
 Section: devel
 Priority: optional
 Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com>
 Standards-Version: 3.9.8
 Build-Depends: dpkg (>= 1.13.19), debhelper (>= 9), gawk,
 Build-Depends-Arch:
- linux-headers-@kernel-abi-version@,
+ @KERNEL_SOURCE@-headers-@kernel-abi-version@,
  linux-headers-@kernel-abi-version@-generic,
 Vcs-Git: git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-meta/+git/@SERIES@
-
-Package: linux-source@SUFFIX@
-Architecture: all
-Depends: ${misc:Depends}, linux-source-${kernel-version}
-Description: Linux kernel source with Ubuntu patches
- This package will always depend on the latest Linux kernel source code
- available. The Ubuntu patches have been applied.
-
-Package: linux-crashdump@SUFFIX@
-Architecture: amd64 arm64 armhf ppc64el s390x
-Depends: ${misc:Depends}, kdump-tools, grub-pc (>= 1.96+20090611-1ubuntu2) [amd64] | grub-efi-ia32 [amd64] | grub-efi-amd64 [amd64] | grub-efi-arm64 [arm64] | grub (>= 0.97-29ubuntu24) [amd64]
-Recommends: apport
-Suggests: crash
-Description: Linux kernel crashdump setup for the latest generic kernel
- This package installs all the needed infrastructure to get crashdumps from
- your running system. If you are experiencing kernel crashes that cannot
- be debugged normally (because the problem is infrequent or panic's the
- system in such a way as to make information gathering impossible), then
- you can install this package to automatically enable capture of the
- vmcore on crashes.
-
diff --git a/debian/control.d/generic b/debian/control.d/generic
index 7be251a69cee..a548f360a5b6 100644
--- a/debian/control.d/generic
+++ b/debian/control.d/generic
@@ -1,4 +1,4 @@ 
-Package: linux-headers-generic@SUFFIX@
+Package: linux-headers-generic${variant:suffix}
 Architecture: amd64 armhf arm64 powerpc ppc64el s390x
 Section: kernel
 Depends: ${misc:Depends}, linux-headers-${kernel-abi-version}-generic
@@ -6,7 +6,7 @@  Description: Generic Linux kernel headers
  This package will always depend on the latest generic kernel headers
  available.
 
-Package: linux-image-generic@SUFFIX@
+Package: linux-image-generic${variant:suffix}
 Architecture: amd64 armhf arm64 powerpc ppc64el s390x
 Section: kernel
 Depends: ${misc:Depends}, linux-image-${kernel-abi-version}-generic, linux-modules-extra-${kernel-abi-version}-generic [amd64 arm64 powerpc ppc64el s390x], linux-firmware, intel-microcode [amd64], amd64-microcode [amd64]
@@ -15,7 +15,7 @@  Description: Generic Linux kernel image
  This package will always depend on the latest generic kernel image
  available.
 
-Package: linux-tools-generic@SUFFIX@
+Package: linux-tools-generic${variant:suffix}
 Architecture: amd64 armhf arm64 powerpc ppc64el s390x
 Section: kernel
 Provides: linux-tools
@@ -24,7 +24,7 @@  Description: Generic Linux kernel tools
  This package will always depend on the latest generic kernel tools
  available.
 
-Package: linux-cloud-tools-generic@SUFFIX@
+Package: linux-cloud-tools-generic${variant:suffix}
 Architecture: amd64
 Section: kernel
 Provides: linux-cloud-tools
@@ -33,10 +33,10 @@  Description: Generic Linux kernel cloud tools
  This package will always depend on the latest generic kernel cloud tools
  available.
 
-Package: linux-generic@SUFFIX@
+Package: linux-generic${variant:suffix}
 Architecture: amd64 armhf arm64 powerpc ppc64el s390x
 Section: kernel
-Depends: ${misc:Depends}, linux-image-generic@SUFFIX@ (= ${binary:Version}), linux-headers-generic@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-image-generic${variant:suffix} (= ${binary:Version}), linux-headers-generic${variant:suffix} (= ${binary:Version})
 Description: Complete Generic Linux kernel and headers
  This package will always depend on the latest complete generic Linux kernel
  and headers.
diff --git a/debian/control.d/generic-lpae b/debian/control.d/generic-lpae
index 2a4d72dbfd35..f8c57d8fcb12 100644
--- a/debian/control.d/generic-lpae
+++ b/debian/control.d/generic-lpae
@@ -1,4 +1,4 @@ 
-Package: linux-headers-generic-lpae@SUFFIX@
+Package: linux-headers-generic-lpae${variant:suffix}
 Architecture: armhf
 Section: kernel
 Depends: ${misc:Depends}, linux-headers-${kernel-abi-version}-generic-lpae
@@ -6,7 +6,7 @@  Description: Generic LPAE Linux kernel headers
  This package will always depend on the latest generic-lpae kernel headers
  available.
 
-Package: linux-image-generic-lpae@SUFFIX@
+Package: linux-image-generic-lpae${variant:suffix}
 Architecture: armhf
 Section: kernel
 Depends: ${misc:Depends}, linux-image-${kernel-abi-version}-generic-lpae, linux-firmware
@@ -15,7 +15,7 @@  Description: Generic LPAE Linux kernel image
  This package will always depend on the latest generic-lpae kernel image
  available.
 
-Package: linux-tools-generic-lpae@SUFFIX@
+Package: linux-tools-generic-lpae${variant:suffix}
 Architecture: armhf
 Section: kernel
 Provides: linux-tools
@@ -24,10 +24,10 @@  Description: Generic LPAE Linux kernel tools
  This package will always depend on the latest generic-lpae kernel tools
  available.
 
-Package: linux-generic-lpae@SUFFIX@
+Package: linux-generic-lpae${variant:suffix}
 Architecture: armhf
 Section: kernel
-Depends: ${misc:Depends}, linux-image-generic-lpae@SUFFIX@ (= ${binary:Version}), linux-headers-generic-lpae@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-image-generic-lpae${variant:suffix} (= ${binary:Version}), linux-headers-generic-lpae${variant:suffix} (= ${binary:Version})
 Description: Complete Generic LPAE Linux kernel and headers
  This package will always depend on the latest complete generic-lpae Linux kernel
  and headers.
diff --git a/debian/control.d/lowlatency b/debian/control.d/lowlatency
index 0e780155fda4..c8fc888d4055 100644
--- a/debian/control.d/lowlatency
+++ b/debian/control.d/lowlatency
@@ -1,4 +1,4 @@ 
-Package: linux-headers-lowlatency@SUFFIX@
+Package: linux-headers-lowlatency${variant:suffix}
 Architecture: amd64
 Section: kernel
 Depends: ${misc:Depends}, linux-headers-${kernel-abi-version}-lowlatency
@@ -6,7 +6,7 @@  Description: lowlatency Linux kernel headers
  This package will always depend on the latest lowlatency kernel headers
  available.
 
-Package: linux-image-lowlatency@SUFFIX@
+Package: linux-image-lowlatency${variant:suffix}
 Architecture: amd64
 Section: kernel
 Depends: ${misc:Depends}, linux-image-${kernel-abi-version}-lowlatency, linux-firmware, intel-microcode [amd64], amd64-microcode [amd64]
@@ -15,7 +15,7 @@  Description: lowlatency Linux kernel image
  This package will always depend on the latest lowlatency kernel image
  available.
 
-Package: linux-tools-lowlatency@SUFFIX@
+Package: linux-tools-lowlatency${variant:suffix}
 Architecture: amd64
 Section: kernel
 Provides: linux-tools
@@ -24,7 +24,7 @@  Description: lowlatency Linux kernel tools
  This package will always depend on the latest lowlatency kernel tools
  available.
 
-Package: linux-cloud-tools-lowlatency@SUFFIX@
+Package: linux-cloud-tools-lowlatency${variant:suffix}
 Architecture: amd64
 Section: kernel
 Provides: linux-cloud-tools
@@ -33,10 +33,10 @@  Description: lowlatency Linux kernel cloud tools
  This package will always depend on the latest lowlatency kernel cloud tools
  available.
 
-Package: linux-lowlatency@SUFFIX@
+Package: linux-lowlatency${variant:suffix}
 Architecture: amd64
 Section: kernel
-Depends: ${misc:Depends}, linux-image-lowlatency@SUFFIX@ (= ${binary:Version}), linux-headers-lowlatency@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-image-lowlatency${variant:suffix} (= ${binary:Version}), linux-headers-lowlatency${variant:suffix} (= ${binary:Version})
 Description: Complete lowlatency Linux kernel
  This package will always depend on the latest complete lowlatency Linux kernel
  available.
diff --git a/debian/control.d/primary b/debian/control.d/primary
new file mode 100644
index 000000000000..de20d4b1e39a
--- /dev/null
+++ b/debian/control.d/primary
@@ -0,0 +1,19 @@ 
+Package: linux-source
+Architecture: all
+Depends: ${misc:Depends}, linux-source-${kernel-version}
+Description: Linux kernel source with Ubuntu patches
+ This package will always depend on the latest Linux kernel source code
+ available. The Ubuntu patches have been applied.
+
+Package: linux-crashdump
+Architecture: amd64 arm64 armhf ppc64el s390x
+Depends: ${misc:Depends}, kdump-tools, grub-pc (>= 1.96+20090611-1ubuntu2) [amd64] | grub-efi-ia32 [amd64] | grub-efi-amd64 [amd64] | grub-efi-arm64 [arm64] | grub (>= 0.97-29ubuntu24) [amd64]
+Recommends: apport
+Suggests: crash
+Description: Linux kernel crashdump setup for the latest generic kernel
+ This package installs all the needed infrastructure to get crashdumps from
+ your running system. If you are experiencing kernel crashes that cannot
+ be debugged normally (because the problem is infrequent or panic's the
+ system in such a way as to make information gathering impossible), then
+ you can install this package to automatically enable capture of the
+ vmcore on crashes.
diff --git a/debian/control.d/snapdragon b/debian/control.d/snapdragon
index 2645922490e9..34b7b3bba934 100644
--- a/debian/control.d/snapdragon
+++ b/debian/control.d/snapdragon
@@ -1,4 +1,4 @@ 
-Package: linux-headers-snapdragon@SUFFIX@
+Package: linux-headers-snapdragon${variant:suffix}
 Architecture: arm64
 Section: kernel
 Depends: ${misc:Depends}, linux-headers-${kernel-abi-version}-snapdragon
@@ -6,7 +6,7 @@  Description: Linux kernel headers for the Qualcomm Snapdragon 410c architecture
  This package will always depend on the latest kernel headers available
  for ARM64 Qualcomm Snapdragon 410c systems.
 
-Package: linux-image-snapdragon@SUFFIX@
+Package: linux-image-snapdragon${variant:suffix}
 Architecture: arm64
 Section: kernel
 Depends: ${misc:Depends}, linux-image-${kernel-abi-version}-snapdragon, linux-firmware
@@ -14,7 +14,7 @@  Description: Linux kernel image for the Qualcomm Snapdragon 410c architecture
  This package will always depend on the latest kernel image available
  for ARM64 Qualcomm Snapdragon 410c systems.
 
-Package: linux-tools-snapdragon@SUFFIX@
+Package: linux-tools-snapdragon${variant:suffix}
 Architecture: arm64
 Section: kernel
 Provides: linux-tools
@@ -23,10 +23,10 @@  Description: Linux kernel tools for the Qualcomm Snapdragon 410c architecture
  This package will always depend on the latest kernel tools available
  for ARM64 Qualcomm Snapdragon 410c systems.
 
-Package: linux-snapdragon@SUFFIX@
+Package: linux-snapdragon${variant:suffix}
 Architecture: arm64
 Section: kernel
-Depends: ${misc:Depends}, linux-image-snapdragon@SUFFIX@ (= ${binary:Version}), linux-headers-snapdragon@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-image-snapdragon${variant:suffix} (= ${binary:Version}), linux-headers-snapdragon${variant:suffix} (= ${binary:Version})
 Description: Complete Linux kernel and headers for the Qualcomm Snapdragon 410c architecture
  This package will always depend on the latest complete Linux kernel and
  headers available for ARM64 Qualcomm Snapdragon 410c systems.
diff --git a/debian/control.d/virtual b/debian/control.d/virtual
index 121c0f08ccea..f0d01c2c6f4b 100644
--- a/debian/control.d/virtual
+++ b/debian/control.d/virtual
@@ -1,11 +1,11 @@ 
-Package: linux-headers-virtual@SUFFIX@
+Package: linux-headers-virtual${variant:suffix}
 Architecture: amd64 arm64 powerpc ppc64el s390x
 Section: kernel
-Depends: ${misc:Depends}, linux-headers-generic@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-headers-generic${variant:suffix} (= ${binary:Version})
 Description: Virtual Linux kernel headers
  This package will always depend on linux-headers-generic.
 
-Package: linux-image-virtual@SUFFIX@
+Package: linux-image-virtual${variant:suffix}
 Architecture: amd64 arm64 powerpc ppc64el s390x
 Section: kernel
 Depends: ${misc:Depends}, linux-image-${kernel-abi-version}-generic
@@ -13,7 +13,7 @@  Description: Virtual Linux kernel image
  This package will always depend on the latest minimal generic kernel image
  used for virtual instances.
 
-Package: linux-tools-virtual@SUFFIX@
+Package: linux-tools-virtual${variant:suffix}
 Architecture: amd64 arm64 powerpc ppc64el s390x
 Section: kernel
 Provides: linux-tools
@@ -22,7 +22,7 @@  Description: Virtual Linux kernel tools
  This package will always depend on the latest minimal generic kernel tools
  used for virtual instances.
 
-Package: linux-cloud-tools-virtual@SUFFIX@
+Package: linux-cloud-tools-virtual${variant:suffix}
 Architecture: amd64
 Section: kernel
 Provides: linux-cloud-tools
@@ -31,17 +31,17 @@  Description: Virtual Linux kernel cloud tools
  This package will always depend on the latest minimal generic kernel cloud tools
  used for virtual instances.
 
-Package: linux-virtual@SUFFIX@
+Package: linux-virtual${variant:suffix}
 Architecture: amd64 arm64 powerpc ppc64el s390x
 Section: kernel
-Depends: ${misc:Depends}, linux-image-virtual@SUFFIX@ (= ${binary:Version}), linux-headers-virtual@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-image-virtual${variant:suffix} (= ${binary:Version}), linux-headers-virtual${variant:suffix} (= ${binary:Version})
 Description: Minimal Generic Linux kernel and headers
  This package will always depend on linux-image-virtual and
  linux-headers-virtual.
 
-Package: linux-image-extra-virtual@SUFFIX@
+Package: linux-image-extra-virtual${variant:suffix}
 Architecture: amd64 arm64 powerpc ppc64el s390x
 Section: kernel
-Depends: ${misc:Depends}, linux-image-generic@SUFFIX@ (= ${binary:Version})
+Depends: ${misc:Depends}, linux-image-generic${variant:suffix} (= ${binary:Version})
 Description: Extra drivers for Virtual Linux kernel image
  This package will always depend on linux-image-generic.
diff --git a/debian/rules b/debian/rules
index 9ddcb3bb5f91..6419ebc4228c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,26 +7,31 @@ 
 # Copyright (c) 2004 Jens Schmalzing <jensen@debian.org>
 #
 
-# Pull out the source suffix, we intend to maintain an -lts-<series> suffix
-# but otherwise assume this main packages are not intended to have a suffix
-# so that linux-meta and linux-meta-ti-omap4 will behave normally, but
-# linux-meta-lts-vivid will add the series suffix.
 SERIES=$(shell dpkg-parsechangelog | sed -ne 's/^Distribution: *//p' | sed -e 's/-\(security\|updates\|proposed\)$$//')
 SOURCE=$(shell dpkg-parsechangelog | sed -ne 's/^Source: *//p')
-SUFFIX=$(shell dpkg-parsechangelog | sed -ne 's/^Source: *linux-meta-lts/-lts/p')
+KERNEL_SOURCE=$(shell echo "$(SOURCE)" | sed -e 's/-meta//')
+
+VARIANT_PROVIDES=$(shell echo "$(SOURCE)" | sed -e 's/linux-meta-//')
 
 # 5 digit versions (2.6.38.<abi>.<upload>, 3 digit kernel base versions (2.6.38)
 KERNEL_VERSION=$(shell dpkg-parsechangelog -SVersion | cut -d. -f1-3)
 KERNEL_ABI=$(shell dpkg-parsechangelog -SVersion | cut -d. -f4)
 
-# 4 digit versions (3.0.<abi>.<upload>), 2 digit kernel base versions (3.0)
-#KERNEL_VERSION=$(shell dpkg-parsechangelog | grep ^Version | sed -e \
-	's/Version: \([0-9]*\.[0-9]*\)\..*/\1/')
-#KERNEL_ABI=$(shell head -n1 < debian/changelog | gawk '{n=split($$0,v,"."); print v[3];}')
-
 KERNEL_ABI_VERSION=$(KERNEL_VERSION)-$(KERNEL_ABI)
 
-control_files := debian/control.common $(shell LC_ALL=C ls -d debian/control.d/*)
+# Get variants, assumng primary if debian/variants is not present
+variants = --
+ifneq (,$(wildcard debian/variants))
+	variants := $(shell cat debian/variants)
+endif
+
+control_files := debian/control.common
+# control files only wanted for the primary variant
+primary_control_files := debian/control.d/primary $(shell LC_ALL=C ls -d debian/control.d/transitionals-*)
+ifneq ($(filter --,$(variants)),)
+	control_files += $(primary_control_files)
+endif
+control_files += $(filter-out $(primary_control_files),$(shell LC_ALL=C ls -d debian/control.d/*))
 
 SHELL := sh -e
 
@@ -35,18 +40,30 @@  clean: debian/control
 	dh_testroot
 	dh_clean
 
+define variant_payload
+variant="$$(echo '$(variant)' | sed -e 's/--//')"; \
+sed -e "s/\$${variant:suffix}/$$variant/g" -e "s/\$${variant:provides\(\|-image\|-headers\)}/$${variant_provides:+linux\1-$$variant_provides}/" <$$i; \
+variant_provides=''; \
+echo "";
+endef
+
 debian/control: $(control_files)
-	rm -f debian/control.tmp
 	for i in $^; do \
-		sed \
-			-e 's/@SERIES@/$(SERIES)/g' \
-			-e 's/@SUFFIX@/$(SUFFIX)/g' \
-			-e 's/@kernel-abi-version@/$(KERNEL_ABI_VERSION)/g' \
-			$$i >> debian/control.tmp; \
-		echo >> debian/control.tmp; \
-	done
+		if grep -q "{variant:" $$i; then \
+			variant_provides="$(VARIANT_PROVIDES)"; \
+			$(foreach variant,$(variants),$(variant_payload)) \
+		else \
+			cat $$i; \
+			echo ""; \
+		fi; \
+	done | sed \
+		-e 's/@SERIES@/$(SERIES)/g' \
+		-e 's/@kernel-abi-version@/$(KERNEL_ABI_VERSION)/g' \
+		-e 's/@META_SOURCE@/$(SOURCE)/g' \
+		-e 's/@KERNEL_SOURCE@/$(KERNEL_SOURCE)/g' \
+	    >$@.tmp
 	rm -f $@
-	mv debian/control.tmp $@
+	mv $@.tmp $@
 
 .PHONY: debian/control