[P/U] [PATCH v2 2/2] UBUNTU: [Packaging] remove intermediate $(DEBIAN)/control.stub

Masahiro Yamada masahiro.yamada at canonical.com
Mon Mar 3 23:45:00 UTC 2025


Currently, scripts/debian/scripts/control-create generates the control
file as $(DEBIAN)/control.stub, which is then copied to debian/control.

The intermediate file is likely used to prevent the creation of a
partially updated (i.e., corrupted) control file.

Now that the build rule for $(DEBIAN)/control.stub can propagate errors
to GNU Make, we can use .DELETE_ON_ERROR to automatically delete the
corrupted control file if its build rule fails.

Since .DELETE_ON_ERROR does not apply to phony targets, I used FORCE
to ensure debian/control is always rebuilt. This is a common technique
in upstream Kbuild.

Signed-off-by: Masahiro Yamada <masahiro.yamada at canonical.com>
---

Changes in v2:
 - Add comments to .DELETE_ON_ERROR and FORCE. No functional changes.

 debian/rules | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/debian/rules b/debian/rules
index 3dfc6f3c1622..9d91769cf14f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -144,8 +144,6 @@ clean: debian/control debian/canonical-certs.pem debian/canonical-revoked-certs.
 	# If we have a reconstruct script use it.
 	[ -f $(DEBIAN)/reconstruct ] && bash $(DEBIAN)/reconstruct || true
 
-	# Remove generated intermediate files
-	rm -f debian/control.stub $(DEBIAN)/control.stub
 	rm -f debian/scripts/fix-filenames
 
 .PHONY: distclean
@@ -162,20 +160,15 @@ include debian/rules.d/3-binary-indep.mk
 UBUNTU_COMPATIBLE_SIGNING=$(shell grep -qx ' *Subject: C = GB, ST = Isle of Man, O = Canonical Ltd., OU = Secure Boot, CN = Canonical Ltd. Secure Boot Signing (2021 v3)' debian/canonical-revoked-certs.pem && echo ubuntu/4 pro/3)
 
 # Misc stuff
-.PHONY: $(DEBIAN)/control.stub
-$(DEBIAN)/control.stub: debian/canonical-revoked-certs.pem $(DEBIAN)/changelog
-	debian/scripts/control-create $(DEB_SOURCE) > $(DEBIAN)/control.stub
+debian/control: debian/canonical-revoked-certs.pem $(DEBIAN)/changelog FORCE
+	debian/scripts/control-create $(DEB_SOURCE) > $@
 	sed -i -e 's/PKGVER/$(DEB_VERSION_UPSTREAM)/g'                          \
 	        -e 's/ABINUM/$(abinum)/g'                                       \
 		-e 's/SRCPKGNAME/$(DEB_SOURCE)/g'                               \
 		-e 's/=SERIES=/$(DEB_DISTRIBUTION)/g'                           \
 		-e 's|\(^Maintainer:.*\)|\1\nXSC-Ubuntu-Compatible-Signing: $(UBUNTU_COMPATIBLE_SIGNING)|g' \
 		-e 's/\(^Build-Depends:$$\)/\1\n$(GCC_BUILD_DEPENDS)/g'         \
-	$(DEBIAN)/control.stub
-
-.PHONY: debian/control
-debian/control: $(DEBIAN)/control.stub
-	cp $(DEBIAN)/control.stub debian/control
+	$@
 
 debian/canonical-certs.pem: $(wildcard debian/certs/*.pem $(DEBIAN)/certs/*.pem)
 	for cert in $(sort $(notdir $^));					\
@@ -200,3 +193,9 @@ debian/canonical-revoked-certs.pem: $(wildcard debian/revoked-certs/*.pem $(DEBI
 			fi;							\
 		done;								\
 	done >"$@"
+
+# delete partially updated (i.e. corrupted) files on error
+.DELETE_ON_ERROR:
+
+# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
+.PHONY: FORCE
-- 
2.43.0




More information about the kernel-team mailing list