qi: Bump to release 2.12
[dragora.git] / recipes / kernel / kmod / recipe
blob28e293bbb201d86054e46c88e8b97a289ecb4d96
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
19 set -e
21 program=kmod
22 version=30
23 release=2
25 # Define a category for the output of the package name
26 pkgcategory=kernel
28 tarname=${program}-${version}.tar.gz
30 # Remote source(s)
31 fetch=https://mirrors.edge.kernel.org/pub/linux/utils/kernel/kmod/$tarname
33 description="
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
38 aliases.
41 homepage=https://git.kernel.org/?p=utils/kernel/kmod/kmod.git
42 license=LGPLv2.1
44 # Source documentation
45 docs="COPYING NEWS README* TODO"
46 docsdir="${docdir}/${program}-${version}"
48 build()
50     unpack "${tardir}/$tarname"
52     cd "$srcdir"
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" \
64      $configure_args \
65      --libdir=/usr/lib${libSuffix} \
66      --infodir=$infodir \
67      --mandir=$mandir \
68      --docdir=$docsdir \
69      --disable-static \
70      --enable-shared \
71      --enable-tools \
72      --with-rootlibdir=/usr/lib${libSuffix} \
73      --with-openssl \
74      --with-zlib \
75      --with-lzlib \
76      --with-xz \
77      --with-zstd \
78      --build="$(gcc -dumpmachine)"
80     make -j${jobs} V=1
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
87     do
88         ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
89     done
91     # For user invocation
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/*
100     do
101         cp -p $file "${destdir}/etc/modprobe.d/"
102         chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
103     done
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"
110     then
111         rm -f "${destdir}/${infodir}/dir"
112         lzip -9 "${destdir}/${infodir}"/*
113     fi
115     # Compress and link man pages (if needed)
116     if test -d "${destdir}/$mandir"
117     then
118         (
119             cd "${destdir}/$mandir"
120             find . -type f -exec lzip -9 {} +
121             find . -type l | while read -r file
122             do
123                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
124                 rm -- "$file"
125             done
126         )
127     fi
129     # Copy documentation
130     mkdir -p "${destdir}/$docsdir"
131     cp -p $docs "${destdir}/$docsdir"