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