Skip to content

Commit

Permalink
Fix "make install" with DESTDIR set (#16995)
Browse files Browse the repository at this point in the history
"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]>
  • Loading branch information
kohlschuetter authored Feb 8, 2025
1 parent c2458ba commit d2147de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions module/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ modules_install-Linux: modules_uninstall-Linux-legacy
$(if @KERNEL_ARCH@,ARCH=@KERNEL_ARCH@) \
KERNELRELEASE=@LINUX_VERSION@
@# Remove extraneous build products when packaging
if [ -n "$(DESTDIR)" ]; then \
if [ -n "$(DESTDIR)" ] && [ "$(DONT_DELETE_MODULES_FILES)" != "1" ]; then \
find $(KMODDIR) -name 'modules.*' -delete; \
fi
@# Debian ships tiny fake System.map files that are
Expand All @@ -106,7 +106,7 @@ modules_install-Linux: modules_uninstall-Linux-legacy
{ [ -f "$$sysmap" ] && [ $$(wc -l < "$$sysmap") -ge 100 ]; } || \
sysmap=$(INSTALL_MOD_PATH)/usr/lib/debug/boot/System.map-@LINUX_VERSION@; \
if [ -f $$sysmap ]; then \
depmod -ae -F $$sysmap @LINUX_VERSION@; \
depmod -ae -F $$sysmap @LINUX_VERSION@ -b $(INSTALL_MOD_PATH)/; \
fi

modules_install-FreeBSD:
Expand Down

0 comments on commit d2147de

Please sign in to comment.