Skip to content

Commit 3e85418

Browse files
guillemjmasahir0y
authored andcommitted
builddeb: Enable rootless builds
This makes it possible to build the Debian packages without requiring (pseudo-)root privileges, when the build drivers support this mode of operation. See-Also: /usr/share/doc/dpkg/rootless-builds.txt.gz Signed-off-by: Guillem Jover <guillem@hadrons.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 51ccdbf commit 3e85418

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

scripts/package/builddeb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if_enabled_echo() {
2626

2727
create_package() {
2828
local pname="$1" pdir="$2"
29+
local dpkg_deb_opts
2930

3031
mkdir -m 755 -p "$pdir/DEBIAN"
3132
mkdir -p "$pdir/usr/share/doc/$pname"
@@ -36,14 +37,18 @@ create_package() {
3637
| xargs -r0 md5sum > DEBIAN/md5sums"
3738

3839
# Fix ownership and permissions
39-
chown -R root:root "$pdir"
40+
if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then
41+
dpkg_deb_opts="--root-owner-group"
42+
else
43+
chown -R root:root "$pdir"
44+
fi
4045
chmod -R go-w "$pdir"
4146
# in case we are in a restrictive umask environment like 0077
4247
chmod -R a+rX "$pdir"
4348

4449
# Create the package
4550
dpkg-gencontrol -p$pname -P"$pdir"
46-
dpkg-deb ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
51+
dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
4752
}
4853

4954
deploy_kernel_headers () {

scripts/package/mkdebian

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Source: $sourcename
174174
Section: kernel
175175
Priority: optional
176176
Maintainer: $maintainer
177+
Rules-Requires-Root: no
177178
Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends
178179
Homepage: https://www.kernel.org/
179180

0 commit comments

Comments
 (0)