1 |
|
2 |
%define kernelversion 3 |
3 |
%define patchlevel 4 |
4 |
# sublevel is now used for -stable patches |
5 |
%define sublevel 24 |
6 |
|
7 |
# kernel Makefile extraversion is substituted by |
8 |
# kpatch/kgit wich are either 0 (empty), rc (kpatch), git (kgit) |
9 |
%define kpatch 0 |
10 |
|
11 |
# kernel.org -gitX patch (only the number after "git") |
12 |
%define kgit 0 |
13 |
|
14 |
# this is the releaseversion |
15 |
%define mgarelease 2 |
16 |
|
17 |
# This is only to make life easier for people that creates derivated kernels |
18 |
# a.k.a name it kernel-tmb :) |
19 |
%define kname kernel-linus |
20 |
|
21 |
%define rpmtag %{distsuffix}%{mgaver} |
22 |
%if %kpatch |
23 |
%if %kgit |
24 |
%define rpmrel %mkrel 0.%{kpatch}.%{kgit}.%{mgarelease} |
25 |
%else |
26 |
%define rpmrel %mkrel 0.%{kpatch}.%{mgarelease} |
27 |
%endif |
28 |
%else |
29 |
%define rpmrel %mkrel %{mgarelease} |
30 |
%endif |
31 |
|
32 |
# theese two never change, they are used to fool rpm/urpmi/smart |
33 |
%define fakever 1 |
34 |
%define fakerel %mkrel 1 |
35 |
|
36 |
# When we are using a pre/rc patch, the tarball is a sublevel -1 |
37 |
%if %kpatch |
38 |
%define kversion %{kernelversion}.%{patchlevel}.%{sublevel} |
39 |
%if %sublevel |
40 |
%define tar_ver %{kernelversion}.%{patchlevel} |
41 |
%else |
42 |
%define tar_ver %{kernelversion}.%(expr %{patchlevel} - 1) |
43 |
%endif |
44 |
%else |
45 |
%define kversion %{kernelversion}.%{patchlevel}.%{sublevel} |
46 |
%define tar_ver %{kernelversion}.%{patchlevel} |
47 |
%endif |
48 |
%define kverrel %{kversion}-%{rpmrel} |
49 |
|
50 |
# used for not making too long names for rpms or search paths |
51 |
%if %kpatch |
52 |
%if %kgit |
53 |
%define buildrpmrel 0.%{kpatch}.%{kgit}.%{mgarelease}%{rpmtag} |
54 |
%else |
55 |
%define buildrpmrel 0.%{kpatch}.%{mgarelease}%{rpmtag} |
56 |
%endif |
57 |
%else |
58 |
%define buildrpmrel %{mgarelease}%{rpmtag} |
59 |
%endif |
60 |
|
61 |
%define buildrel %{kversion}-%{buildrpmrel} |
62 |
|
63 |
%define klinus_notice NOTE: This kernel has no Mageia patches and no third-party drivers. |
64 |
|
65 |
# having different top level names for packges means that you have to remove them by hard :( |
66 |
%define top_dir_name %{kname}-%{_arch} |
67 |
|
68 |
%define build_dir ${RPM_BUILD_DIR}/%{top_dir_name} |
69 |
%define src_dir %{build_dir}/linux-%{tar_ver} |
70 |
|
71 |
# disable useless debug rpms... |
72 |
%define _enable_debug_packages %{nil} |
73 |
%define debug_package %{nil} |
74 |
|
75 |
# build defines |
76 |
%define build_doc 1 |
77 |
%define build_source 1 |
78 |
%define build_devel 1 |
79 |
|
80 |
%define build_kernel 1 |
81 |
|
82 |
%define distro_branch %(perl -pe '/(\\d+)\\.(\\d)\\.?(\\d)?/; $_="$1.$2"' /etc/mageia-release) |
83 |
|
84 |
# End of user definitions |
85 |
%{?_without_kernel: %global build_kernel 0} |
86 |
%{?_without_doc: %global build_doc 0} |
87 |
%{?_without_source: %global build_source 0} |
88 |
%{?_without_devel: %global build_devel 0} |
89 |
|
90 |
%{?_with_kernel: %global build_kernel 1} |
91 |
%{?_with_doc: %global build_doc 1} |
92 |
%{?_with_source: %global build_source 1} |
93 |
%{?_with_devel: %global build_devel 1} |
94 |
|
95 |
%if %(if [ -z "$CC" ] ; then echo 0; else echo 1; fi) |
96 |
%define kmake %make CC="$CC" |
97 |
%else |
98 |
%define kmake %make |
99 |
%endif |
100 |
# there are places where parallel make don't work |
101 |
%define smake make |
102 |
|
103 |
# Parallelize xargs invocations on smp machines |
104 |
%define kxargs xargs %([ -z "$RPM_BUILD_NCPUS" ] \\\ |
105 |
&& RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\ |
106 |
[ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-P $RPM_BUILD_NCPUS") |
107 |
|
108 |
# Aliases for amd64 builds (better make source links?) |
109 |
%define target_cpu %(echo %{_target_cpu} | sed -e "s/amd64/x86_64/") |
110 |
%define target_arch %(echo %{_arch} | sed -e "s/amd64/x86_64/" -e 's/arm.*/arm/') |
111 |
|
112 |
# src.rpm description |
113 |
Summary: The Linux kernel (the core of the Linux operating system) |
114 |
Name: %{kname} |
115 |
Version: %{kversion} |
116 |
Release: %{rpmrel} |
117 |
License: GPLv2 |
118 |
Group: System/Kernel and hardware |
119 |
ExclusiveArch: %{ix86} x86_64 %{arm} |
120 |
ExclusiveOS: Linux |
121 |
URL: http://www.kernel.org/ |
122 |
|
123 |
#################################################################### |
124 |
# |
125 |
# Sources |
126 |
# |
127 |
### This is for full SRC RPM |
128 |
Source0: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/linux-%{tar_ver}.tar.xz |
129 |
Source1: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/linux-%{tar_ver}.tar.sign |
130 |
|
131 |
# This is for disabling mrproper and other targets on -devel rpms |
132 |
Source2: disable-mrproper-in-devel-rpms.patch |
133 |
|
134 |
Source4: README.kernel-sources |
135 |
|
136 |
# Kernel defconfigs |
137 |
Source20: i386_defconfig |
138 |
Source21: x86_64_defconfig |
139 |
Source22: arm_defconfig |
140 |
|
141 |
#################################################################### |
142 |
# |
143 |
# Patches |
144 |
|
145 |
# |
146 |
# Patch0 to Patch100 are for core kernel upgrades. |
147 |
# |
148 |
|
149 |
# Pre linus patch: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing |
150 |
|
151 |
%if %sublevel |
152 |
Patch1: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kversion}.xz |
153 |
Source11: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/patch-%{kversion}.sign |
154 |
%endif |
155 |
%if %kpatch |
156 |
Patch2: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing/patch-%{kernelversion}.%{patchlevel}-%{kpatch}.xz |
157 |
Source12: ftp://ftp.kernel.org/pub/linux/kernel/v%{kernelversion}.%{patchlevel}/testing/patch-%{kernelversion}.%{patchlevel}-%{kpatch}.sign |
158 |
%endif |
159 |
|
160 |
#END |
161 |
#################################################################### |
162 |
|
163 |
# Defines for the things that are needed for all the kernels |
164 |
%define requires1 kmod >= 7-7 |
165 |
%define requires2 dracut >= 017-16.1 |
166 |
%define requires3 bootloader-utils >= 1.9 |
167 |
%define requires4 sysfsutils |
168 |
%define requires5 kernel-firmware >= 20111229-1 |
169 |
|
170 |
%define kprovides kernel = %{tar_ver}, alsa |
171 |
|
172 |
%define kconflicts dkms-broadcom-wl < 5.100.82.112-6, dkms-fglrx < 8.961-2, dkms-nvidia173 < 173.14.36-1, dkms-nvidia96xx < 96.43.23-2 |
173 |
|
174 |
Autoreqprov: no |
175 |
BuildRequires: gcc kmod >= 7-7 |
176 |
%ifarch %{arm} |
177 |
BuildRequires: uboot-mkimage |
178 |
%endif |
179 |
|
180 |
%description |
181 |
Source package to build the Linux kernel. |
182 |
|
183 |
%{klinus_notice} |
184 |
|
185 |
|
186 |
# |
187 |
# kernel: Symmetric MultiProcessing kernel |
188 |
# |
189 |
%if %build_kernel |
190 |
%package -n %{kname}-%{buildrel} |
191 |
Version: %{fakever} |
192 |
Release: %{fakerel} |
193 |
%ifarch %{ix86} |
194 |
Summary: Linux Kernel for desktop use with i586 & 4GB RAM |
195 |
%else |
196 |
%ifarch %{arm} |
197 |
Linux Kernel for Arm machines based on Kirkwood |
198 |
%else |
199 |
Summary: Linux Kernel for desktop use with %{_arch} |
200 |
%endif |
201 |
%endif |
202 |
Group: System/Kernel and hardware |
203 |
Provides: %kprovides |
204 |
Provides: should-restart = system |
205 |
Requires: %requires1 |
206 |
Requires: %requires2 |
207 |
Requires: %requires3 |
208 |
Requires: %requires4 |
209 |
Requires: %requires5 |
210 |
Conflicts: %kconflicts |
211 |
|
212 |
%ifarch %{ix86} |
213 |
Conflicts: arch(x86_64) |
214 |
%endif |
215 |
|
216 |
%description -n %{kname}-%{buildrel} |
217 |
%ifarch %{ix86} |
218 |
This kernel is compiled for desktop use, single or multiple i586 |
219 |
processor(s)/core(s) and less than 4GB RAM, using HZ_1000, voluntary |
220 |
preempt, CFS cpu scheduler and cfq i/o scheduler. |
221 |
This kernel relies on in-kernel smp alternatives to switch between |
222 |
up & smp mode depending on detected hardware. To force the kernel |
223 |
to boot in single processor mode, use the "nosmp" boot parameter. |
224 |
%else |
225 |
%ifarch %{arm} |
226 |
This kernel is compiled for Arm Kirkwood boxes. It will run on openrd |
227 |
boards. It's configured using HZ_100, preempt, CFS cpu scheduler and |
228 |
cfq i/o scheduler. |
229 |
This kernel relies on in-kernel smp alternatives to switch between |
230 |
up & smp mode depending on detected hardware. To force the kernel |
231 |
to boot in single processor mode, use the "nosmp" boot parameter. |
232 |
%else |
233 |
This kernel is compiled for desktop use, single or multiple %{_arch} |
234 |
processor(s)/core(s), using HZ_1000, voluntary preempt, CFS cpu |
235 |
scheduler and cfq i/o scheduler. |
236 |
This kernel relies on in-kernel smp alternatives to switch between |
237 |
up & smp mode depending on detected hardware. To force the kernel |
238 |
to boot in single processor mode, use the "nosmp" boot parameter. |
239 |
%endif |
240 |
%endif |
241 |
|
242 |
%{klinus_notice} |
243 |
%endif # build_kernel |
244 |
|
245 |
|
246 |
# |
247 |
# kernel-source: kernel sources |
248 |
# |
249 |
%if %build_source |
250 |
%package -n %{kname}-source-%{buildrel} |
251 |
Version: %{fakever} |
252 |
Release: %{fakerel} |
253 |
Provides: %{kname}-source, kernel-source = %{kverrel} |
254 |
Provides: %{kname}-source-%{kernelversion}.%{patchlevel} |
255 |
Requires: glibc-devel, ncurses-devel, make, gcc, perl, diffutils |
256 |
Summary: The source code for the Linux kernel |
257 |
Group: Development/Kernel |
258 |
Autoreqprov: no |
259 |
Buildarch: noarch |
260 |
|
261 |
%description -n %{kname}-source-%{buildrel} |
262 |
The %{kname}-source package contains the source code files for the |
263 |
Linux kernel. Theese source files are only needed if you want to build |
264 |
your own custom kernel that is better tuned to your particular hardware. |
265 |
|
266 |
If you only want the files needed to build 3rdparty (nVidia, Ati, dkms-*,...) |
267 |
drivers against, install the *-devel-* rpm that is matching your kernel. |
268 |
|
269 |
%{klinus_notice} |
270 |
%endif #build_source |
271 |
|
272 |
|
273 |
# |
274 |
# kernel-devel: stripped kernel sources |
275 |
# |
276 |
%if %build_devel |
277 |
%package -n %{kname}-devel-%{buildrel} |
278 |
Version: %{fakever} |
279 |
Release: %{fakerel} |
280 |
Provides: kernel-devel = %{kverrel} |
281 |
Summary: The %{kname} devel files for 3rdparty modules build |
282 |
Group: Development/Kernel |
283 |
Autoreqprov: no |
284 |
Requires: glibc-devel, ncurses-devel, make, gcc, perl |
285 |
%ifarch %{ix86} |
286 |
Conflicts: arch(x86_64) |
287 |
%endif |
288 |
|
289 |
%description -n %{kname}-devel-%{buildrel} |
290 |
This package contains the kernel-devel files that should be enough to build |
291 |
3rdparty drivers against for use with the %{kname}-%{buildrel}. |
292 |
|
293 |
If you want to build your own kernel, you need to install the full |
294 |
%{kname}-source-%{buildrel} rpm. |
295 |
|
296 |
%{klinus_notice} |
297 |
%endif #build_devel |
298 |
|
299 |
|
300 |
# |
301 |
# kernel-doc: documentation for the Linux kernel |
302 |
# |
303 |
%if %build_doc |
304 |
%package -n %{kname}-doc |
305 |
Version: %{kversion} |
306 |
Release: %{rpmrel} |
307 |
Summary: Various documentation bits found in the kernel source |
308 |
Group: Books/Computer books |
309 |
Buildarch: noarch |
310 |
|
311 |
%description -n %{kname}-doc |
312 |
This package contains documentation files form the kernel source. Various |
313 |
bits of information about the Linux kernel and the device drivers shipped |
314 |
with it are documented in these files. You also might want install this |
315 |
package if you need a reference to the options that can be passed to Linux |
316 |
kernel modules at load time. |
317 |
|
318 |
%{klinus_notice} |
319 |
%endif #build_doc |
320 |
|
321 |
|
322 |
# |
323 |
# kernel-latest: virtual rpm |
324 |
# |
325 |
%if %build_kernel |
326 |
%package -n %{kname}-latest |
327 |
Version: %{kversion} |
328 |
Release: %{rpmrel} |
329 |
Summary: Virtual rpm for latest %{kname} |
330 |
Group: System/Kernel and hardware |
331 |
Requires: %{kname}-%{buildrel} |
332 |
%ifarch %{ix86} |
333 |
Conflicts: arch(x86_64) |
334 |
%endif |
335 |
|
336 |
%description -n %{kname}-latest |
337 |
This package is a virtual rpm that aims to make sure you always have the |
338 |
latest %{kname} installed... |
339 |
|
340 |
%{klinus_notice} |
341 |
%endif #build_kernel |
342 |
|
343 |
|
344 |
# |
345 |
# kernel-source-latest: virtual rpm |
346 |
# |
347 |
%if %build_source |
348 |
%package -n %{kname}-source-latest |
349 |
Version: %{kversion} |
350 |
Release: %{rpmrel} |
351 |
Summary: Virtual rpm for latest %{kname}-source |
352 |
Group: System/Kernel and hardware |
353 |
Requires: %{kname}-source-%{buildrel} |
354 |
Buildarch: noarch |
355 |
|
356 |
%description -n %{kname}-source-latest |
357 |
This package is a virtual rpm that aims to make sure you always have the |
358 |
latest %{kname}-source installed... |
359 |
|
360 |
%{klinus_notice} |
361 |
%endif #build_source |
362 |
|
363 |
|
364 |
# |
365 |
# kernel-devel-latest: virtual rpm |
366 |
# |
367 |
%if %build_devel |
368 |
%package -n %{kname}-devel-latest |
369 |
Version: %{kversion} |
370 |
Release: %{rpmrel} |
371 |
Summary: Virtual rpm for latest %{kname}-devel |
372 |
Group: System/Kernel and hardware |
373 |
Requires: %{kname}-devel-%{buildrel} |
374 |
%ifarch %{ix86} |
375 |
Conflicts: arch(x86_64) |
376 |
%endif |
377 |
|
378 |
%description -n %{kname}-devel-latest |
379 |
This package is a virtual rpm that aims to make sure you always have the |
380 |
latest %{kname}-devel installed... |
381 |
|
382 |
%{klinus_notice} |
383 |
%endif #build_devel |
384 |
|
385 |
|
386 |
# |
387 |
# End packages - here begins build stage |
388 |
# |
389 |
%prep |
390 |
%setup -q -n %top_dir_name -c |
391 |
|
392 |
pushd %src_dir |
393 |
|
394 |
%if %sublevel |
395 |
%patch1 -p1 |
396 |
%endif |
397 |
%if %kpatch |
398 |
%patch2 -p1 |
399 |
%endif |
400 |
|
401 |
popd |
402 |
|
403 |
# PATCH END |
404 |
|
405 |
|
406 |
# |
407 |
# Setup Begin |
408 |
# |
409 |
|
410 |
|
411 |
# Install defconfigs... |
412 |
install %{SOURCE20} %{build_dir}/linux-%{tar_ver}/arch/x86/configs/ |
413 |
install %{SOURCE21} %{build_dir}/linux-%{tar_ver}/arch/x86/configs/ |
414 |
install %{SOURCE22} %{build_dir}/linux-%{tar_ver}/arch/arm/configs/ |
415 |
|
416 |
# make sure the kernel has the sublevel we know it has... |
417 |
LC_ALL=C perl -p -i -e "s/^SUBLEVEL.*/SUBLEVEL = %{sublevel}/" linux-%{tar_ver}/Makefile |
418 |
|
419 |
|
420 |
%build |
421 |
# Common target directories |
422 |
%define _bootdir /boot |
423 |
%define _modulesdir /lib/modules |
424 |
%define _kerneldir /usr/src/%{kname}-%{buildrel} |
425 |
%define _develdir /usr/src/%{kname}-devel-%{buildrel} |
426 |
|
427 |
|
428 |
# Directories definition needed for building |
429 |
%define temp_root %{build_dir}/temp-root |
430 |
%define temp_boot %{temp_root}%{_bootdir} |
431 |
%define temp_modules %{temp_root}%{_modulesdir} |
432 |
%define temp_source %{temp_root}%{_kerneldir} |
433 |
%define temp_devel %{temp_root}%{_develdir} |
434 |
|
435 |
|
436 |
# Create a simulacro of buildroot |
437 |
rm -rf %{temp_root} |
438 |
install -d %{temp_root} |
439 |
|
440 |
|
441 |
# make sure we are in the directory |
442 |
cd %{src_dir} |
443 |
|
444 |
# make sure EXTRAVERSION says what we want it to say |
445 |
LC_ALL=C perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{buildrpmrel}/" Makefile |
446 |
|
447 |
# Prepare the kernel |
448 |
%smake -s mrproper |
449 |
%ifarch %{ix86} x86_64 |
450 |
cp arch/x86/configs/%{target_arch}_defconfig .config |
451 |
%else |
452 |
cp arch/%{target_arch}/%{target_arch}_defconfig .config |
453 |
%endif |
454 |
%smake oldconfig |
455 |
|
456 |
# Build the kernel |
457 |
%kmake -s all |
458 |
%ifarch %{arm} |
459 |
%kmake uImage |
460 |
%endif |
461 |
# Install kernel |
462 |
install -d %{temp_boot} |
463 |
install -m 644 System.map %{temp_boot}/System.map-%{buildrel} |
464 |
install -m 644 .config %{temp_boot}/config-%{buildrel} |
465 |
%ifarch %{arm} |
466 |
cp -f arch/%{target_arch}/boot/uImage %{temp_boot}/uImage-$KernelVer |
467 |
%else |
468 |
cp -f arch/%{target_arch}/boot/bzImage %{temp_boot}/vmlinuz-%{buildrel} |
469 |
%endif |
470 |
|
471 |
# Install modules |
472 |
install -d %{temp_modules}/%{buildrel} |
473 |
%smake INSTALL_MOD_PATH=%{temp_root} KERNELRELEASE=%{buildrel} modules_install |
474 |
|
475 |
# remove /lib/firmware, we use a separate kernel-firmware |
476 |
rm -rf %{temp_root}/lib/firmware |
477 |
|
478 |
# Save devel tree |
479 |
%if %build_devel |
480 |
mkdir -p %{temp_devel} |
481 |
for i in $(find . -name 'Makefile*'); do cp -R --parents $i %{temp_devel};done |
482 |
for i in $(find . -name 'Kconfig*' -o -name 'Kbuild*' -o -name config.mk); do cp -R --parents $i %{temp_devel};done |
483 |
cp -fR include %{temp_devel} |
484 |
cp -fR scripts %{temp_devel} |
485 |
cp -fR tools/include %{temp_devel}/tools/ |
486 |
%ifarch %{arm} |
487 |
cp -fR arch/%{target_arch}/tools $TempDevelRoot/arch/%{target_arch}/ |
488 |
%endif |
489 |
%ifarch %{ix86} x86_64 |
490 |
cp -fR arch/x86/kernel/asm-offsets.{c,s} %{temp_devel}/arch/x86/kernel/ |
491 |
cp -fR arch/x86/kernel/asm-offsets_{32,64}.c %{temp_devel}/arch/x86/kernel/ |
492 |
cp -fR arch/x86/syscalls/syscall* %{temp_devel}/arch/x86/syscalls/ |
493 |
cp -fR arch/x86/include %{temp_devel}/arch/x86/ |
494 |
cp -fR arch/x86/tools/relocs.c %{temp_devel}/arch/x86/tools/ |
495 |
%else |
496 |
cp -fR arch/%{target_arch}/kernel/asm-offsets.{c,s} %{temp_devel}/arch/%{target_arch}/kernel/ |
497 |
for f in $(find arch/%{target_arch} -name include); do cp -fR --parents $f $TempDevelRoot; done |
498 |
%endif |
499 |
|
500 |
# Needed for generation of kernel/bounds.s |
501 |
cp -fR kernel/bounds.c %{temp_devel}/kernel/ |
502 |
|
503 |
# Needed for lguest |
504 |
cp -fR drivers/lguest/lg.h %{temp_devel}/drivers/lguest/ |
505 |
|
506 |
cp -fR .config Module.symvers %{temp_devel} |
507 |
|
508 |
# Needed for truecrypt build (Danny) |
509 |
cp -fR drivers/md/dm.h %{temp_devel}/drivers/md/ |
510 |
|
511 |
# Needed for external dvb tree (#41418) |
512 |
cp -fR drivers/media/dvb/dvb-core/*.h %{temp_devel}/drivers/media/dvb/dvb-core/ |
513 |
cp -fR drivers/media/dvb/frontends/lgdt330x.h %{temp_devel}/drivers/media/dvb/frontends/ |
514 |
|
515 |
# add acpica header files, needed for fglrx build |
516 |
cp -fR drivers/acpi/acpica/*.h %{temp_devel}/drivers/acpi/acpica/ |
517 |
|
518 |
# Check and clean the -devel tree |
519 |
pushd %{temp_devel} >/dev/null |
520 |
%smake -s prepare scripts clean |
521 |
rm -f .config.old |
522 |
popd >/dev/null |
523 |
|
524 |
# Disable mrproper and other targets |
525 |
patch -p1 -d %{temp_devel} -i %{SOURCE2} |
526 |
|
527 |
# Fix permissions |
528 |
chmod -R a+rX %{temp_devel} |
529 |
%endif # build_devel |
530 |
|
531 |
#make sure we are in the directory |
532 |
cd %src_dir |
533 |
|
534 |
# kernel-source is shipped as an unprepared tree |
535 |
%smake -s mrproper |
536 |
|
537 |
|
538 |
### |
539 |
### Install |
540 |
### |
541 |
%install |
542 |
install -m 644 %{SOURCE4} . |
543 |
|
544 |
cd %src_dir |
545 |
# Directories definition needed for installing |
546 |
%define target_source %{buildroot}/%{_kerneldir} |
547 |
%define target_boot %{buildroot}%{_bootdir} |
548 |
%define target_modules %{buildroot}%{_modulesdir} |
549 |
%define target_devel %{buildroot}%{_develdir} |
550 |
|
551 |
# We want to be able to test several times the install part |
552 |
rm -rf %{buildroot} |
553 |
cp -a %{temp_root} %{buildroot} |
554 |
|
555 |
# Create directories infastructure |
556 |
%if %build_source |
557 |
install -d %{target_source} |
558 |
|
559 |
tar cf - . | tar xf - -C %{target_source} |
560 |
chmod -R a+rX %{target_source} |
561 |
|
562 |
# we remove all the source files that we don't ship |
563 |
|
564 |
# first architecture files |
565 |
for i in alpha avr32 blackfin c6x cris frv hexagon h8300 ia64 m32r mips \ |
566 |
microblaze m68k m68knommu mn10300 openrisc parisc powerpc ppc \ |
567 |
s390 score sh sh64 sparc tile unicore32 v850 xtensa; do |
568 |
rm -rf %{target_source}/arch/$i |
569 |
|
570 |
%if %build_devel |
571 |
rm -rf %{target_devel}/arch/$i |
572 |
%endif |
573 |
done |
574 |
|
575 |
# remove arch files based on target arch in -devel rpms |
576 |
%if %build_devel |
577 |
%ifnarch %{ix86} x86_64 |
578 |
rm -rf %{target_devel}/arch/x86 |
579 |
%endif |
580 |
%ifnarch %{arm} |
581 |
rm -rf %{target_devel}/arch/arm |
582 |
%endif |
583 |
%endif |
584 |
|
585 |
|
586 |
# other misc files |
587 |
rm -f %{target_source}/{.config.old,.config.cmd,.tmp_gas_check,.mailmap,.missing-syscalls.d,arch/.gitignore} |
588 |
rm -rf %{target_source}/.tmp_depmod/ |
589 |
|
590 |
#endif %build_source |
591 |
%endif |
592 |
|
593 |
|
594 |
# compressing modules |
595 |
find %{target_modules} -name "*.ko" | %kxargs xz -6e |
596 |
|
597 |
|
598 |
# We used to have a copy of PrepareKernel here |
599 |
# Now, we make sure that the thing in the linux dir is what we want it to be |
600 |
|
601 |
for i in %{target_modules}/*; do |
602 |
rm -f $i/build $i/source |
603 |
done |
604 |
|
605 |
|
606 |
# sniff, if we gzipped all the modules, we change the stamp :( |
607 |
# we really need the depmod -ae here |
608 |
pushd %{target_modules} |
609 |
for i in *; do |
610 |
/sbin/depmod -ae -b %{buildroot} -F %{target_boot}/System.map-$i $i |
611 |
echo $? |
612 |
done |
613 |
|
614 |
for i in *; do |
615 |
pushd $i |
616 |
echo "Creating module.description for $i" |
617 |
modules=`find . -name "*.ko.xz"` |
618 |
echo $modules | %kxargs /sbin/modinfo \ |
619 |
| perl -lne 'print "$name\t$1" if $name && /^description:\s*(.*)/; $name = $1 if m!^filename:\s*(.*)\.k?o!; $name =~ s!.*/!!' > modules.description |
620 |
popd |
621 |
done |
622 |
popd |
623 |
|
624 |
|
625 |
### |
626 |
### Clean |
627 |
### |
628 |
|
629 |
%clean |
630 |
rm -rf %{buildroot} |
631 |
# We don't want to remove this, the whole reason of its existence is to be |
632 |
# able to do several rpm --short-circuit -bi for testing install |
633 |
# phase without repeating compilation phase |
634 |
#rm -rf %{temp_root} |
635 |
|
636 |
|
637 |
### |
638 |
### Scripts |
639 |
### |
640 |
|
641 |
### kernel |
642 |
%if %build_kernel |
643 |
%preun -n %{kname}-%{buildrel} |
644 |
/sbin/installkernel -R %{buildrel} |
645 |
if [ -L /lib/modules/%{buildrel}/build ]; then |
646 |
rm -f /lib/modules/%{buildrel}/build |
647 |
fi |
648 |
if [ -L /lib/modules/%{buildrel}/source ]; then |
649 |
rm -f /lib/modules/%{buildrel}/source |
650 |
fi |
651 |
pushd /boot > /dev/null |
652 |
if [ -L vmlinuz-linus ]; then |
653 |
if [ "$(readlink vmlinuz-linus)" = "vmlinuz-%{buildrel}" ]; then |
654 |
rm -f vmlinuz-linus |
655 |
fi |
656 |
fi |
657 |
if [ -L initrd-linus.img ]; then |
658 |
if [ "$(readlink initrd-linus.img)" = "initrd-%{buildrel}.img" ]; then |
659 |
rm -f initrd-linus.img |
660 |
fi |
661 |
fi |
662 |
popd > /dev/null |
663 |
exit 0 |
664 |
|
665 |
%post -n %{kname}-%{buildrel} |
666 |
/sbin/installkernel -L %{buildrel} |
667 |
if [ -d /usr/src/%{kname}-devel-%{buildrel} ]; then |
668 |
ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/build |
669 |
ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/source |
670 |
fi |
671 |
pushd /boot > /dev/null |
672 |
if [ -L vmlinuz-linus ]; then |
673 |
rm -f vmlinuz-linus |
674 |
fi |
675 |
ln -sf vmlinuz-%{buildrel} vmlinuz-linus |
676 |
if [ -L initrd-linus.img ]; then |
677 |
rm -f initrd-linus.img |
678 |
fi |
679 |
ln -sf initrd-%{buildrel}.img initrd-linus.img |
680 |
popd > /dev/null |
681 |
|
682 |
%posttrans -n %{kname}-%{buildrel} |
683 |
if [ -x /usr/sbin/dkms_autoinstaller -a -d /usr/src/%{kname}-devel-%{buildrel} ]; then |
684 |
/usr/sbin/dkms_autoinstaller start %{buildrel} |
685 |
fi |
686 |
|
687 |
%postun -n %{kname}-%{buildrel} |
688 |
/sbin/kernel_remove_initrd %{buildrel} |
689 |
rm -rf /lib/modules/%{buildrel} > /dev/null |
690 |
%endif # build_kernel |
691 |
|
692 |
|
693 |
### kernel-devel |
694 |
%if %build_devel |
695 |
%post -n %{kname}-devel-%{buildrel} |
696 |
# place /build and /source symlinks in place. |
697 |
if [ -d /lib/modules/%{buildrel} ]; then |
698 |
ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/build |
699 |
ln -sf /usr/src/%{kname}-devel-%{buildrel} /lib/modules/%{buildrel}/source |
700 |
fi |
701 |
|
702 |
%preun -n %{kname}-devel-%{buildrel} |
703 |
# we need to delete <modules>/{build,source} at uninstall |
704 |
if [ -L /lib/modules/%{buildrel}/build ]; then |
705 |
rm -f /lib/modules/%{buildrel}/build |
706 |
fi |
707 |
if [ -L /lib/modules/%{buildrel}/source ]; then |
708 |
rm -f /lib/modules/%{buildrel}/source |
709 |
fi |
710 |
exit 0 |
711 |
%endif #build_devel |
712 |
|
713 |
|
714 |
### |
715 |
### file lists |
716 |
### |
717 |
|
718 |
# kernel |
719 |
%if %build_kernel |
720 |
%files -n %{kname}-%{buildrel} |
721 |
%{_bootdir}/config-%{buildrel} |
722 |
%ifarch %{arm} |
723 |
%{_bootdir}/uImage-%{buildrel} |
724 |
%else |
725 |
%{_bootdir}/vmlinuz-%{buildrel} |
726 |
%endif |
727 |
%{_bootdir}/System.map-%{buildrel} |
728 |
%dir %{_modulesdir}/%{buildrel}/ |
729 |
%{_modulesdir}/%{buildrel}/kernel |
730 |
%{_modulesdir}/%{buildrel}/modules.* |
731 |
%doc README.kernel-sources |
732 |
%endif # build_kernel |
733 |
|
734 |
# kernel-source |
735 |
%if %build_source |
736 |
%files -n %{kname}-source-%{buildrel} |
737 |
%dir %{_kerneldir} |
738 |
%dir %{_kerneldir}/arch |
739 |
%dir %{_kerneldir}/include |
740 |
%{_kerneldir}/.gitignore |
741 |
%{_kerneldir}/COPYING |
742 |
%{_kerneldir}/CREDITS |
743 |
%{_kerneldir}/Documentation |
744 |
%{_kerneldir}/Kbuild |
745 |
%{_kerneldir}/Kconfig |
746 |
%{_kerneldir}/MAINTAINERS |
747 |
%{_kerneldir}/Makefile |
748 |
%{_kerneldir}/README |
749 |
%{_kerneldir}/REPORTING-BUGS |
750 |
%{_kerneldir}/arch/Kconfig |
751 |
%{_kerneldir}/arch/arm |
752 |
%{_kerneldir}/arch/x86 |
753 |
%{_kerneldir}/arch/um |
754 |
%{_kerneldir}/block |
755 |
%{_kerneldir}/crypto |
756 |
%{_kerneldir}/drivers |
757 |
%{_kerneldir}/firmware |
758 |
%{_kerneldir}/fs |
759 |
%{_kerneldir}/include/Kbuild |
760 |
%{_kerneldir}/include/acpi |
761 |
%{_kerneldir}/include/asm-generic |
762 |
%{_kerneldir}/include/crypto |
763 |
%{_kerneldir}/include/drm |
764 |
%{_kerneldir}/include/linux |
765 |
%{_kerneldir}/include/math-emu |
766 |
%{_kerneldir}/include/net |
767 |
%{_kerneldir}/include/pcmcia |
768 |
%{_kerneldir}/include/scsi |
769 |
%{_kerneldir}/include/sound |
770 |
%{_kerneldir}/include/target |
771 |
%{_kerneldir}/include/trace |
772 |
%{_kerneldir}/include/video |
773 |
%{_kerneldir}/include/media |
774 |
%{_kerneldir}/include/misc |
775 |
%{_kerneldir}/include/mtd |
776 |
%{_kerneldir}/include/rxrpc |
777 |
%{_kerneldir}/include/keys |
778 |
%{_kerneldir}/include/rdma |
779 |
%{_kerneldir}/include/xen |
780 |
%{_kerneldir}/init |
781 |
%{_kerneldir}/ipc |
782 |
%{_kerneldir}/kernel |
783 |
%{_kerneldir}/lib |
784 |
%{_kerneldir}/mm |
785 |
%{_kerneldir}/net |
786 |
%{_kerneldir}/samples |
787 |
%{_kerneldir}/scripts |
788 |
%{_kerneldir}/security |
789 |
%{_kerneldir}/sound |
790 |
%{_kerneldir}/tools |
791 |
%{_kerneldir}/usr |
792 |
%{_kerneldir}/virt |
793 |
%doc README.kernel-sources |
794 |
%endif # build_source |
795 |
|
796 |
# kernel-devel |
797 |
%if %build_devel |
798 |
%files -n %{kname}-devel-%{buildrel} |
799 |
%dir %{_develdir} |
800 |
%dir %{_develdir}/arch |
801 |
%dir %{_develdir}/include |
802 |
%{_develdir}/.config |
803 |
%{_develdir}/Documentation |
804 |
%{_develdir}/Kbuild |
805 |
%{_develdir}/Kconfig |
806 |
%{_develdir}/Makefile |
807 |
%{_develdir}/Module.symvers |
808 |
%{_develdir}/arch/Kconfig |
809 |
%ifarch %{arm} |
810 |
%{_develdir}/arch/arm |
811 |
%endif |
812 |
%ifarch %{ix86} x86_64 |
813 |
%{_develdir}/arch/x86 |
814 |
%endif |
815 |
%{_develdir}/arch/um |
816 |
%{_develdir}/block |
817 |
%{_develdir}/crypto |
818 |
%{_develdir}/drivers |
819 |
%{_develdir}/firmware |
820 |
%{_develdir}/fs |
821 |
%{_develdir}/include/Kbuild |
822 |
%{_develdir}/include/acpi |
823 |
%{_develdir}/include/asm-generic |
824 |
%{_develdir}/include/config |
825 |
%{_develdir}/include/crypto |
826 |
%{_develdir}/include/drm |
827 |
%{_develdir}/include/generated |
828 |
%{_develdir}/include/keys |
829 |
%{_develdir}/include/linux |
830 |
%{_develdir}/include/math-emu |
831 |
%{_develdir}/include/misc |
832 |
%{_develdir}/include/mtd |
833 |
%{_develdir}/include/net |
834 |
%{_develdir}/include/pcmcia |
835 |
%{_develdir}/include/rdma |
836 |
%{_develdir}/include/scsi |
837 |
%{_develdir}/include/sound |
838 |
%{_develdir}/include/target |
839 |
%{_develdir}/include/trace |
840 |
%{_develdir}/include/video |
841 |
%{_develdir}/include/media |
842 |
%{_develdir}/include/rxrpc |
843 |
%{_develdir}/include/xen |
844 |
%{_develdir}/init |
845 |
%{_develdir}/ipc |
846 |
%{_develdir}/kernel |
847 |
%{_develdir}/lib |
848 |
%{_develdir}/mm |
849 |
%{_develdir}/net |
850 |
%{_develdir}/samples |
851 |
%{_develdir}/scripts |
852 |
%{_develdir}/security |
853 |
%{_develdir}/sound |
854 |
%{_develdir}/tools |
855 |
%{_develdir}/usr |
856 |
%{_develdir}/virt |
857 |
%doc README.kernel-sources |
858 |
%endif # build_devel |
859 |
|
860 |
|
861 |
%if %build_doc |
862 |
%files -n %{kname}-doc |
863 |
%doc linux-%{tar_ver}/Documentation/* |
864 |
%endif # build_doc |
865 |
|
866 |
%if %build_kernel |
867 |
%files -n %{kname}-latest |
868 |
%endif # build_kernel |
869 |
|
870 |
%if %build_source |
871 |
%files -n %{kname}-source-latest |
872 |
%endif # build_source |
873 |
|
874 |
%if %build_devel |
875 |
%files -n %{kname}-devel-latest |
876 |
%endif # build_devel |