Skip to content

Commit d2147de

Browse files
Fix "make install" with DESTDIR set (#16995)
"DESTDIR=/path/to/target/root/ make install" may fail when installing to a root that contains an existing lib/modules structure. When run as root we may even affect the wrong kernel (the build system's one, or, if running a different version, some other directory in /lib/modules, but not the desired one installed in DESTDIR). Add a missing reference to the INSTALL_MOD_PATH root when calling "depmod" during "make install" Also add a switch "DONT_DELETE_MODULES_FILES=1" that skips the removal of files named "modules.*" prior to running depmod. Signed-off-by: Christian Kohlschütter <[email protected]> Closes #16994 Reviewed-by: Rob Norris <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Hutter <[email protected]>
1 parent c2458ba commit d2147de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

module/Makefile.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ modules_install-Linux: modules_uninstall-Linux-legacy
9393
$(if @KERNEL_ARCH@,ARCH=@KERNEL_ARCH@) \
9494
KERNELRELEASE=@LINUX_VERSION@
9595
@# Remove extraneous build products when packaging
96-
if [ -n "$(DESTDIR)" ]; then \
96+
if [ -n "$(DESTDIR)" ] && [ "$(DONT_DELETE_MODULES_FILES)" != "1" ]; then \
9797
find $(KMODDIR) -name 'modules.*' -delete; \
9898
fi
9999
@# Debian ships tiny fake System.map files that are
@@ -106,7 +106,7 @@ modules_install-Linux: modules_uninstall-Linux-legacy
106106
{ [ -f "$$sysmap" ] && [ $$(wc -l < "$$sysmap") -ge 100 ]; } || \
107107
sysmap=$(INSTALL_MOD_PATH)/usr/lib/debug/boot/System.map-@LINUX_VERSION@; \
108108
if [ -f $$sysmap ]; then \
109-
depmod -ae -F $$sysmap @LINUX_VERSION@; \
109+
depmod -ae -F $$sysmap @LINUX_VERSION@ -b $(INSTALL_MOD_PATH)/; \
110110
fi
111111

112112
modules_install-FreeBSD:

0 commit comments

Comments
 (0)