Revert "Bluetooth: Store advertising handle so it can be re-enabled"
[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 %if "%{dev_wos}" == "1"
138 # build as permissive mode
139 ./scripts/config --file arch/%{buildarch}/configs/%{config_name} -u CONFIG_SECURITY_SMACK -u CONFIG_SECURITY_SMACK_APPEND_SIGNALS -e CONFIG_NETLABEL -e CONFIG_SECURITY_NETWORK
140 ./scripts/config --file arch/%{buildarch}/configs/%{config_name_rt} -u CONFIG_SECURITY_SMACK -u CONFIG_SECURITY_SMACK_APPEND_SIGNALS -e CONFIG_NETLABEL -e CONFIG_SECURITY_NETWORK
141 %endif
142
143 for target in %{variant} %{variant}-rt; do
144     echo "-${target}" > localversion-tizen
145
146     # extract uapi headers
147     make O=build/${target} headers_install %{?_smp_mflags}
148
149     # Set config file
150     case $target in
151         %{variant})
152             make O=build/${target} %{config_name} %{?_smp_mflags}
153
154             # Build perf
155             # WERROR=0 make O=build/${target} -s -C tools/lib/traceevent %{?_smp_mflags}
156             WERROR=0 make O=build/${target} -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" %{?_smp_mflags} NO_LIBTRACEEVENT=1 NO_JEVENTS=1
157         ;;
158         %{variant}-rt)
159             cat _localversion-rt > localversion-rt
160             make O=build/${target} %{config_name_rt} %{?_smp_mflags}
161         ;;
162     esac
163
164     # Build Image/Image.gz
165     make O=build/${target} %{?_smp_mflags}
166
167     # Build dtbs
168     make O=build/${target} dtbs %{?_smp_mflags}
169
170     # Build modules
171     make O=build/${target} modules %{?_smp_mflags}
172 done
173
174 %install
175 QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
176
177 # Destination directories
178 mkdir -p %{buildroot}/boot
179 mkdir -p %{buildroot}/lib/modules
180
181 # Install boot binary files
182 %ifarch aarch64
183 install -m 644 rpi4/boot/config_64bit.txt %{buildroot}/boot/config.txt
184 %else
185 install -m 644 rpi4/boot/config.txt %{buildroot}/boot/
186 %endif
187 install -m 644 rpi4/boot/LICENCE.broadcom %{buildroot}/boot/
188 install -m 644 rpi4/boot/start*.elf %{buildroot}/boot/
189 install -m 644 rpi4/boot/fixup*.dat %{buildroot}/boot/
190
191 # Install kernel DTB
192 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/broadcom/bcm*.dtb %{buildroot}/boot/
193 mkdir -p %{buildroot}/boot/overlays
194 install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/overlays/*.dtbo %{buildroot}/boot/overlays/
195
196 # Install kernel headers
197 make O=build/%{variant} headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr
198
199 for target in %{variant} %{variant}-rt; do
200     # Install kernel binary
201     case $target in
202         %{variant})
203 %ifarch aarch64
204             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image
205 %else
206             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage
207 %endif
208
209             # Install perf
210             WERROR=0 make O=build/${target} -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" DESTDIR=%{buildroot}/usr install NO_LIBTRACEEVENT=1 NO_JEVENTS=1
211             rm -rf %{buildroot}/usr/etc
212             rm -rf %{buildroot}/usr/lib/debug
213             rm -rf %{buildroot}/usr/lib/perf
214             rm -rf %{buildroot}/usr/share
215
216         ;;
217         %{variant}-rt)
218 %ifarch aarch64
219             install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image_rt
220 %else
221             install -m 644 build/${target}/arch/%{buildarch}/boot/zImage %{buildroot}/boot/zImage_rt
222 %endif
223         ;;
224     esac
225
226     # Install modules
227     make O=build/${target} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install
228
229     # Copy files for devel package
230     mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-${target}
231     rsync -r \
232           --include "/scripts/**.c" \
233           --exclude "/debug*.list" \
234           --exclude "/documentation.list" \
235           --exclude "/*.manifest" \
236           --exclude "/packaging/" \
237           --exclude "/.gbs.conf" \
238           --exclude "/.git**" \
239           --exclude ".gitignore" \
240           --exclude "*\.c" \
241           --exclude ".tmp_vmlinux*" \
242           --exclude ".*dtb*tmp" \
243           --exclude ".*dtb" \
244           --exclude "*.*tmp" \
245           --exclude "vmlinux" \
246           --exclude "Image" \
247           --exclude "zImage" \
248           --exclude "Image.gz" \
249           --exclude "*.cmd" \
250           --exclude "*.ko" \
251           --exclude "*.o" \
252           --exclude "*.S" \
253           --exclude "*.HEX" \
254           --exclude "/build/" \
255           ./ build/${target}/ %{buildroot}/boot/kernel/devel/kernel-devel-${target}
256 done
257
258 %clean
259 rm -rf %{buildroot}
260
261 %post -n %{variant}-rt-linux-kernel
262 %ifarch aarch64
263 mv /boot/Image_rt /boot/Image
264 %else
265 mv /boot/zImage_rt /boot/zImage
266 %endif
267
268 %preun -n %{variant}-rt-linux-kernel
269 %ifarch aarch64
270 mv /boot/Image /boot/Image_rt
271 %else
272 mv /boot/zImage /boot/zImage_rt
273 %endif
274
275 %files -n %{variant}-linux-kernel-modules
276 %ifarch aarch64
277 /lib/modules/*%{variant}-v8/
278 %else
279 /lib/modules/*%{variant}-v7l/
280 %endif
281
282 %files -n %{variant}-rt-linux-kernel-modules
283 %ifarch aarch64
284 /lib/modules/*%{variant}-rt-v8/
285 %else
286 /lib/modules/*%{variant}-rt-v7l/
287 %endif
288
289 %files -n %{variant}-linux-kernel-devel
290 /boot/kernel/devel/*%{variant}/
291
292 %files -n %{variant}-rt-linux-kernel-devel
293 /boot/kernel/devel/*%{variant}-rt/
294
295 %files -n %{variant}-linux-kernel
296 %license COPYING
297 %ifarch aarch64
298 /boot/Image
299 %else
300 /boot/zImage
301 %endif
302 /boot/bcm*.dtb
303 /boot/overlays/*.dtbo
304 /boot/config.txt
305 /boot/LICENCE.broadcom
306 /boot/start*.elf
307 /boot/fixup*.dat
308
309 %files -n %{variant}-rt-linux-kernel
310 %license COPYING
311 %ifarch aarch64
312 /boot/Image_rt
313 %else
314 /boot/zImage_rt
315 %endif
316 /boot/bcm*.dtb
317 /boot/overlays/*.dtbo
318 /boot/config.txt
319 /boot/LICENCE.broadcom
320 /boot/start*.elf
321 /boot/fixup*.dat
322
323 %files -n %{variant}-linux-kernel-headers
324 /usr/include/*
325
326 %files -n linux-kernel-perf
327 %license COPYING
328 /usr/bin/*
329 /usr/libexec/*