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