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

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


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 at canonical.com>
---
 debian/scripts/dkms-build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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" \
-- 
2.31.1




More information about the kernel-team mailing list