05ed5c84ba3e1d0140f01a301702199086524f65
[platform/kernel/linux-rpi.git] / packaging / linux-rpi4.spec
1 # Ignore double dash in version for rpmbuild
2 %define _wrong_version_format_terminate_build 0
3
4 %define config_name tizen_bcm2711_defconfig
5 %define config_name_rt tizen_bcm2711_rt_defconfig
6 %ifarch aarch64
7 %define buildarch arm64
8 %else
9 %define buildarch arm
10 %endif
11 %define target_board rpi4
12 %define variant %{buildarch}-%{target_board}
13
14 Name: rpi4-linux-kernel
15 Summary: The Linux Kernel for Raspberry Pi4
16 Version: 6.6.17
17 Release: 0
18 License: GPL-2.0
19 ExclusiveArch: %{arm} aarch64
20 Group: System/Kernel
21 Vendor: The Linux Community
22 URL: https://www.kernel.org
23 Source0:   linux-kernel-%{version}.tar.xz
24 BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root
25
26 %define fullVersion %{version}-%{variant}
27
28 BuildRequires: bc
29 BuildRequires: module-init-tools
30 BuildRequires: bison
31 BuildRequires: flex
32 BuildRequires: pkgconfig(openssl3)
33 BuildRequires: libunwind-devel
34 BuildRequires: libdw-devel
35 BuildRequires: libelf-devel
36 BuildRequires: elfutils
37 BuildRequires: xz-devel
38 BuildRequires: binutils-devel
39 BuildRequires: python3
40 BuildRequires: rsync
41
42 %description
43 The Linux Kernel, the operating system core itself
44
45 # kernel
46 %package -n %{variant}-linux-kernel
47 License: GPL-2.0
48 Summary: Tizen kernel for %{target_board}
49 Group: System/Kernel
50 Provides: %{variant}-kernel-uname-r = %{fullVersion}
51 Provides: linux-kernel = %{version}-%{release}
52
53 %description -n %{variant}-linux-kernel
54 This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board})
55
56 %package -n %{variant}-rt-linux-kernel
57 License: GPL-2.0
58 Summary: Tizen kernel for %{target_board}
59 Group: System/Kernel
60 Provides: %{variant}-kernel-uname-r = %{fullVersion}-rt
61 Provides: linux-kernel = %{version}-%{release}-rt
62
63 %description -n %{variant}-rt-linux-kernel
64 This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board})
65
66 # modules
67
68 %package -n %{variant}-linux-kernel-modules
69 Summary: Kernel modules for %{target_board}
70 Group: System/Kernel
71 Provides: %{variant}-kernel-modules = %{fullVersion}
72 Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}
73
74 %description -n %{variant}-linux-kernel-modules
75 Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board}
76
77 %package -n %{variant}-rt-linux-kernel-modules
78 Summary: Kernel modules for %{target_board}
79 Group: System/Kernel
80 Provides: %{variant}-kernel-modules = %{fullVersion}-rt
81 Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}-rt
82
83 %description -n %{variant}-rt-linux-kernel-modules
84 Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board}
85 with the PREEMPT_RT patch
86
87 # devel
88
89 %package -n %{variant}-linux-kernel-devel
90 License: GPL-2.0
91 Summary: Linux support kernel map and etc for other packages
92 Group: System/Kernel
93 Provides: %{variant}-kernel-devel = %{fullVersion}
94 Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}
95
96 %description -n %{variant}-linux-kernel-devel
97 This package provides kernel map and etc information.
98
99 %package -n %{variant}-rt-linux-kernel-devel
100 License: GPL-2.0
101 Summary: Linux support kernel map and etc for other packages
102 Group: System/Kernel
103 Provides: %{variant}-kernel-devel = %{fullVersion}-rt
104 Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}-rt
105
106 %description -n %{variant}-rt-linux-kernel-devel
107 This package provides kernel map and etc information.
108
109 #headers
110 %package -n %{variant}-linux-kernel-headers
111 License: GPL-2.0
112 Summary: Linux support headers for userspace development
113 Group: System/Kernel
114 Provides: kernel-headers-tizen-dev
115
116 %description -n %{variant}-linux-kernel-headers
117 This package provides userspaces headers from the Linux kernel. These
118 headers are used by the installed headers for GNU glibc and other system
119  libraries.
120
121 %package -n linux-kernel-perf
122 Summary: The perf performance counter tool
123 Group: System/Kernel
124 Provides: perf = %{version}
125
126 %description -n linux-kernel-perf
127 This package provides the "perf" tool that can be used to monitor performance
128 counter events as well as various kernel internal events.
129
130 %prep
131 %setup -q
132
133 %build
134 %{?asan:/usr/bin/gcc-unforce-options}
135 %{?ubsan:/usr/bin/gcc-unforce-options}
136
137 for target in %{variant} %{variant}-rt; do
138     echo "-${target}" > localversion-tizen
139
140     # extract uapi headers
141     make O=build/${target} headers_install %{?_smp_mflags}
142
143     # Set config file
144     case $target in
145         %{variant})
146             make O=build/${target} %{config_name} %{?_smp_mflags}
147
148             # Build perf
149             # WERROR=0 make O=build/${target} -s -C tools/lib/traceevent %{?_smp_mflags}
150             WERROR=0 make O=build/${target} -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" %{?_smp_mflags} NO_LIBTRACEEVENT=1
151         ;;
152         %{variant}-rt)
153             cat _localversion-rt > localversion-rt
154             make O=build/${target} %{config_name_rt} %{?_smp_mflags}
155         ;;
156     esac
157
158     # Build Image/Image.gz
159     make O=build/${target} %{?_smp_mflags}
160
161     # Build dtbs
162     make O=build/${target} dtbs %{?_smp_mflags}
163
164     # Build modules
165     make O=build/${target} modules %{?_smp_mflags}
166 done
167
168 %install
169 QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
170
171 # Destination directories
172 mkdir -p %{buildroot}/boot
173 mkdir -p %{buildroot}/lib/modules
174
175 # Install boot binary files
176 %ifarch aarch64
177 install -m 644 rpi4/boot/config_64bit.txt %{buildroot}/boot/config.txt
178 %else
179 install -m 644 rpi4/boot/config.txt %{buildroot}/boot/
180 %endif
181 install -m 644 rpi4/boot/LICENCE.broadcom %{buildroot}/boot/
182 install -m 644 rpi4/boot/start*.elf %{buildroot}/boot/
183 install -m 644 rpi4/boot/fixup*.dat %{buildroot}/boot/
184
185 # Install kernel DTB
186 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/broadcom/bcm*.dtb %{buildroot}/boot/
187 mkdir -p %{buildroot}/boot/overlays
188 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/overlays/*.dtbo %{buildroot}/boot/overlays/
189
190 # Install kernel headers
191 make O=build/%{variant} headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr
192
193 for target in %{variant} %{variant}-rt; do
194     # Install kernel binary
195     case $target in
196         %{variant})
197 %ifarch aarch64
198             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image
199 %else
200             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage
201 %endif
202
203             # Install perf
204             WERROR=0 make O=build/${target} -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" DESTDIR=%{buildroot}/usr install NO_LIBTRACEEVENT=1
205             rm -rf %{buildroot}/usr/etc
206             rm -rf %{buildroot}/usr/lib/debug
207             rm -rf %{buildroot}/usr/lib/perf
208             rm -rf %{buildroot}/usr/share
209
210         ;;
211         %{variant}-rt)
212 %ifarch aarch64
213             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image_rt
214 %else
215             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage_rt
216 %endif
217         ;;
218     esac
219
220     # Install modules
221     make O=build/${target} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install
222
223     # Copy files for devel package
224     mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-${target}
225     rsync -r \
226           --include "/scripts/**.c" \
227           --exclude "/debug*.list" \
228           --exclude "/documentation.list" \
229           --exclude "/*.manifest" \
230           --exclude "/packaging/" \
231           --exclude "/.gbs.conf" \
232           --exclude "/.git**" \
233           --exclude ".gitignore" \
234           --exclude "*\.c" \
235           --exclude ".tmp_vmlinux*" \
236           --exclude ".*dtb*tmp" \
237           --exclude ".*dtb" \
238           --exclude "*.*tmp" \
239           --exclude "vmlinux" \
240           --exclude "Image" \
241           --exclude "zImage" \
242           --exclude "Image.gz" \
243           --exclude "*.cmd" \
244           --exclude "*.ko" \
245           --exclude "*.o" \
246           --exclude "*.S" \
247           --exclude "*.HEX" \
248           --exclude "/build/" \
249           ./ build/${target}/ %{buildroot}/boot/kernel/devel/kernel-devel-${target}
250 done
251
252 %clean
253 rm -rf %{buildroot}
254
255 %post -n %{variant}-rt-linux-kernel
256 %ifarch aarch64
257 mv /boot/Image_rt /boot/Image
258 %else
259 mv /boot/zImage_rt /boot/zImage
260 %endif
261
262 %preun -n %{variant}-rt-linux-kernel
263 %ifarch aarch64
264 mv /boot/Image /boot/Image_rt
265 %else
266 mv /boot/zImage /boot/zImage_rt
267 %endif
268
269 %files -n %{variant}-linux-kernel-modules
270 %ifarch aarch64
271 /lib/modules/*%{variant}-v8/
272 %else
273 /lib/modules/*%{variant}-v7l/
274 %endif
275
276 %files -n %{variant}-rt-linux-kernel-modules
277 %ifarch aarch64
278 /lib/modules/*%{variant}-rt-v8/
279 %else
280 /lib/modules/*%{variant}-rt-v7l/
281 %endif
282
283 %files -n %{variant}-linux-kernel-devel
284 /boot/kernel/devel/*%{variant}/
285
286 %files -n %{variant}-rt-linux-kernel-devel
287 /boot/kernel/devel/*%{variant}-rt/
288
289 %files -n %{variant}-linux-kernel
290 %license COPYING
291 %ifarch aarch64
292 /boot/Image
293 %else
294 /boot/zImage
295 %endif
296 /boot/bcm*.dtb
297 /boot/overlays/*.dtbo
298 /boot/config.txt
299 /boot/LICENCE.broadcom
300 /boot/start*.elf
301 /boot/fixup*.dat
302
303 %files -n %{variant}-rt-linux-kernel
304 %license COPYING
305 %ifarch aarch64
306 /boot/Image_rt
307 %else
308 /boot/zImage_rt
309 %endif
310 /boot/bcm*.dtb
311 /boot/overlays/*.dtbo
312 /boot/config.txt
313 /boot/LICENCE.broadcom
314 /boot/start*.elf
315 /boot/fixup*.dat
316
317 %files -n %{variant}-linux-kernel-headers
318 /usr/include/*
319
320 %files -n linux-kernel-perf
321 %license COPYING
322 /usr/bin/*
323 /usr/libexec/*