recipes: Rename 'pkghashtag' variable to 'pkgcategory'
[dragora.git] / recipes / kernel / kmod / recipe
blobd025a4a66bded2967b9e4e4f9515c9f3ed0b65a1
1 # Build recipe for kmod.
3 # Copyright (c) 2017-2019 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.
17 program=kmod
18 version=26
19 release=1
21 # Define a category for the output of the package name
22 pkgcategory=kernel
24 tarname=${program}-${version}.tar.gz
26 # Remote source(s)
27 fetch=http://www.kernel.org/pub/linux/utils/kernel/kmod/$tarname
29 description="
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
34 aliases.
37 homepage=http://git.kernel.org/?p=utils/kernel/kmod/kmod.git
38 license=LGPLv2.1
40 # Source documentation
41 docs="COPYING NEWS README TODO"
42 docsdir="${docdir}/${program}-${version}"
44 build()
46     set -e
48     unpack "${tardir}/$tarname"
50     cd "$srcdir"
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-26_lzip-0.diff"
58     autoreconf -vif
60     # --enable-static is not supported by kmod
62     ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
63      lzlib_LIBS="-llz" lzlib_CFLAGS="-llz" \
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-zlib \
74      --with-lzlib \
75      --without-xz \
76      --build="$(cc -dumpmachine)"
78     make -j${jobs} V=1
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
85     do
86         ( cd "${destdir}/usr/sbin" && ln -sf ../bin/kmod $target )
87     done
89     # For user invocation
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/*
97     do
98         cp -p $file "${destdir}/etc/modprobe.d/"
99         chmod 644 "${destdir}/etc/modprobe.d/${file##*/}"
100     done
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"
107     then
108         rm -f "${destdir}/${infodir}/dir"
109         lzip -9 "${destdir}/${infodir}"/*
110     fi
112     # Compress and link man pages (if needed)
113     if test -d "${destdir}/$mandir"
114     then
115         (
116             cd "${destdir}/$mandir"
117             find . -type f -exec lzip -9 '{}' +
118             find . -type l | while read -r file
119             do
120                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
121                 rm -- "$file"
122             done
123         )
124     fi
126     # Copy documentation
127     mkdir -p "${destdir}${docsdir}"
128     cp -p $docs "${destdir}${docsdir}"