1 # Build instructions for GNU Linux-libre (amd64, generic).
3 # Copyright (c) 2017-2023 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 tarname=${program}-${version}-gnu.tar.lz
30 fetch=http://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu/$tarname
32 homepage=https://www.gnu.org/software/linux-libre
35 The GNU Linux-libre kernel (image and modules for ${arch}).
37 GNU Linux-libre is a project to maintain and publish 100% Free distributions
38 of Linux, suitable for use in Free System Distributions, removing software
39 that is included without source code, with obfuscated or obscured source
40 code, under non-Free Software licenses, that do not permit you to change
41 the software so that it does what you wish, and that induces or requires
42 you to install additional pieces of non-Free Software.
44 This is a custom configuration for Dragora, intended to be generic and work
45 well in all environments.
51 srcdir=linux-${version}
55 unpack "${tardir}/$tarname"
59 # Set sane permissions
60 chmod -R u+w,go-w,a+rX-s .
62 # Support LZIP (Thanks to the friend of the house "Antonio Diaz Diaz")
64 patch -p1 < "${worktree}/patches/kernel/linux-6.1.11_lzip-0.diff"
66 # Support Reiserfs4 (Thanks to "Edward Shishkin")
68 #patch -p1 < "${worktree}/patches/kernel/reiser4-for-5.16.patch"
72 echo "Copying config-amd64_generic ..."
73 cp -p "${worktree}/archive/kernel/config-amd64_generic" .config
75 # An environment variable for config purposes
76 if test ! -z "$PRESERVE"
78 echo "PRESERVE has been set."
82 make -j${jobs} ARCH=x86_64 HOSTCFLAGS="-D_GNU_SOURCE" bzImage
83 make -j${jobs} ARCH=x86_64 HOSTCFLAGS="-D_GNU_SOURCE" modules
84 make -j${jobs} ARCH=x86_64 HOSTCFLAGS="-D_GNU_SOURCE" \
85 INSTALL_MOD_PATH="$destdir" modules_install
87 # To extract the kernel string version
88 strver="$(ls -d "${destdir}"/lib/modules/*)"
89 strver="${strver##*/}"
91 # Install kernel images
92 mkdir -p "${destdir}/boot"
94 cp -p .config "${destdir}/boot/config-${arch}_generic-${strver}"
95 cp -p System.map "${destdir}/boot/System.map-${arch}_generic-${strver}"
97 if test -e "arch/x86_64/boot/bzImage"
99 cp -p "arch/x86_64/boot/bzImage" \
100 "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
101 elif test -e "arch/x86_64/boot/zImage"
103 cp -p "arch/x86_64/boot/zImage" \
104 "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
106 echo "${0}: No kernel image found: bzImage or zImage" 1>&2
110 # Exclude files from the Graft installation,
111 # this will be copied via post-intall, since
112 # /boot could be a separated partition
113 touch "${destdir}/boot/.nograft"
115 # Insert post-install script manually
117 # This must be recreated on post-installation
118 rm -f "${destdir}"/lib/modules/${strver}/build \
119 "${destdir}"/lib/modules/${strver}/source
121 mkdir -p "${destdir}/var/lib/qi"
122 cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
124 # Kernel string version
127 # Copy kernel image from 'packagedir' to 'rootdir/boot'
129 mkdir -p -- "\${rootdir}/boot"
131 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-${arch}_generic-${strver}" \\
134 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-${arch}_generic-${strver}" \\
137 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-${arch}_generic-${strver}" \\
140 # Make generic symlinks for this kernel version
142 srcdir="${srcdir##*/}"
145 cd lib/modules/${strver} || exit 1
147 ln -sf /usr/src/${srcdir} build
148 ln -sf /usr/src/${srcdir} source
151 # Generate or update the module dependency list
152 chroot "\$rootdir" /sbin/depmod -a $strver
156 # Preserve 'srcdir' in order to produce "kernel/buildtree-generic"
157 keep_srcdir=keep_srcdir
159 # Save 'version' and 'release' number to compose
160 # variable values for "kernel/buildtree-generic"
161 kernel_generic_version=$version
162 kernel_generic_release=$release
164 export keep_srcdir kernel_generic_version kernel_generic_release