diff mbox series

[v2,4/6,Unstable] UBUNTU: [Debian] dkms-build -- use fakeroot if not running as root

Message ID 20210604024719.650626-5-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

Some dkms builds require running as root, or at least the illusion of
doing so. However we need to do dkms builds before deleting the
flavour build directory in order to sign the modules, and this may
happen without fakeroot. Detect whether or not dkms-build has been
invoked as root, and if not use fakeroot to do the dkms build.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 debian/scripts/dkms-build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build
index c1751ffaa016..9d78fc60e63f 100755
--- a/debian/scripts/dkms-build
+++ b/debian/scripts/dkms-build
@@ -158,8 +158,10 @@  dkms_version=$( sed -ne 's/PACKAGE_VERSION="\(.*\)"/\1/p' "$dkms_conf" )
 
 # Build the DKMS binaries.
 echo "II: dkms-build building $package"
+fakeroot=""
+[[ $EUID -ne 0 ]] && fakeroot="/usr/bin/fakeroot"
 rc=0
-/usr/sbin/dkms build --no-prepare-kernel --no-clean-kernel \
+$fakeroot /usr/sbin/dkms build --no-prepare-kernel --no-clean-kernel \
 	-k "$abi_flavour" \
 	--sourcetree "$dkms_dir/source" \
 	--dkmstree "$dkms_dir/build" \