]> git.ipfire.org Git - ipfire-3.x.git/blob - kernel/kernel.nm
Merge branch 'master' of ssh://git.ipfire.org/pub/git/ipfire-3.x into grubby
[ipfire-3.x.git] / kernel / kernel.nm
1 ###############################################################################
2 # IPFire.org - An Open Source Firewall Solution #
3 # Copyright (C) - IPFire Development Team <info@ipfire.org> #
4 ###############################################################################
5
6 name = kernel
7 version = 3.0.4
8 release = 8
9 thisapp = linux-%{version}
10
11 maintainer = Michael Tremer <michael.tremer@ipfire.org>
12 groups = System/Kernels
13 url = http://www.kernel.org/
14 license = GPLv2
15 summary = The Linux kernel.
16
17 description
18 The kernel package contains the Linux kernel (vmlinuz), the core of any \
19 Linux operating system. The kernel handles the basic functions \
20 of the operating system: memory allocation, process allocation, device \
21 input and output, etc.
22 end
23
24 # Version helper variables.
25 localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH}
26 fullver = %{version}-%{localversion}
27
28 sources = %{thisapp}.tar.gz
29
30 build
31 # icecream cannot be used to compile the kernel.
32 # Because the PaX patch does use GCC plugins to harden the kernel which
33 # are not available on the remote compilers, we need to disable it here.
34 export ICECC=no
35
36 requires
37 binutils-devel
38 elfutils-devel
39 module-init-tools
40 ncurses-devel
41 net-tools
42 newt-devel
43 perl
44 python-devel
45 slang-devel
46 xz-lzma-compat
47 end
48
49 # A list of kernels to build.
50 kernels = default
51
52 if "%{DISTRO_ARCH}" == "i686"
53 # Build a PAE-enabled kernel for the i686 architecture.
54 kernels += PAE
55
56 kernel_arch = x86
57 kernel_image = arch/%{kernel_arch}/boot/bzImage
58 kernel_target = bzImage
59 end
60
61 prepare_cmds
62 rm -f %{DIR_APP}/localversion-grsec
63
64 sed -e "s/^HOSTCFLAGS.*=.*/& -fPIC/g" -i Makefile
65
66 cp -vf %{DIR_SOURCE}/%{DISTRO_SNAME}_logo.ppm \
67 drivers/video/logo/logo_linux_clut224.ppm
68
69 # Get rid of unwanted files resulting from patch fuzz.
70 find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
71
72 # Remove unnecessary SCM files.
73 find . -name .gitignore -exec rm -f {} \; >/dev/null
74
75 # This prevents scripts/setlocalversion from mucking with our version numbers.
76 touch .scmversion
77
78 mkdir -pv configs
79 configure_kernel() {
80 local flavour=${1}
81 local suffix
82 if [ "${flavour}" != "default" ]; then
83 suffix="-${flavour}"
84 fi
85
86 # This is the place, where the configuration files
87 # should be dynamically generated.
88 # For now, we just copy pregenerated ones.
89 cp %{DIR_SOURCE}/config.%{arch}${suffix} .config
90
91 make ARCH=%{kernel_arch} oldnoconfig
92 mv .config configs/config.${flavour}
93 }
94
95 # Generate configuration files for all kernels we are going to
96 # build.
97 for kernel in %{kernels}; do
98 configure_kernel ${kernel}
99 done
100 end
101
102 build
103 build_kernel() {
104 local flavour=${1}
105 local suffix
106 local localversion="%{localversion}"
107 local fullversion="%{fullver}"
108 if [ "${flavour}" != "default" ]; then
109 suffix="-${flavour}"
110 localversion="${localversion}.${flavour}"
111 fullversion="${fullversion}.${flavour}"
112 fi
113
114 # Label the build.
115 sed -i Makefile \
116 -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/"
117
118 # Clean up the source tree.
119 make mrproper
120
121 # Install configuration file.
122 cp configs/config.${flavour} .config
123
124 # Run the build.
125 make ARCH=%{kernel_arch} oldnoconfig >/dev/null
126 make ARCH=%{kernel_arch} CC="gcc -fno-PIE" %{kernel_target} modules %{PARALLELISMFLAGS}
127
128 # Install the results.
129 mkdir -pv %{BUILDROOT}/boot %{BUILDROOT}/lib/modules/${fullversion}
130 install -m 755 %{kernel_image} %{BUILDROOT}/boot/vmlinuz-${fullversion}
131 install -m 644 .config %{BUILDROOT}/boot/config-${fullversion}
132 install -m 644 System.map %{BUILDROOT}/boot/System.map-${fullversion}
133
134 # Create empty initramfs (20M).
135 dd if=/dev/zero of=%{BUILDROOT}/boot/initramfs-${fullversion}.img bs=1M count=20
136
137 # Install modules.
138 make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT} mod-fw= \
139 KERNELRELEASE=${fullversion} modules_install
140 #make ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{BUILDROOT} \
141 # KERNELRELEASE=${fullversion} vdso_install
142
143 # Create an empty settings file for dracut
144 mkdir -pv %{BUILDROOT}/etc/ld.so.conf.d
145 echo "# Placeholder file, no vDSO hwcap entries used in this kernel." \
146 > %{BUILDROOT}/etc/ld.so.conf.d/kernel-${fullversion}.conf
147
148 # And now the scary looking part.
149 #
150 # Recreate source and build links.
151 rm -vf %{BUILDROOT}/lib/modules/${fullversion}/{build,source}
152 mkdir -pv %{BUILDROOT}/lib/modules/${fullversion}/build
153 ln -svf build %{BUILDROOT}/lib/modules/${fullversion}/source
154
155 # Create dirs for extra modules.
156 mkdir -pv %{BUILDROOT}/lib/modules/${fullversion}/extra
157
158 cp -v --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") \
159 %{BUILDROOT}/lib/modules/${fullversion}/build
160 cp -v Module.symvers System.map \
161 %{BUILDROOT}/lib/modules/${fullversion}/build
162 rm -vrf %{BUILDROOT}/lib/modules/${fullversion}/build/{Documentation,scripts,include}
163
164 cp -v .config %{BUILDROOT}/lib/modules/${fullversion}/build
165 cp -va scripts %{BUILDROOT}/lib/modules/${fullversion}/build
166 find %{BUILDROOT}/lib/modules/${fullversion}/build/scripts -name "*.o" \
167 -exec rm -vf {} \;
168
169 cp -va --parents arch/%{kernel_arch}/include \
170 %{BUILDROOT}/lib/modules/${fullversion}/build
171 cp -va include %{BUILDROOT}/lib/modules/${fullversion}/build/include
172
173 # Make sure we can build external modules.
174 touch -r %{BUILDROOT}/lib/modules/${fullversion}/build/Makefile \
175 %{BUILDROOT}/lib/modules/${fullversion}/build/include/linux/version.h
176 touch -r %{BUILDROOT}/lib/modules/${fullversion}/build/.config \
177 %{BUILDROOT}/lib/modules/${fullversion}/build/autoconf.h
178 cp -v %{BUILDROOT}/lib/modules/${fullversion}/build/.config \
179 %{BUILDROOT}/lib/modules/${fullversion}/build/include/config/auto.conf
180
181 find %{BUILDROOT}/lib/modules/${fullversion} -name "*.ko" -type f | \
182 xargs chmod u+x
183
184 # Move all development files to /usr/src.
185 mkdir -pv %{BUILDROOT}/usr/src/kernels
186 mv -v %{BUILDROOT}/lib/modules/${fullversion}/build \
187 %{BUILDROOT}/usr/src/kernels/${fullversion}
188 ln -svf ../../../usr/src/kernels/${fullversion} \
189 %{BUILDROOT}/lib/modules/${fullversion}/build
190
191 find %{BUILDROOT}/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
192 }
193
194 for kernel in %{kernels}; do
195 build_kernel ${kernel}
196 done
197 end
198
199 install
200 # Install the header files
201 make ARCH=x86 INSTALL_HDR_PATH=dest headers_install
202 mkdir -pv %{BUILDROOT}/usr/include
203 find dest/include \( -name .install -o -name ..install.cmd \) -delete
204 cp -rv dest/include/* %{BUILDROOT}/usr/include
205
206 # Glibc provides these headers
207 rm -rfv %{BUILDROOT}/usr/include/scsi \
208 %{BUILDROOT}/usr/include/asm*/atomic.h \
209 %{BUILDROOT}/usr/include/asm*/io.h \
210 %{BUILDROOT}/usr/include/asm*/irq.h
211
212 # Remove all firmware files which are distributed by linux-firmware
213 rm -rfv %{BUILDROOT}/lib/firmware
214
215 # Install tools.
216 # XXX Man pages cannot be created because they need asciidoc.
217 make -C tools/perf DESTDIR=%{BUILDROOT} \
218 HAVE_CPLUS_DEMANGLE=1 prefix=/usr perfexecdir=lib/perf-core \
219 install #install-man
220 end
221 end
222
223 packages
224 template KERNEL
225 kernel_release = %{fullver}
226
227 summary = The Linux kernel %{kernel_release}.
228
229 prerequires = module-init-tools
230 provides = kernel
231 requires
232 dracut
233 linux-firmware
234 end
235
236 files
237 /boot/System.map-%{kernel_release}
238 /boot/vmlinuz-%{kernel_release}
239 /boot/initramfs-%{kernel_release}.img
240 /etc/ld.so.conf.d/kernel-%{kernel_release}.conf
241 /lib/modules/%{kernel_release}
242 end
243
244 script posttransin
245 dracut --force /boot/initramfs-%{kernel_release}.img %{kernel_release}
246 end
247 end
248
249 template KERNELDEVEL
250 kernel_release = %{fullver}
251
252 summary = Development files of kernel-%{kernel_release}.
253 description
254 %{summary}
255
256 Install this package in order to compile modules for
257 kernel release %{kernel_release}.
258 end
259
260 filter_requires
261 perl>=[0-9]\:.*
262 end
263
264 files
265 /lib/modules/%{kernel_release}/build
266 /lib/modules/%{kernel_release}/source
267 /usr/src/kernels/%{kernel_release}
268 end
269 end
270
271 package kernel
272 template KERNEL
273
274 kernel_release = %{fullver}
275 end
276
277 package kernel-devel
278 template KERNELDEVEL
279
280 kernel_release = %{fullver}
281 end
282
283 package kernel-PAE
284 template KERNEL
285
286 kernel_release = %{fullver}.PAE
287 end
288
289 package kernel-PAE-devel
290 template KERNELDEVEL
291
292 kernel_release = %{fullver}.PAE
293 end
294
295 package kernel-headers
296 summary = Header files of the kernel release %{fullver}.
297 desciption = %{summary}
298
299 files
300 /usr/include
301 end
302 end
303
304 package kernel-tools
305 summary = Assortment of tools for the Linux kernel.
306 description = %{summary}
307
308 filter_requires
309 perl>=[0-9]\:.*
310 end
311
312 files
313 /
314 !/boot
315 !/lib/modules
316 !/usr/include
317 !/usr/src
318 end
319 end
320 end