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