Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot "make install" with DESTDIR set #16994

Open
kohlschuetter opened this issue Jan 27, 2025 · 0 comments · May be fixed by #16995
Open

Cannot "make install" with DESTDIR set #16994

kohlschuetter opened this issue Jan 27, 2025 · 0 comments · May be fixed by #16995
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@kohlschuetter
Copy link
Contributor

System information

Distribution Name | Alpine Linux
Distribution Version | 3.21.2
Kernel Version | 6.12.9 (host) 6.12.11 (target)
Architecture | x86_64
OpenZFS Version | 2.3.0 / master

Describe the problem you're observing

"make install" with a specified "DESTDIR=" may fail when installing to a root that contains an existing lib/modules structure, or may do the wrong thing when run as root (because we may affect the running kernel, not the target kernel)

Describe how to reproduce the problem

  1. Build the Linux kernel, install modules into KDIR (e.g., if KDIR=/tmp/kernel-out/, there would be /tmp/kernel-out/lib/modules/6.12.11/, /tmp/kernel-out/boot/System.map-6.12.11 etc.)
  2. Build and install zfs with "DESTDIR=$KDIR make install"

Include any warning/errors/backtraces from the system logs

...
sysmap=/tmp/kernel-out/boot/System.map-6.12.11; \
{ [ -f "$sysmap" ] && [ $(wc -l < "$sysmap") -ge 100 ]; } || \
	sysmap=/tmp/kernel-out/usr/lib/debug/boot/System.map-6.12.11; \
if [ -f $sysmap ]; then \
	depmod -ae -F $sysmap 6.12.11 ; \
fi
depmod: WARNING: could not open modules.order at /tmp/kernel-out/lib/modules/6.12.11: No such file or directory
depmod: WARNING: could not open modules.builtin at /tmp/kernel-out/lib/modules/6.12.11: No such file or directory
depmod: WARNING: could not open modules.builtin.modinfo at /tmp/kernel-out/lib/modules/6.12.11: No such file or directory
...

This is due to the makefile (module/Makefile) explicitly deleting all files starting with modules.* (see "Remove extraneous build products when packaging")

Even after disabling these lines, the installation does not succeed:

...
sysmap=/tmp/kernel-out/boot/System.map-6.12.11; \
{ [ -f "$sysmap" ] && [ $(wc -l < "$sysmap") -ge 100 ]; } || \
	sysmap=/tmp/kernel-out/usr/lib/debug/boot/System.map-6.12.11; \
if [ -f $sysmap ]; then \
	depmod -ae -F $sysmap 6.12.11 ; \
fi
depmod: ERROR: could not open directory /lib/modules/6.12.11: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
...

Here, we try to run depmod on the wrong kernel (the host system's kernel, not the one under DESTDIR / not using the modules in INSTALL_MOD_PATH)

Adding -b $(INSTALL_MOD_PATH) to depmod (INSTALL_MOD_PATH defaults to DESTDIR) does the trick.

@kohlschuetter kohlschuetter added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jan 27, 2025
kohlschuetter added a commit to kohlschuetter/zfs that referenced this issue Jan 27, 2025
"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 openzfs#16994
@kohlschuetter kohlschuetter linked a pull request Jan 27, 2025 that will close this issue
13 tasks
kohlschuetter added a commit to kohlschuetter/zfs that referenced this issue Jan 27, 2025
"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 openzfs#16994
kohlschuetter added a commit to kohlschuetter/zfs that referenced this issue Jan 27, 2025
"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 openzfs#16994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant