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.
21 # Define a category for the output of the package name
24 pkgname=kernel-generic
26 tarname=${program}-libre-${version}-gnu.tar.lz
29 fetch=http://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu/$tarname
31 homepage=http://www.gnu.org/software/linux-libre
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.
44 # Preserve 'srcdir' in order to produce "buildtree-generic", later
45 keep_srcdir=keep_srcdir
49 unpack "${tardir}/$tarname"
53 # Set sane permissions
54 chmod -R u+w,go-w,a+rX-s .
58 patch -p1 < "${worktree}/patches/kernel/linux-5.4.18_lzip-0.diff"
62 patch -p1 < "${worktree}/patches/kernel/reiser4-for-5.4.21.patch"
68 echo "Copying config-amd64_generic ..."
69 cp -p "${worktree}/archive/kernel/config-amd64_generic" .config
73 echo "Copying config-i586_generic ..."
74 cp -p "${worktree}/archive/kernel/config-i586_generic" .config
78 echo "Copying config-c201-v12 ..."
79 cp -p "${worktree}/archive/kernel/config-c201-v12" .config
83 echo "${0}: No custom configuration file detected for your architecture." 1>&2
88 # An environment variable for config purposes
89 if test ! -z "$PRESERVE"
91 echo "PRESERVE has been set."
95 make -j${jobs} ARCH=$kernel_arch bzImage
96 make -j${jobs} ARCH=$kernel_arch modules
97 make -j${jobs} ARCH=$kernel_arch \
98 INSTALL_MOD_PATH="$destdir" modules_install
100 # To extract the kernel string version
101 strver="$(ls -d "${destdir}"/lib/modules/*)"
102 strver="${strver##*/}"
104 # Install kernel images
105 mkdir -p "${destdir}/boot"
107 cp -p .config "${destdir}/boot/config-generic-${strver}"
108 cp -p System.map "${destdir}/boot/System.map-generic-${strver}"
110 if test -e "arch/${kernel_arch}/boot/bzImage"
112 cp -p "arch/${kernel_arch}/boot/bzImage" \
113 "${destdir}/boot/vmlinuz-generic-${strver}"
114 elif test -e "arch/${kernel_arch}/boot/zImage"
116 cp -p "arch/${kernel_arch}/boot/zImage" \
117 "${destdir}/boot/vmlinuz-generic-${strver}"
119 echo "${0}: No kernel image found: bzImage or zImage" 1>&2
123 # Exclude files from the Graft installation,
124 # this will be copied via post-intall, since
125 # /boot could be a separated partition
126 touch "${destdir}/boot/.nograft"
128 # Insert post-install script manually
130 # This must be recreated on post-installation
131 rm -f "${destdir}"/lib/modules/${strver}/build \
132 "${destdir}"/lib/modules/${strver}/source
134 mkdir -p "${destdir}/var/lib/qi"
135 cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
137 # Kernel string version
140 # Copy kernel image from 'packagedir' to 'rootdir/boot'
142 mkdir -p -- "\${rootdir}/boot"
144 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-generic-${strver}" \\
147 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-generic-${strver}" \\
150 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-generic-${strver}" \\
153 # Make generic symlinks for this kernel version
155 srcdir="${srcdir##*/}"
158 cd lib/modules/${strver} || exit 1
160 ln -sf /usr/src/${srcdir} build
161 ln -sf /usr/src/${srcdir} source
164 # Generate or update the module dependency list
165 chroot . /sbin/depmod -a $strver