recipes: Rename 'pkghashtag' variable to 'pkgcategory'
[dragora.git] / recipes / kernel / generic / recipe
blobf8d8932da84ffe5ca3a0eb096e320745da5fb5b5
1 # Build recipe for linux-libre (generic).
3 # Copyright (c) 2017-2020 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=linux
18 version=5.4.28
19 release=1
21 # Define a category for the output of the package name
22 pkgcategory=kernel
24 pkgname=kernel-generic
26 tarname=${program}-libre-${version}-gnu.tar.lz
28 # Remote source(s)
29 fetch=http://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu/$tarname
31 homepage=http://www.gnu.org/software/linux-libre
33 description="
34 The Linux kernel image and modules.
36 This is a generic configuration for the Linux kernel
37 which intends to run well in all environments.
40 license="GPLv2 only"
42 build()
44     # Preserve 'srcdir' in order to produce "buildtree-generic", later
45     keep_srcdir=keep_srcdir
47     set -e
49     unpack "${tardir}/$tarname"
51     cd "$srcdir"
53     # Set sane permissions
54     chmod -R u+w,go-w,a+rX-s .
56     # Support LZIP
58     patch -p1 < "${worktree}/patches/kernel/linux-5.4.18_lzip-0.diff"
60     make mrproper
62     case $arch in
63     x86_64)
64         echo "Copying config-x86_64_generic ..."
65         cp -p "${worktree}/archive/kernel/config-x86_64_generic" .config
66         kernel_arch=x86_64
67         ;;
68     i?86)
69         echo "Copying config-x86_generic ..."
70         cp -p "${worktree}/archive/kernel/config-x86_generic" .config
71         kernel_arch=i386
72         ;;
73     armv7a)
74         echo "Copying config-armv7a ..."
75         cp -p "${worktree}/archive/kernel/config-armv7a" .config
76         kernel_arch=arm
77         ;;
78     *)
79         echo "No custom configuration file detected for your architecture." 1>&2
80         exit 1;
81         ;;
82     esac
84     # An environment variable for config purposes
85     if test ! -z "$PRESERVE"
86     then
87         echo "PRESERVE has been set."
88         exit 99;
89     fi
91     make -j${jobs} ARCH=$kernel_arch bzImage
92     make -j${jobs} ARCH=$kernel_arch modules
93     make -j${jobs} ARCH=$kernel_arch \
94      INSTALL_MOD_PATH="$destdir" modules_install
96     # To extract the kernel string version
97     strver="$(ls -d "${destdir}"/lib/modules/*)"
98     strver="${strver##*/}"
100     # Install kernel images
101     mkdir -p "${destdir}/boot"
103     cp -p .config "${destdir}/boot/config-generic-${strver}"
104     cp -p System.map "${destdir}/boot/System.map-generic-${strver}"
106     if test -e "arch/${kernel_arch}/boot/bzImage"
107     then
108         cp -p "arch/${kernel_arch}/boot/bzImage" \
109               "${destdir}/boot/vmlinuz-generic-${strver}"
110     elif test -e "arch/${kernel_arch}/boot/zImage"
111     then
112         cp -p "arch/${kernel_arch}/boot/zImage" \
113               "${destdir}/boot/vmlinuz-generic-${strver}"
114     else
115         echo "${0}: No kernel image found: bzImage or zImage" 1>&2
116         exit 1;
117     fi
119     # Exclude files from the Graft installation,
120     # this will be copied via post-intall, since
121     # /boot could be a separated partition
122     touch "${destdir}/boot/.nograft"
124     # Insert post-install script manually
126     # This must be recreated on post-installation
127     rm -f "${destdir}"/lib/modules/${strver}/build \
128           "${destdir}"/lib/modules/${strver}/source
130     mkdir -p "${destdir}/var/lib/qi"
131     cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
133 # Kernel string version
134 strver=$strver
136 # Copy kernel image from 'packagedir' to 'rootdir/boot'
138 mkdir -p -- "\${rootdir}/boot"
140 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-generic-${strver}" \\
141           "\${rootdir}/boot/"
143 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-generic-${strver}" \\
144           "\${rootdir}/boot/"
146 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-generic-${strver}" \\
147           "\${rootdir}/boot/"
149 # Make generic symlinks for this kernel version
151 srcdir="${srcdir##*/}"
154     cd lib/modules/${strver} || exit 1
155     rm -f build source
156     ln -sf /usr/src/${srcdir} build
157     ln -sf /usr/src/${srcdir} source
160 # Generate or update the module dependency list
161 chroot . /sbin/depmod -a $strver