kbuild: deb-pkg: remove the fakeroot builds support
PATCH v3 1/1 kbuild: deb-pkg: remove the fakeroot builds support
In 2017, the dpkg suite introduced the rootless builds support with the following commits:
- 2436807c87b0 ("dpkg-deb: Add support for rootless builds")
- fca1bfe84068 ("dpkg-buildpackage: Add support for rootless builds")
This feature is available in the default dpkg on Debian 10 and Ubuntu 20.04.
Remove the old method.
---
Changes in v3:
- Remove DEB_RULES_REQUIRES_ROOT=no again (resent in order to clarify which one should be applied)
Changes in v2:
- add DEB_RULES_REQUIRES_ROOT=no to debian/rules
scripts/Makefile.package | 4 +--- scripts/package/builddeb | 8 +------- 2 files changed, 2 insertions(+), 10 deletions(-)
scripts/Makefile.package +1 -3
@@ -109,8 +109,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian cp $< ../$(orig-name); \ fi -KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' - PHONY += deb-pkg srcdeb-pkg bindeb-pkg deb-pkg: private build-type := source,binary
@@ -125,7 +123,7 @@ deb-pkg srcdeb-pkg bindeb-pkg: $(if $(findstring source, $(build-type)), \ --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ $(if $(findstring binary, $(build-type)), \ - -R'$(MAKE) -f debian/rules' -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \ --no-check-builddeps) \ $(DPKG_FLAGS))
scripts/package/builddeb +1 -7
@@ -36,19 +36,13 @@ create_package() { sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ | xargs -r0 md5sum > DEBIAN/md5sums" - # Fix ownership and permissions - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then - dpkg_deb_opts="--root-owner-group" - else - chown -R root:root "$pdir" - fi # a+rX in case we are in a restrictive umask environment like 0077 # ug-s in case we build in a setuid/setgid directory chmod -R go-w,a+rX,ug-s "$pdir" # Create the package dpkg-gencontrol -p$pname -P"$pdir" - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. + dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. } install_linux_image () {
Signature · 1 line
2.40.1
Hi!
Quoted 9 lines · Masahiro Yamada
In 2017, the dpkg suite introduced the rootless builds support with the following commits:
-
2436807c87b0("dpkg-deb: Add support for rootless builds")
-fca1bfe84068("dpkg-buildpackage: Add support for rootless builds")This feature is available in the default dpkg on Debian 10 and Ubuntu 20.04.
Quoted 8 lines
Remove the old method.
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v3:
- Remove DEB_RULES_REQUIRES_ROOT=no again (resent in order to clarify which one should be applied)
Thanks, as this variable is supposed to be defined by the build driver (such as dpkg-buildpackage) that calls debian/rules, as covered in the rootless-builds.txt spec.
Quoted 14 lines
scripts/Makefile.package +0
-2@@ -109,8 +109,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian cp $< ../$(orig-name); \ fi -KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' - PHONY += deb-pkg srcdeb-pkg bindeb-pkg deb-pkg: private build-type := source,binary
scripts/Makefile.package deb-pkg srcdeb-pkg bindeb-pkg: · line 126
Quoted 5 lines
scripts/Makefile.package +1
-1@@ -125,7 +123,7 @@ deb-pkg srcdeb-pkg bindeb-pkg: $(if $(findstring source, $(build-type)), \ --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ $(if $(findstring binary, $(build-type)), \ - -R'$(MAKE) -f debian/rules' -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \
Since dpkg 1.14.7, dpkg-buildpackage uses fakeroot if available, so regardless of anything else this removal seems safe.
Quoted 15 lines
scripts/Makefile.package +0
-0--no-check-builddeps) \ $(DPKG_FLAGS))scripts/package/builddeb +0
-4@@ -36,19 +36,13 @@ create_package() { sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ | xargs -r0 md5sum > DEBIAN/md5sums" - # Fix ownership and permissions - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then - dpkg_deb_opts="--root-owner-group" - else
scripts/package/builddeb create_package() { · line 45
Quoted 10 lines
scripts/package/builddeb +1
-3- chown -R root:root "$pdir" - fi # a+rX in case we are in a restrictive umask environment like 0077 # ug-s in case we build in a setuid/setgid directory chmod -R go-w,a+rX,ug-s "$pdir" # Create the package dpkg-gencontrol -p$pname -P"$pdir" - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. + dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
If you want to make sure dpkg-deb supports that option, perhaps add «dpkg (>= 1.19.0)» to the package Build-Depends? If that version seems old enough to be assumed to be present, then unconditionally using it seems fine.
scripts/package/builddeb create_package() { · line 48
Quoted 3 lines
scripts/package/builddeb +0
-0} install_linux_image () {
Otherwise, the change LGTM.
Thanks,
Guillem
Quoted 38 lines · Guillem Jover
Hi!
Quoted 9 lines · Masahiro Yamada
In 2017, the dpkg suite introduced the rootless builds support with the following commits:
-
2436807c87b0("dpkg-deb: Add support for rootless builds")
-fca1bfe84068("dpkg-buildpackage: Add support for rootless builds")This feature is available in the default dpkg on Debian 10 and Ubuntu 20.04.
Quoted 8 lines
Remove the old method.
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v3:
- Remove DEB_RULES_REQUIRES_ROOT=no again (resent in order to clarify which one should be applied)Thanks, as this variable is supposed to be defined by the build driver (such as dpkg-buildpackage) that calls debian/rules, as covered in the rootless-builds.txt spec.
Quoted 12 lines
scripts/Makefile.package +0
-2@@ -109,8 +109,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian cp $< ../$(orig-name); \ fi -KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' - PHONY += deb-pkg srcdeb-pkg bindeb-pkg
Quoted 10 lines
scripts/Makefile.package deb-pkg srcdeb-pkg bindeb-pkg: · line 126
Quoted 7 lines
scripts/Makefile.package +1
-1deb-pkg: private build-type := source,binary@@ -125,7 +123,7 @@ deb-pkg srcdeb-pkg bindeb-pkg: $(if $(findstring source, $(build-type)), \ --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ $(if $(findstring binary, $(build-type)), \ - -R'$(MAKE) -f debian/rules' -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \Since dpkg 1.14.7, dpkg-buildpackage uses fakeroot if available, so regardless of anything else this removal seems safe.
You are right.
Even without the explicit -r option, fakeroot will be used when dpkg-buildpackage determines it is necessary.
Only a use-case I can come up with is,
the fakeroot command is not installed on the system, and a user may want to do "make bindeb-pkg KBUILD_PKG_ROOTCMD=sudo" as a backup plan.
Anyway, now we always assume "--root-command=none" should work, so -r$(KBUILD_PKG_ROOTCMD) is unneeded.
Quoted 21 lines
Quoted 21 lines
scripts/Makefile.package +0
-0--no-check-builddeps) \ $(DPKG_FLAGS))scripts/package/builddeb +0
-6@@ -36,19 +36,13 @@ create_package() { sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ | xargs -r0 md5sum > DEBIAN/md5sums" - # Fix ownership and permissions - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then - dpkg_deb_opts="--root-owner-group" - else - chown -R root:root "$pdir" - fi # a+rX in case we are in a restrictive umask environment like 0077 # ug-s in case we build in a setuid/setgid directory chmod -R go-w,a+rX,ug-s "$pdir"
Quoted 9 lines
scripts/package/builddeb create_package() { · line 45
Quoted 4 lines
scripts/package/builddeb +1
-1# Create the package dpkg-gencontrol -p$pname -P"$pdir" - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. + dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..If you want to make sure dpkg-deb supports that option, perhaps add «dpkg (>= 1.19.0)» to the package Build-Depends? If that version seems old enough to be assumed to be present, then unconditionally using it seems fine.
Personally, I do not want to list an essential tool in the dependency.
The Debian kernel does not do it either.
Anyway, thank you for your comments.
Quoted 8 lines
scripts/package/builddeb create_package() { · line 48
Quoted 3 lines
scripts/package/builddeb +0
-0} install_linux_image () {Otherwise, the change LGTM.
Thanks,
Guillem
Signature · 2 lines
Best Regards Masahiro Yamada