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