]> git.ipfire.org Git - ipfire-3.x.git/blame - 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
CommitLineData
166a6c21 1###############################################################################
802ea3af
MT
2# IPFire.org - An Open Source Firewall Solution #
3# Copyright (C) - IPFire Development Team <info@ipfire.org> #
166a6c21
MT
4###############################################################################
5
15a11c5b
MT
6name = kernel
7version = 3.0.4
20bc7289 8release = 8
15a11c5b 9thisapp = linux-%{version}
166a6c21 10
802ea3af
MT
11maintainer = Michael Tremer <michael.tremer@ipfire.org>
12groups = System/Kernels
13url = http://www.kernel.org/
14license = GPLv2
15summary = The Linux kernel.
166a6c21 16
802ea3af 17description
166a6c21
MT
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.
802ea3af 22end
166a6c21 23
802ea3af 24# Version helper variables.
bcf38aec
MT
25localversion = %{release}.%{DISTRO_DISTTAG}.%{DISTRO_ARCH}
26fullver = %{version}-%{localversion}
802ea3af 27
15a11c5b 28sources = %{thisapp}.tar.gz
802ea3af
MT
29
30build
ebeed08a
MT
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
802ea3af 36 requires
bcf38aec
MT
37 binutils-devel
38 elfutils-devel
802ea3af
MT
39 module-init-tools
40 ncurses-devel
ebeed08a 41 net-tools
bcf38aec 42 newt-devel
802ea3af 43 perl
bcf38aec 44 python-devel
ebeed08a 45 slang-devel
bcf38aec
MT
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
802ea3af
MT
59 end
60
61 prepare_cmds
802ea3af
MT
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
bcf38aec
MT
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
ebeed08a
MT
75 # This prevents scripts/setlocalversion from mucking with our version numbers.
76 touch .scmversion
77
bcf38aec
MT
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
802ea3af 90
bcf38aec
MT
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
802ea3af
MT
100 end
101
102 build
bcf38aec
MT
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
802ea3af 113
ebeed08a
MT
114 # Label the build.
115 sed -i Makefile \
116 -e "s/^EXTRAVERSION.*/EXTRAVERSION = -${localversion}/"
117
bcf38aec
MT
118 # Clean up the source tree.
119 make mrproper
802ea3af 120
bcf38aec
MT
121 # Install configuration file.
122 cp configs/config.${flavour} .config
802ea3af 123
bcf38aec 124 # Run the build.
ebeed08a 125 make ARCH=%{kernel_arch} oldnoconfig >/dev/null
bcf38aec
MT
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
802ea3af 142
bcf38aec
MT
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
802ea3af 147
bcf38aec
MT
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
802ea3af 154
bcf38aec
MT
155 # Create dirs for extra modules.
156 mkdir -pv %{BUILDROOT}/lib/modules/${fullversion}/extra
802ea3af 157
bcf38aec
MT
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
bcf38aec
MT
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
802ea3af
MT
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
15a11c5b
MT
212 # Remove all firmware files which are distributed by linux-firmware
213 rm -rfv %{BUILDROOT}/lib/firmware
bcf38aec
MT
214
215 # Install tools.
ebeed08a
MT
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
802ea3af
MT
220 end
221end
222
223packages
bcf38aec
MT
224 template KERNEL
225 kernel_release = %{fullver}
226
227 summary = The Linux kernel %{kernel_release}.
228
229 prerequires = module-init-tools
230 provides = kernel
802ea3af
MT
231 requires
232 dracut
233 linux-firmware
234 end
ad1ea534 235
bcf38aec
MT
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
ad1ea534 244 script posttransin
bcf38aec
MT
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]\:.*
ad1ea534
MT
262 end
263
bcf38aec
MT
264 files
265 /lib/modules/%{kernel_release}/build
266 /lib/modules/%{kernel_release}/source
267 /usr/src/kernels/%{kernel_release}
ad1ea534 268 end
802ea3af 269 end
bcf38aec
MT
270
271 package kernel
272 template KERNEL
58dc2060
MT
273
274 kernel_release = %{fullver}
bcf38aec
MT
275 end
276
277 package kernel-devel
278 template KERNELDEVEL
58dc2060
MT
279
280 kernel_release = %{fullver}
bcf38aec
MT
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
ebeed08a 294
802ea3af 295 package kernel-headers
802ea3af
MT
296 summary = Header files of the kernel release %{fullver}.
297 desciption = %{summary}
c698e4be
MT
298
299 files
300 /usr/include
301 end
802ea3af 302 end
bcf38aec 303
ebeed08a
MT
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
802ea3af 320end