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

Fix "make install" with DESTDIR set #16995

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kohlschuetter
Copy link
Contributor

"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

Motivation and Context

Fixes an important build issue when installing to DESTDIR.
see issue #16994

Description

In addition to the details in #16994:

I'm sure there's a reason why the current makefile deletes files starting with "modules.*", so I'm only adding a switch that can disable that functionality when not desired.

With this change, I can now install zfs nto my target root as follows:

DONT_DELETE_MODULES_FILES=1 DESTDIR=/tmp/kernel-out make install

How Has This Been Tested?

Tested on Alpine Linux 3.21.2 using the following zfs build instructions

#KERNEL_DIR=/path/to/kernel/source
#KERNEL_OUT=/path/to/target/root
./configure --prefix=/usr \
			--with-tirpc \
			--sysconfdir=/etc \
			--mandir=/usr/share/man \
			--infodir=/usr/share/info \
			--localstatedir=/var \
			--with-config=kernel \
			--with-linux="$KERNEL_DIR"
make -s -j$(nproc)
DONT_DELETE_MODULES_FILES=1 DESTDIR="$KERNEL_OUT" make install

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

  • My code follows the OpenZFS code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied. (NOTE: unrelated since it's an integration issue)
  • All commit messages are properly formatted and contain Signed-off-by.

"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
@amotin amotin added the Status: Code Review Needed Ready for review and testing label Jan 28, 2025
Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I've had a similar workaround (the -b part) for over a year for my local dev VMs. I have no opinion on the "don't delete" flag other than its useful and nonintrusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot "make install" with DESTDIR set
3 participants