Skip to content

packaging: install kernel modules under /usr/lib/modules - #120

Open
Bjordis Collaku (bjordiscollaku) wants to merge 1 commit into
mainfrom
fix/usr-lib-modules
Open

Bjordis Collaku (bjordiscollaku) wants to merge 1 commit into
mainfrom
fix/usr-lib-modules

Conversation

@bjordiscollaku

@bjordiscollaku Bjordis Collaku (bjordiscollaku) commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Closes #119

Policy 10.1 (since 4.7.1) says packages must not install into /bin, /lib or /sbin. The image package still put its modules, the build and source links, and the bundled DKMS modules under /lib/modules.

kbuild hardcodes MODLIB to $(INSTALL_MOD_PATH)/lib/modules, so the build keeps installing there and dh_movetousr moves the staged files into /usr afterwards, the same way Debian's linux package does. It also rewrites the build and source links into the relative form Policy 10.5 wants.

The move is hooked on execute_after_dh_installdeb on purpose. dh_installmodules only scans lib/modules when it adds the depmod snippet (same in debhelper 13.24.2 and 14.3), and it runs from override_dh_installdeb, so moving any earlier, including through dh-sequence-movetousr, would drop that snippet without an error.

Debug symbols stay at /usr/lib/debug/lib/modules, which is already under /usr and is where crash and systemtap look.

Validation so far:

Build is green on trixie, forky and resolute, all five legs plus the S3 publishes. Checked the resulting packages from the resolute build: nothing is left under ./lib, the modules, extra/msm_kgsl.ko and modules.dep are at ./usr/lib/modules//, build and source point at ../../../src/linux-headers-, and the debug package is unchanged at ./usr/lib/debug/lib/modules/. The build log also shows dh_installmodules running before dh_movetousr, so the depmod snippet is still generated from the lib/modules layout.

Debian Policy 10.1, since 4.7.1, says packages must not install files
into /bin, /lib or /sbin, which are symlinks into /usr on merged-/usr
systems. The image package installed its modules, their build and
source links, and the bundled DKMS modules under /lib/modules.

kbuild hardcodes MODLIB to $(INSTALL_MOD_PATH)/lib/modules, so keep
installing there and move the staged files with dh_movetousr, as
Debian's own linux package does. dh_movetousr also rewrites the
absolute build and source links into the relative form Policy 10.5
requires.

The move runs from execute_after_dh_installdeb rather than at its usual
place. dh_installmodules, called from override_dh_installdeb, only
scans lib/modules when it adds the depmod maintainer script snippet, so
moving the modules before it would silently drop that snippet. The
dh-sequence-movetousr addon would run the helper too early for the
same reason.

Build-depend on debhelper 13.11.9, the first release where
dh_movetousr also rewrites links pointing into aliased directories.

Nothing moves between binary packages, so the DEP17 file loss case
(P1) does not apply, and base-files ships the /lib symlink on trixie,
forky and resolute, so /lib/modules keeps resolving on the target.

Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install kernel modules under /usr/lib/modules

1 participant