1 # Build recipe for kmod.
3 # Copyright (c) 2017-2018 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
21 # Set 'outdir' for a nice and well-organized output directory
22 outdir="${outdir}/${arch}/kernel"
24 tarname=${program}-${version}.tar.gz
27 fetch=http://www.kernel.org/pub/linux/utils/kernel/kmod/$tarname
30 Linux kernel module handling.
32 kmod is a set of tools to handle common tasks with Linux kernel modules
33 like insert, remove, list, check properties, resolve dependencies and
37 homepage=http://git.kernel.org/?p=utils/kernel/kmod/kmod.git
40 # Source documentation
41 docs="COPYING NEWS README TODO"
42 docsdir="${docdir}/${program}-${version}"
48 unpack "${tardir}/$tarname"
52 # Set sane permissions
53 chmod -R u+w,go-w,a+rX-s .
55 # Add support for kernel modules compressed with LZIP
56 patch -p1 < "${worktree}/patches/kmod/kmod-25_lzip-0.diff"
60 # --enable-static is not supported by kmod
62 ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
63 lzlib_LIBS="-llz" lzlib_CFLAGS="-llz" \
65 --libdir=/usr/lib${libSuffix} \
72 --with-rootlibdir=/usr/lib${libSuffix} \
76 --build="$(cc -dumpmachine)"
79 make -j${jobs} DESTDIR="$destdir" install-strip
81 # Make symlinks for compatibility
83 mkdir -p "${destdir}/usr/sbin"
84 for target in depmod insmod lsmod modinfo modprobe rmmod
86 ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
90 ( cd "${destdir}/usr/bin" && ln -sf ../bin/kmod lsmod )
92 # Prepare directories / files for modprobe
94 mkdir -p "${destdir}/lib/modprobe.d" "${destdir}/etc/modprobe.d"
96 for file in "${worktree}"/archive/kmod/etc/modprobe.d/*
98 cp -p $file "${destdir}/etc/modprobe.d/"
99 chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
102 # To manage (dot) new files
103 touch "${destdir}/etc/modprobe.d/.graft-config"
105 # Compress info documents deleting index file for the package
106 if test -d "${destdir}/$infodir"
108 rm -f "${destdir}/${infodir}/dir"
109 lzip -9 "${destdir}/${infodir}"/*
112 # Compress and link man pages (if needed)
113 if test -d "${destdir}/$mandir"
116 cd "${destdir}/$mandir"
117 find . -type f -exec lzip -9 '{}' +
118 find . -type l | while read -r file
120 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
127 mkdir -p "${destdir}${docsdir}"
128 cp -p $docs "${destdir}${docsdir}"