packaging: remove headers_check in spec file
[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: 5.10.95
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: libopenssl1.1-devel
33 BuildRequires: rsync
34
35 %description
36 The Linux Kernel, the operating system core itself
37
38 # kernel
39 %package -n %{variant}-linux-kernel
40 License: GPL-2.0
41 Summary: Tizen kernel for %{target_board}
42 Group: System/Kernel
43 Provides: %{variant}-kernel-uname-r = %{fullVersion}
44 Provides: linux-kernel = %{version}-%{release}
45
46 %description -n %{variant}-linux-kernel
47 This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board})
48
49 %package -n %{variant}-rt-linux-kernel
50 License: GPL-2.0
51 Summary: Tizen kernel for %{target_board}
52 Group: System/Kernel
53 Provides: %{variant}-kernel-uname-r = %{fullVersion}-rt
54 Provides: linux-kernel = %{version}-%{release}-rt
55
56 %description -n %{variant}-rt-linux-kernel
57 This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board})
58
59 # modules
60
61 %package -n %{variant}-linux-kernel-modules
62 Summary: Kernel modules for %{target_board}
63 Group: System/Kernel
64 Provides: %{variant}-kernel-modules = %{fullVersion}
65 Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}
66
67 %description -n %{variant}-linux-kernel-modules
68 Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board}
69
70 %package -n %{variant}-rt-linux-kernel-modules
71 Summary: Kernel modules for %{target_board}
72 Group: System/Kernel
73 Provides: %{variant}-kernel-modules = %{fullVersion}-rt
74 Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}-rt
75
76 %description -n %{variant}-rt-linux-kernel-modules
77 Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board}
78 with the PREEMPT_RT patch
79
80 # devel
81
82 %package -n %{variant}-linux-kernel-devel
83 License: GPL-2.0
84 Summary: Linux support kernel map and etc for other packages
85 Group: System/Kernel
86 Provides: %{variant}-kernel-devel = %{fullVersion}
87 Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}
88
89 %description -n %{variant}-linux-kernel-devel
90 This package provides kernel map and etc information.
91
92 %package -n %{variant}-rt-linux-kernel-devel
93 License: GPL-2.0
94 Summary: Linux support kernel map and etc for other packages
95 Group: System/Kernel
96 Provides: %{variant}-kernel-devel = %{fullVersion}-rt
97 Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}-rt
98
99 %description -n %{variant}-rt-linux-kernel-devel
100 This package provides kernel map and etc information.
101
102 #headers
103 %package -n %{variant}-linux-kernel-headers
104 License: GPL-2.0
105 Summary: Linux support headers for userspace development
106 Group: System/Kernel
107 Provides: kernel-headers-tizen-dev
108
109 %description -n %{variant}-linux-kernel-headers
110 This package provides userspaces headers from the Linux kernel. These
111 headers are used by the installed headers for GNU glibc and other system
112  libraries.
113
114 %prep
115 %setup -q
116
117 %build
118 %{?asan:/usr/bin/gcc-unforce-options}
119 %{?ubsan:/usr/bin/gcc-unforce-options}
120
121 for target in %{variant} %{variant}-rt; do
122     echo "-${target}" > localversion-tizen
123
124     # extract uapi headers
125     make O=build/${target} headers_install %{?_smp_mflags}
126
127     # Set config file
128     case $target in
129         %{variant})
130             make O=build/${target} %{config_name} %{?_smp_mflags}
131         ;;
132         %{variant}-rt)
133             cat _localversion-rt > localversion-rt
134             make O=build/${target} %{config_name_rt} %{?_smp_mflags}
135         ;;
136     esac
137
138     # Build Image/Image.gz
139     make O=build/${target} %{?_smp_mflags}
140
141     # Build dtbs
142     make O=build/${target} dtbs %{?_smp_mflags}
143
144     # Build modules
145     make O=build/${target} modules %{?_smp_mflags}
146 done
147
148 %install
149 QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
150
151 # Destination directories
152 mkdir -p %{buildroot}/boot
153 mkdir -p %{buildroot}/lib/modules
154
155 # Install boot binary files
156 %ifarch aarch64
157 install -m 644 rpi4/boot/config_64bit.txt %{buildroot}/boot/config.txt
158 %else
159 install -m 644 rpi4/boot/config.txt %{buildroot}/boot/
160 %endif
161 install -m 644 rpi4/boot/LICENCE.broadcom %{buildroot}/boot/
162 install -m 644 rpi4/boot/start*.elf %{buildroot}/boot/
163 install -m 644 rpi4/boot/fixup*.dat %{buildroot}/boot/
164
165 # Install kernel DTB
166 %ifarch aarch64
167 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/broadcom/bcm*.dtb %{buildroot}/boot/
168 %else
169 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/bcm*.dtb %{buildroot}/boot/
170 %endif
171 mkdir -p %{buildroot}/boot/overlays
172 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/overlays/*.dtbo %{buildroot}/boot/overlays/
173
174 # Install kernel headers
175 make O=build/%{variant} headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr
176
177 for target in %{variant} %{variant}-rt; do
178     # Install kernel binary
179     case $target in
180         %{variant})
181 %ifarch aarch64
182             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image
183 %else
184             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage
185 %endif
186         ;;
187         %{variant}-rt)
188 %ifarch aarch64
189             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image_rt
190 %else
191             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage_rt
192 %endif
193         ;;
194     esac
195
196     # Install modules
197     make O=build/${target} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install
198
199     # Copy files for devel package
200     mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-${target}
201     rsync -r \
202           --include "/scripts/**.c" \
203           --exclude "/debug*.list" \
204           --exclude "/documentation.list" \
205           --exclude "/*.manifest" \
206           --exclude "/packaging/" \
207           --exclude "/.gbs.conf" \
208           --exclude "/.git**" \
209           --exclude ".gitignore" \
210           --exclude "*\.c" \
211           --exclude ".tmp_vmlinux*" \
212           --exclude ".*dtb*tmp" \
213           --exclude ".*dtb" \
214           --exclude "*.*tmp" \
215           --exclude "vmlinux" \
216           --exclude "Image" \
217           --exclude "zImage" \
218           --exclude "Image.gz" \
219           --exclude "*.cmd" \
220           --exclude "*.ko" \
221           --exclude "*.o" \
222           --exclude "*.S" \
223           --exclude "*.HEX" \
224           --exclude "/build/" \
225           ./ build/${target}/ %{buildroot}/boot/kernel/devel/kernel-devel-${target}
226 done
227
228 %clean
229 rm -rf %{buildroot}
230
231 %post -n %{variant}-rt-linux-kernel
232 %ifarch aarch64
233 mv /boot/Image_rt /boot/Image
234 %else
235 mv /boot/zImage_rt /boot/zImage
236 %endif
237
238 %preun -n %{variant}-rt-linux-kernel
239 %ifarch aarch64
240 mv /boot/Image /boot/Image_rt
241 %else
242 mv /boot/zImage /boot/zImage_rt
243 %endif
244
245 %files -n %{variant}-linux-kernel-modules
246 %ifarch aarch64
247 /lib/modules/*%{variant}-v8/
248 %else
249 /lib/modules/*%{variant}-v7l/
250 %endif
251
252 %files -n %{variant}-rt-linux-kernel-modules
253 %ifarch aarch64
254 /lib/modules/*%{variant}-rt-v8/
255 %else
256 /lib/modules/*%{variant}-rt-v7l/
257 %endif
258
259 %files -n %{variant}-linux-kernel-devel
260 /boot/kernel/devel/*%{variant}/
261
262 %files -n %{variant}-rt-linux-kernel-devel
263 /boot/kernel/devel/*%{variant}-rt/
264
265 %files -n %{variant}-linux-kernel
266 %license COPYING
267 %ifarch aarch64
268 /boot/Image
269 %else
270 /boot/zImage
271 %endif
272 /boot/bcm*.dtb
273 /boot/overlays/*.dtbo
274 /boot/config.txt
275 /boot/LICENCE.broadcom
276 /boot/start*.elf
277 /boot/fixup*.dat
278
279 %files -n %{variant}-rt-linux-kernel
280 %license COPYING
281 %ifarch aarch64
282 /boot/Image_rt
283 %else
284 /boot/zImage_rt
285 %endif
286 /boot/bcm*.dtb
287 /boot/overlays/*.dtbo
288 /boot/config.txt
289 /boot/LICENCE.broadcom
290 /boot/start*.elf
291 /boot/fixup*.dat
292
293 %files -n %{variant}-linux-kernel-headers
294 /usr/include/*