recipes: kernel/generic: Include virtio_scsi to be used in VMs
[dragora.git] / recipes / kernel / generic / i586
blobefaffd5ff41476159e5f34ee695999fae65f7d77
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
18 set -e
20 program=linux-libre
21 version=4.14.305
22 release=2
24 # Define a category for the output of the package name
25 pkgcategory=kernel
27 tarname=${program}-${version}-gnu1.tar.lz
29 # Remote source(s)
30 fetch=https://linux-libre.fsfla.org/pub/linux-libre/releases/${version}-gnu1/$tarname
32 homepage=https://www.gnu.org/software/linux-libre
34 description="
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.
48 license="GPLv2 only"
50 # Refresh 'srcdir'
51 srcdir=linux-${version}
53 build()
55     unpack "${tardir}/$tarname"
57     cd "$srcdir"
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")
67     #
68     # TODO: Needs a re-adaptation
69     #patch -p1 < "${worktree}/patches/kernel/reiser4-for-4.14.1.patch"
71     make mrproper
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"
78     then
79         echo "PRESERVE has been set."
80         exit 99;
81     fi
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"
99     then
100         cp -p "arch/i386/boot/bzImage" \
101               "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
102     elif test -e "arch/i386/boot/zImage"
103     then
104         cp -p "arch/i386/boot/zImage" \
105               "${destdir}/boot/vmlinuz-${arch}_generic-${strver}"
106     else
107         echo "${0}: No kernel image found: bzImage or zImage" 1>&2
108         exit 1;
109     fi
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
126 strver=$strver
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}" \\
133           "\${rootdir}/boot/"
135 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/config-${arch}_generic-${strver}" \\
136           "\${rootdir}/boot/"
138 cp -pf -- "\$rootdir${packagedir}/${full_pkgname}/boot/vmlinuz-${arch}_generic-${strver}" \\
139           "\${rootdir}/boot/"
141 # Make generic symlinks for this kernel version
143 srcdir="${srcdir##*/}"
146     cd lib/modules/${strver} || exit 1
147     rm -f build source
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