1 # Build instructions for GNU Linux-libre (i586+, generic).
3 # Copyright (c) 2022-2024 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}-gnu1.tar.lz
30 fetch=https://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu1/$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, which is for uni-processors,
45 is intended to be or run on Intel 586 family (MMX) machines or higher.
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-4.14.40_lzip-3.diff"
66 # Support Reiserfs4 (Thanks to "Edward Shishkin")
68 # TODO: Needs a re-adaptation
69 #patch -p1 < "${worktree}/patches/kernel/reiser4-for-4.14.1.patch"
73 echo "Copying config-i586_generic ..."
74 cp -p "${worktree}/archive/kernel/config-i586_generic" .config
76 # An environment variable for config purposes
77 if test ! -z "$PRESERVE"
79 echo "PRESERVE has been set."
83 make -j${jobs} ARCH=i386 HOSTCFLAGS="-D_GNU_SOURCE" bzImage
84 make -j${jobs} ARCH=i386 HOSTCFLAGS="-D_GNU_SOURCE" modules
85 make -j${jobs} ARCH=i386 HOSTCFLAGS="-D_GNU_SOURCE" \
86 INSTALL_MOD_PATH="$destdir" modules_install
88 # To extract the kernel string version
89 strver="$(ls -d "${destdir}"/lib/modules/*)"
90 strver="${strver##*/}"
92 # Install kernel images
93 mkdir -p "${destdir}/boot"
95 cp -p .config "${destdir}/boot/config-${arch}_generic-${strver}"
96 cp -p System.map "${destdir}/boot/System.map-${arch}_generic-${strver}"
98 if test -e "arch/i386/boot/bzImage"
100 cp -p "arch/i386/boot/bzImage" \
101 "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
102 elif test -e "arch/i386/boot/zImage"
104 cp -p "arch/i386/boot/zImage" \
105 "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
107 echo "${0}: No kernel image found: bzImage or zImage" 1>&2
111 # Exclude files from the Graft installation,
112 # this will be copied via post-intall, since
113 # /boot could be a separated partition
114 touch "${destdir}/boot/.nograft"
116 # Insert post-install script manually
118 # This must be recreated on post-installation
119 rm -f "${destdir}"/lib/modules/${strver}/build \
120 "${destdir}"/lib/modules/${strver}/source
122 mkdir -p "${destdir}/var/lib/qi"
123 cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
125 # Kernel string version
128 # Copy kernel image from 'packagedir' to 'rootdir/boot'
130 mkdir -p -- "\${rootdir}/boot"
132 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/System.map-${arch}_generic-${strver}" \\
135 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-${arch}_generic-${strver}" \\
138 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-${arch}_generic-${strver}" \\
141 # Make generic symlinks for this kernel version
143 srcdir="${srcdir##*/}"
146 cd lib/modules/${strver} || exit 1
148 ln -sf /usr/src/${srcdir} build
149 ln -sf /usr/src/${srcdir} source
152 # Generate or update the module dependency list
153 chroot "\$rootdir" /sbin/depmod -a $strver
157 # Preserve 'srcdir' in order to produce "kernel/buildtree-generic"
158 keep_srcdir=keep_srcdir
160 # Save 'version' and 'release' number to compose
161 # variable values for "kernel/buildtree-generic"
162 kernel_generic_version=$version
163 kernel_generic_release=$release
165 export keep_srcdir kernel_generic_version kernel_generic_release