packaging: Add kernel dtb overlays
[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_check %{?_smp_mflags}
126     make O=build/${target} headers_install %{?_smp_mflags}
127
128     # Set config file
129     case $target in
130         %{variant})
131             make O=build/${target} %{config_name} %{?_smp_mflags}
132         ;;
133         %{variant}-rt)
134             cat _localversion-rt > localversion-rt
135             make O=build/${target} %{config_name_rt} %{?_smp_mflags}
136         ;;
137     esac
138
139     # Build Image/Image.gz
140     make O=build/${target} %{?_smp_mflags}
141
142     # Build dtbs
143     make O=build/${target} dtbs %{?_smp_mflags}
144
145     # Build modules
146     make O=build/${target} modules %{?_smp_mflags}
147 done
148
149 %install
150 QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
151
152 # Destination directories
153 mkdir -p %{buildroot}/boot
154 mkdir -p %{buildroot}/lib/modules
155
156 # Install boot binary files
157 %ifarch aarch64
158 install -m 644 rpi4/boot/config_64bit.txt %{buildroot}/boot/config.txt
159 %else
160 install -m 644 rpi4/boot/config.txt %{buildroot}/boot/
161 %endif
162 install -m 644 rpi4/boot/LICENCE.broadcom %{buildroot}/boot/
163 install -m 644 rpi4/boot/start*.elf %{buildroot}/boot/
164 install -m 644 rpi4/boot/fixup*.dat %{buildroot}/boot/
165
166 # Install kernel DTB
167 %ifarch aarch64
168 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/broadcom/bcm*.dtb %{buildroot}/boot/
169 %else
170 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/bcm*.dtb %{buildroot}/boot/
171 %endif
172 mkdir -p %{buildroot}/boot/overlays
173 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/overlays/*.dtbo %{buildroot}/boot/overlays/
174
175 # Install kernel headers
176 make O=build/%{variant} headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr
177
178 for target in %{variant} %{variant}-rt; do
179     # Install kernel binary
180     case $target in
181         %{variant})
182 %ifarch aarch64
183             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image
184 %else
185             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage
186 %endif
187         ;;
188         %{variant}-rt)
189 %ifarch aarch64
190             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image_rt
191 %else
192             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage_rt
193 %endif
194         ;;
195     esac
196
197     # Install modules
198     make O=build/${target} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install
199
200     # Copy files for devel package
201     mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-${target}
202     rsync -r \
203           --include "/scripts/**.c" \
204           --exclude "/debug*.list" \
205           --exclude "/documentation.list" \
206           --exclude "/*.manifest" \
207           --exclude "/packaging/" \
208           --exclude "/.gbs.conf" \
209           --exclude "/.git**" \
210           --exclude ".gitignore" \
211           --exclude "*\.c" \
212           --exclude ".tmp_vmlinux*" \
213           --exclude ".*dtb*tmp" \
214           --exclude ".*dtb" \
215           --exclude "*.*tmp" \
216           --exclude "vmlinux" \
217           --exclude "Image" \
218           --exclude "zImage" \
219           --exclude "Image.gz" \
220           --exclude "*.cmd" \
221           --exclude "*.ko" \
222           --exclude "*.o" \
223           --exclude "*.S" \
224           --exclude "*.HEX" \
225           --exclude "/build/" \
226           ./ build/${target}/ %{buildroot}/boot/kernel/devel/kernel-devel-${target}
227 done
228
229 %clean
230 rm -rf %{buildroot}
231
232 %post -n %{variant}-rt-linux-kernel
233 %ifarch aarch64
234 mv /boot/Image_rt /boot/Image
235 %else
236 mv /boot/zImage_rt /boot/zImage
237 %endif
238
239 %preun -n %{variant}-rt-linux-kernel
240 %ifarch aarch64
241 mv /boot/Image /boot/Image_rt
242 %else
243 mv /boot/zImage /boot/zImage_rt
244 %endif
245
246 %files -n %{variant}-linux-kernel-modules
247 %ifarch aarch64
248 /lib/modules/*%{variant}-v8/
249 %else
250 /lib/modules/*%{variant}-v7l/
251 %endif
252
253 %files -n %{variant}-rt-linux-kernel-modules
254 %ifarch aarch64
255 /lib/modules/*%{variant}-rt-v8/
256 %else
257 /lib/modules/*%{variant}-rt-v7l/
258 %endif
259
260 %files -n %{variant}-linux-kernel-devel
261 /boot/kernel/devel/*%{variant}/
262
263 %files -n %{variant}-rt-linux-kernel-devel
264 /boot/kernel/devel/*%{variant}-rt/
265
266 %files -n %{variant}-linux-kernel
267 %license COPYING
268 %ifarch aarch64
269 /boot/Image
270 %else
271 /boot/zImage
272 %endif
273 /boot/bcm*.dtb
274 /boot/overlays/*.dtbo
275 /boot/config.txt
276 /boot/LICENCE.broadcom
277 /boot/start*.elf
278 /boot/fixup*.dat
279
280 %files -n %{variant}-rt-linux-kernel
281 %license COPYING
282 %ifarch aarch64
283 /boot/Image_rt
284 %else
285 /boot/zImage_rt
286 %endif
287 /boot/bcm*.dtb
288 /boot/overlays/*.dtbo
289 /boot/config.txt
290 /boot/LICENCE.broadcom
291 /boot/start*.elf
292 /boot/fixup*.dat
293
294 %files -n %{variant}-linux-kernel-headers
295 /usr/include/*