1 # Build recipe for linux-libre (generic).
3 # Copyright (c) 2017-2022 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 # Exit immediately on any error
24 # Define a category for the output of the package name
27 pkgname=kernel-generic
29 tarname=${program}-libre-${version}-gnu.tar.lz
32 fetch=https://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu/$tarname
34 homepage=https://www.gnu.org/software/linux-libre
37 The Linux kernel image and modules.
39 This is a generic configuration for the Linux kernel
40 which intends to run well in all environments.
47 unpack "${tardir}/$tarname"
51 # Set sane permissions
52 chmod -R u+w,go-w,a+rX-s .
54 # Support LZIP (Thanks to the friend of the house "Antonio Diaz Diaz")
56 patch -p1 < "${worktree}/patches/kernel/linux-5.16.11_lzip-0.diff"
58 # Support Reiserfs4 (Thanks to "Edward Shishkin")
60 patch -p1 < "${worktree}/patches/kernel/reiser4-for-5.16.patch"
66 echo "Copying config-amd64_generic ..."
67 cp -p "${worktree}/archive/kernel/config-amd64_generic" .config
71 echo "Copying config-i586_generic ..."
72 cp -p "${worktree}/archive/kernel/config-i586_generic" .config
76 echo "Copying config-c201-v12 ..."
77 cp -p "${worktree}/archive/kernel/config-c201-v12" .config
81 echo "${0}: No custom configuration file detected for your architecture." 1>&2
86 # An environment variable for config purposes
87 if test ! -z "$PRESERVE"
89 echo "PRESERVE has been set."
93 make -j${jobs} ARCH=$kernel_arch bzImage
94 make -j${jobs} ARCH=$kernel_arch modules
95 make -j${jobs} ARCH=$kernel_arch \
96 INSTALL_MOD_PATH="$destdir" modules_install
98 # To extract the kernel string version
99 strver="$(ls -d "${destdir}"/lib/modules/*)"
100 strver="${strver##*/}"
102 # Install kernel images
103 mkdir -p "${destdir}/boot"
105 cp -p .config "${destdir}/boot/config-generic-${strver}"
106 cp -p System.map "${destdir}/boot/System.map-generic-${strver}"
108 if test -e "arch/${kernel_arch}/boot/bzImage"
110 cp -p "arch/${kernel_arch}/boot/bzImage" \
111 "${destdir}/boot/vmlinuz-generic-${strver}"
112 elif test -e "arch/${kernel_arch}/boot/zImage"
114 cp -p "arch/${kernel_arch}/boot/zImage" \
115 "${destdir}/boot/vmlinuz-generic-${strver}"
117 echo "${0}: No kernel image found: bzImage or zImage" 1>&2
121 # Exclude files from the Graft installation,
122 # this will be copied via post-intall, since
123 # /boot could be a separated partition
124 touch "${destdir}/boot/.nograft"
126 # Insert post-install script manually
128 # This must be recreated on post-installation
129 rm -f "${destdir}"/lib/modules/${strver}/build \
130 "${destdir}"/lib/modules/${strver}/source
132 mkdir -p "${destdir}/var/lib/qi"
133 cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
135 # Kernel string version
138 # Copy kernel image from 'packagedir' to 'rootdir/boot'
140 mkdir -p -- "\${rootdir}/boot"
142 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-generic-${strver}" \\
145 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-generic-${strver}" \\
148 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-generic-${strver}" \\
151 # Make generic symlinks for this kernel version
153 srcdir="${srcdir##*/}"
156 cd lib/modules/${strver} || exit 1
158 ln -sf /usr/src/${srcdir} build
159 ln -sf /usr/src/${srcdir} source
162 # Generate or update the module dependency list
163 chroot "\$rootdir" /sbin/depmod -a $strver
167 # Preserve 'srcdir' in order to produce "kernel/buildtree-generic"
168 keep_srcdir=keep_srcdir
170 # Set ID for the recipe that will produce the package with the build tree
171 kernel_generic_has_been_built=kernel_generic_has_been_built
173 export keep_srcdir kernel_generic_has_been_built