8.67. Kmod-34.1

The Kmod package contains libraries and utilities for loading kernel modules

Approximate build time: less than 0.1 SBU
Required disk space: 11 MB

8.67.1. Installation of Kmod

Create the PKGBUILD for the Kmod package with the following commands:

mkdir /sources/kmod
cd /sources/kmod
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="kmod"
pkgver="34.1"
pkgrel="1"
pkgdesc="The Kmod package contains libraries and utilities for loading kernel modules."
arch=('x86'
      'x86_64')
url="https://github.com/kmod-project/kmod"
license=('LGPLv2.1')
groups=('core')
depends=('glibc'
         'xz'
         'zlib'
         'rootfs')
makedepends=('bash'
             'binutils'
             'bison'
             'coreutils'
             'flex'
             'gcc'
             'gettext'
             'gzip'
             'make'
             'pkg-config'
             'sed')
source=('https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-34.1.tar.xz')
md5sums=('bdc01ba7d330685af597c16c5f58c0e2')
    
prepare(){
  cd "${pkgname}-${pkgver}"
  mkdir -p build
  cd       build
}

build(){
  cd "${pkgname}-${pkgver}/build"
  meson setup --prefix=/usr ..    \
              --sbindir=/usr/sbin \
              --buildtype=release \
              -D manpages=false
  ninja
}

check(){
  cd "${pkgname}-${pkgver}/build"
  # Do nothing as the test suite depends on raw kernel headers
  # A "linux-source" package would make sense here
  echo ""
}

package(){
  cd "${pkgname}-${pkgver}/build"
  DESTDIR="${pkgdir}" ninja install
}
REALEOF

The meaning of the configure options:

-D manpages=false

This option disables generating the man pages which requires an external program.

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps --nocheck'

Add the newly created package to the central package repository:

cp kmod-34.1-1-$(uname -m).pkg.tar.xz \                           /srv/pacman/repos/LFS/                                                                                               repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \                                                                                   /srv/pacman/repos/LFS/kmod-34.1-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Kmod package:

pacman -Syu
pacman -S kmod --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/kmod
cp PKGBUILD /srv/pacman/source/LFS/kmod
cd /sources
rm -rf kmod

8.67.2. Contents of Kmod

Installed programs: depmod (link to kmod), insmod (link to kmod), kmod, lsmod (link to kmod), modinfo (link to kmod), modprobe (link to kmod), and rmmod (link to kmod)
Installed library: libkmod.so

Short Descriptions

depmod

Creates a dependency file based on the symbols it finds in the existing set of modules; this dependency file is used by modprobe to automatically load the required modules

insmod

Installs a loadable module in the running kernel

kmod

Loads and unloads kernel modules

lsmod

Lists currently loaded modules

modinfo

Examines an object file associated with a kernel module and displays any information that it can glean

modprobe

Uses a dependency file, created by depmod, to automatically load relevant modules

rmmod

Unloads modules from the running kernel

libkmod

This library is used by other programs to load and unload kernel modules