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}-gnu1.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 # Preserve 'srcdir' in order to produce "buildtree-generic", later
48 keep_srcdir=keep_srcdir
50 unpack "${tardir}/$tarname"
54 # Set sane permissions
55 chmod -R u+w,go-w,a+rX-s .
57 # Support LZIP (Thanks to the friend of the house "Antonio Diaz Diaz")
59 patch -p1 < "${worktree}/patches/kernel/linux-5.10.25_lzip-0.diff"
63 patch -p1 < "${worktree}/patches/kernel/reiser4-for-5.10.2.patch"
69 echo "Copying config-amd64_generic ..."
70 cp -p "${worktree}/archive/kernel/config-amd64_generic" .config
74 echo "Copying config-i586_generic ..."
75 cp -p "${worktree}/archive/kernel/config-i586_generic" .config
79 echo "Copying config-c201-v12 ..."
80 cp -p "${worktree}/archive/kernel/config-c201-v12" .config
84 echo "${0}: No custom configuration file detected for your architecture." 1>&2
89 # An environment variable for config purposes
90 if test ! -z "$PRESERVE"
92 echo "PRESERVE has been set."
96 make -j${jobs} ARCH=$kernel_arch bzImage
97 make -j${jobs} ARCH=$kernel_arch modules
98 make -j${jobs} ARCH=$kernel_arch \
99 INSTALL_MOD_PATH="$destdir" modules_install
101 # To extract the kernel string version
102 strver="$(ls -d "${destdir}"/lib/modules/*)"
103 strver="${strver##*/}"
105 # Install kernel images
106 mkdir -p "${destdir}/boot"
108 cp -p .config "${destdir}/boot/config-generic-${strver}"
109 cp -p System.map "${destdir}/boot/System.map-generic-${strver}"
111 if test -e "arch/${kernel_arch}/boot/bzImage"
113 cp -p "arch/${kernel_arch}/boot/bzImage" \
114 "${destdir}/boot/vmlinuz-generic-${strver}"
115 elif test -e "arch/${kernel_arch}/boot/zImage"
117 cp -p "arch/${kernel_arch}/boot/zImage" \
118 "${destdir}/boot/vmlinuz-generic-${strver}"
120 echo "${0}: No kernel image found: bzImage or zImage" 1>&2
124 # Exclude files from the Graft installation,
125 # this will be copied via post-intall, since
126 # /boot could be a separated partition
127 touch "${destdir}/boot/.nograft"
129 # Insert post-install script manually
131 # This must be recreated on post-installation
132 rm -f "${destdir}"/lib/modules/${strver}/build \
133 "${destdir}"/lib/modules/${strver}/source
135 mkdir -p "${destdir}/var/lib/qi"
136 cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
138 # Kernel string version
141 # Copy kernel image from 'packagedir' to 'rootdir/boot'
143 mkdir -p -- "\${rootdir}/boot"
145 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-generic-${strver}" \\
148 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-generic-${strver}" \\
151 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-generic-${strver}" \\
154 # Make generic symlinks for this kernel version
156 srcdir="${srcdir##*/}"
159 cd lib/modules/${strver} || exit 1
161 ln -sf /usr/src/${srcdir} build
162 ln -sf /usr/src/${srcdir} source
165 # Generate or update the module dependency list
166 chroot "\$rootdir" /sbin/depmod -a $strver