1 # Build recipe for kmod.
3 # Copyright (c) 2017-2019 Matias Fonzo, <selk@dragora.org>.
4 # Copyright (c) 2021-2023 Matias Fonzo, <selk@dragora.org>.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # Exit immediately on any error
25 # Define a category for the output of the package name
28 tarname=${program}-${version}.tar.gz
31 fetch=https://mirrors.edge.kernel.org/pub/linux/utils/kernel/kmod/$tarname
34 Linux kernel module handling.
36 kmod is a set of tools to handle common tasks with Linux kernel modules
37 like insert, remove, list, check properties, resolve dependencies and
41 homepage=https://git.kernel.org/?p=utils/kernel/kmod/kmod.git
44 # Source documentation
45 docs="COPYING NEWS README* TODO"
46 docsdir="${docdir}/${program}-${version}"
50 unpack "${tardir}/$tarname"
54 # Add support for Kernel modules compressed with LZIP
55 patch -p1 < "${worktree}/patches/kmod/kmod-30_lzip-1.diff"
57 # Set sane permissions
58 chmod -R u+w,go-w,a+rX-s .
60 # --enable-static is not supported by kmod
62 ./configure CPPFLAGS="$QICPPFLAGS" \
63 CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
65 --libdir=/usr/lib${libSuffix} \
72 --with-rootlibdir=/usr/lib${libSuffix} \
78 --build="$(gcc -dumpmachine)"
81 make -j${jobs} DESTDIR="$destdir" install-strip
83 # Make symlinks for compatibility
85 mkdir -p "${destdir}/usr/sbin"
86 for target in depmod insmod lsmod modinfo modprobe rmmod
88 ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
92 ( cd "${destdir}/usr/bin" && ln -sf ../bin/kmod lsmod )
94 # Prepare directories / files for modprobe
96 mkdir -p "${destdir}/usr/lib${libSuffix}/modprobe.d" \
97 "${destdir}/etc/modprobe.d"
99 for file in "${worktree}"/archive/kmod/etc/modprobe.d/*
101 cp -p $file "${destdir}/etc/modprobe.d/"
102 chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
105 # To manage (dot) new files
106 touch "${destdir}/etc/modprobe.d/.graft-config"
108 # Compress info documents deleting index file for the package
109 if test -d "${destdir}/$infodir"
111 rm -f "${destdir}/${infodir}/dir"
112 lzip -9 "${destdir}/${infodir}"/*
115 # Compress and link man pages (if needed)
116 if test -d "${destdir}/$mandir"
119 cd "${destdir}/$mandir"
120 find . -type f -exec lzip -9 {} +
121 find . -type l | while read -r file
123 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
130 mkdir -p "${destdir}/$docsdir"
131 cp -p $docs "${destdir}/$docsdir"