[PATCH v2 6/6][Unstable] UBUNTU: [Debian] fix ownership for files installed during build

Seth Forshee seth.forshee at canonical.com
Fri Jun 4 02:47:19 UTC 2021


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

We now install some files during build. This may be run separately
from building packages, in which case fakeroot will not record the
correct ownership in package archives.

Fix this by adding a new fixowner target which fixes the ownership
for the files installed during the build and is a dependency of the
build targets.

Signed-off-by: Seth Forshee <seth.forshee at canonical.com>
---
 debian/rules.d/2-binary-arch.mk | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 7e2c8b7ae169..700c1e65491d 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -35,11 +35,35 @@ $(stampdir)/stamp-prepare-tree-%: $(commonconfdir)/config.common.$(family) $(arc
 	$(build_cd) $(kmake) $(build_O) -j1 syncconfig prepare scripts
 	touch $@
 
+# Fix ownership for files potentially installed while not under fakeroot
+fixowner-%: pkgdir_bin = $(CURDIR)/debian/$(bin_pkg_name)-$*
+fixowner-%: pkgdir = $(CURDIR)/debian/$(mods_pkg_name)-$*
+fixowner-%: pkgdir_ex = $(CURDIR)/debian/$(mods_extra_pkg_name)-$*
+fixowner-%: pkgdir_bldinfo = $(CURDIR)/debian/$(bldinfo_pkg_name)-$*
+fixowner-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
+fixowner-%: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
+fixowner-%: toolspkgdir = $(CURDIR)/debian/$(tools_flavour_pkg_name)-$*
+fixowner-%: cloudpkgdir = $(CURDIR)/debian/$(cloud_flavour_pkg_name)-$*
+fixowner-%: basepkg = $(hdrs_pkg_name)
+fixowner-%: indeppkg = $(indep_hdrs_pkg_name)
+fixowner-%: $(stampdir)/stamp-install-%
+	@echo Debug: $@
+	[ -e $(pkgdir_bin) ] && find $(pkgdir_bin) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(pkgdir) ] && find $(pkgdir) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(pkgdir_ex) ] && find $(pkgdir_ex) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(pkgdir_bldinfo) ] && find $(pkgdir_bldinfo) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(dbgpkgdir) ] && find $(dbgpkgdir) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(signingv) ] && find $(signingv) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(toolspkgdir) ] && find $(toolspkgdir) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(cloudpkgdir) ] && find $(cloudpkgdir) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(basepkg) ] && find $(basepkg) -print0 | xargs -0 chown 0:0 || true
+	[ -e $(indeppkg) ] && find $(indeppkg) -print0 | xargs -0 chown 0:0 || true
+
 # Used by developers as a shortcut to prepare a tree for compilation.
 prepare-%: $(stampdir)/stamp-prepare-%
 	@echo Debug: $@
 # Used by developers to allow efficient pre-building without fakeroot.
-build-%: $(stampdir)/stamp-install-%
+build-%: fixowner-%
 	@echo Debug: $@
 
 # Do the actual build, including image and modules
-- 
2.31.1




More information about the kernel-team mailing list