39.15. kmod-34.2
Libraries and utilities for loading kernel modules
| Version | 34.2, release 4 |
| Shelf | base — The minimal userland and system daemons that every KDOS image boots with |
| Phase | 30_foundation (Build Foundation), 76 of 127 in build order |
| Licence | LGPL-2.1-or-later AND GPL-2.0-or-later |
| Homepage | https://github.com/kmod-project/kmod |
| Build time | 0.1 SBU |
| Installed size | 478.5 KiB in 35 files |
| Recipe | ports/core/base/kmod/kpkgbuild |
About
kmod loads and unloads kernel modules. It is one program, /usr/bin/kmod, and modprobe, insmod, rmmod, lsmod, modinfo and depmod are links to it; libkmod is the library behind them. On KDOS, eudev links libkmod to load the driver for each device it sees, the 02_modules boot script loads the lists in /etc/modules-load.d, and the initramfs carries kmod as modprobe, insmod and depmod and runs depmod over the modules it copies (see The initramfs). The linux port depends on it.
Sources
kmod-34.2.tar.xz(433.3 KiB)
sha2565a5d5073070cc7e0c7a7a3c6ec2a0e1780850c8b47b3e3892226b93ffcb9cb54
upstream: https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-34.2.tar.xz
archive copy: sources-1/base--kmod-34.2.tar.xz
Dependencies
Depends on: xz, zlib, zstd, scdoc.
Required by (6): eudev, libblockdev, linux, ndctl, nvme-cli, pciutils.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
--without-openssl, line 20: openssl (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
relative-tool-links.patch— Changes the install hook inMakefile.inthat links the tools tokmod. Upstream runs$(LN_S) --force --relativefrom$(DESTDIR)$(bindir)/kmod; the patch writes each link with the literal relative target../bin/kmod, which is what/usr/sbin/modprobeand the others point to on an installed system.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install kmod'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base/kmod.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/base/kmod
echo '5a5d5073070cc7e0c7a7a3c6ec2a0e1780850c8b47b3e3892226b93ffcb9cb54 kmod-34.2.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/kmod
SRC=$SRC_ROOT/kmod-34.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf kmod-34.2.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/relative-tool-links.patch"
CFLAGS="$CFLAGS -include libgen.h" \
./configure --prefix=/usr \
--sysconfdir=/etc \
--with-xz \
--with-zstd \
--with-zlib \
--without-openssl
make
make DESTDIR=$PKG install
The switches, and why each is set:
-include libgen.h— Include<libgen.h>ahead of every source file, configure’s tests among them. configure checks whetherbasenameis declared after<string.h>; musl declares it only in<libgen.h>, so without this the answer is no and kmod defines its ownbasenameinshared/missing.h. With it the answer is yes, and kmod calls musl’s POSIXbasename(), which takes a non-const string: the compiler warns about discardedconstqualifiers indepmod.c,util.candlibkmod-config.c.--with-xz,--with-zstd,--with-zlib— Read modules compressed with xz, zstd or gzip. Each is off by default, and each, once asked for, stops configure if pkg-config cannot find its library. The kernel’s own modules are compressed with zstd (CONFIG_in the linux port’sMODULE_ COMPRESS_ ZSTD kdos.config), anddepmodandmodinfomust decompress a module to read it.--without-openssl— Build without libcrypto, upstream’s default. kmod uses it only to decode the PKCS#7 signature appended to a module. The linux port signs every module (CONFIG_turns onSECURITY_ LOCKDOWN_ LSM CONFIG_), soMODULE_ SIG modinfodoes find a signature: it reportssig_id: PKCS#7andsig_hashalgo: unknown, and leaves the signer, key and signature fields empty. Loading is unaffected, because the kernel verifies the signature itself (see Module signing).
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/kmod, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf kmod-34.2-4.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/kmod, and runs the triggers its paths call for.
Contents
Installed programs: depmod, insmod, kmod, lsmod, modinfo, modprobe, rmmod.
Installed libraries: libkmod.so.
Installed directories: /usr/share/fish/vendor_functions.d, /usr/share/licenses/kmod.
Short descriptions
depmod |
Generate modules.dep and map files. |
insmod |
Simple program to insert a module into the Linux Kernel |
kmod |
Program to manage Linux Kernel modules |
lsmod |
Show the status of modules in the Linux Kernel |
modinfo |
Show information about a Linux Kernel module |
modprobe |
Add and remove modules from the Linux Kernel |
rmmod |
Simple program to remove a module from the Linux Kernel |
kmod.pc |
Tools to deal with kernel modules |
libkmod.pc |
Library to deal with kernel modules |
Notes
The manual pages are written in scdoc, and configure stops when scdoc is missing unless --disable-manpages is passed; that is why the recipe depends on scdoc.
musl’s basename() writes into its argument when the path ends in /, stripping the slashes in place; kmod’s own replacement only reads it. The warnings about discarded const mark the calls that pass a string kmod treats as read-only. Adding or removing -include libgen.h changes which of the two functions every kmod program calls.