1 # Build recipe for linux-libre (generic).
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.
21 # Set 'outdir' for a nice and well-organized output directory
22 outdir="${outdir}/${arch}/kernel"
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-4.19.8_lzip-0.diff"
64 echo "Copying config-x86_64_generic ..."
65 cp -p "${worktree}/archive/kernel/config-x86_64_generic" .config
69 echo "Copying config-x86_generic ..."
70 cp -p "${worktree}/archive/kernel/config-x86_generic" .config
74 echo "Copying config-armv7a ..."
75 cp -p "${worktree}/archive/kernel/config-armv7a" .config
79 echo "No custom configuration file detected for your architecture." 1>&2
84 # An environment variable for config purposes
85 if test ! -z "$ABORT_FOR_CONFIG"
87 echo "ABORT_FOR_CONFIG has been set."
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"
108 cp -p "arch/${kernel_arch}/boot/bzImage" \
109 "${destdir}/boot/vmlinuz-generic-${strver}"
110 elif test -e "arch/${kernel_arch}/boot/zImage"
112 cp -p "arch/${kernel_arch}/boot/zImage" \
113 "${destdir}/boot/vmlinuz-generic-${strver}"
115 echo "${0}: No kernel image found: bzImage or zImage" 1>&2
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
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}" \\
143 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-generic-${strver}" \\
146 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-generic-${strver}" \\
149 # Make generic symlinks for this kernel version
151 srcdir="${srcdir##*/}"
154 cd lib/modules/${strver} || exit 1
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