diff mbox series

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

Message ID 20210604024719.650626-7-seth.forshee@canonical.com
State New
Headers show
Series Kernel package builds running out of space on builders | expand

Commit Message

Seth Forshee June 4, 2021, 2:47 a.m. UTC
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@canonical.com>
---
 debian/rules.d/2-binary-arch.mk | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

Comments

Tim Gardner June 4, 2021, 12:02 p.m. UTC | #1
On 6/3/21 8:47 PM, Seth Forshee wrote:
> 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@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
> +

I know its bike shedding a bit, but this cuts down on repetitive code:

$(foreach i, $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) $(pkgdir_bldinfo) 
$(dbgpkgdir) $(signingv) $(toolspkgdir) $(cloudpkgdir) $(basepkg) 
$(indeppkg), [ -e $(i) ] && find $(i) -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
>
Seth Forshee June 4, 2021, 1:54 p.m. UTC | #2
On Fri, Jun 04, 2021 at 06:02:29AM -0600, Tim Gardner wrote:
> 
> 
> On 6/3/21 8:47 PM, Seth Forshee wrote:
> > 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@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
> > +
> 
> I know its bike shedding a bit, but this cuts down on repetitive code:
> 
> $(foreach i, $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) $(pkgdir_bldinfo)
> $(dbgpkgdir) $(signingv) $(toolspkgdir) $(cloudpkgdir) $(basepkg)
> $(indeppkg), [ -e $(i) ] && find $(i) -print0 | xargs -0 chown 0:0 || true;)

As it happens, Andy and I have determined this patch isn't needed. With
our packaging dh_fixperms is already going to change ownership of all
files to root:root, so I'm just going to drop this patch entirely.

Seth
diff mbox series

Patch

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