spec: support gbs(1) incremental builds
[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 %ifarch aarch64
6 %define buildarch arm64
7 %else
8 %define buildarch arm
9 %endif
10 %define target_board rpi4
11 %define variant %{buildarch}-%{target_board}
12
13 Name: rpi4-linux-kernel
14 Summary: The Linux Kernel for Raspberry Pi4
15 Version: 5.4.50
16 Release: 0
17 License: GPL-2.0
18 ExclusiveArch: %{arm} aarch64
19 Group: System/Kernel
20 Vendor: The Linux Community
21 URL: https://www.kernel.org
22 Source0:   linux-kernel-%{version}.tar.xz
23 BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root
24
25 %define fullVersion %{version}-%{variant}
26
27 BuildRequires: bc
28 BuildRequires: module-init-tools
29 BuildRequires: bison
30 BuildRequires: flex
31 BuildRequires: libopenssl1.1-devel
32 BuildRequires: rsync
33
34 %description
35 The Linux Kernel, the operating system core itself
36
37 %package -n %{variant}-linux-kernel
38 License: GPL-2.0
39 Summary: Tizen kernel for %{target_board}
40 Group: System/Kernel
41 Provides: %{variant}-kernel-uname-r = %{fullVersion}
42 Provides: linux-kernel = %{version}-%{release}
43
44 %description -n %{variant}-linux-kernel
45 This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board})
46
47 %package -n %{variant}-linux-kernel-modules
48 Summary: Kernel modules for %{target_board}
49 Group: System/Kernel
50 Provides: %{variant}-kernel-modules = %{fullVersion}
51 Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}
52
53 %description -n %{variant}-linux-kernel-modules
54 Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board}
55
56 %package -n %{variant}-linux-kernel-devel
57 License: GPL-2.0
58 Summary: Linux support kernel map and etc for other packages
59 Group: System/Kernel
60 Provides: %{variant}-kernel-devel = %{fullVersion}
61 Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}
62
63 %description -n %{variant}-linux-kernel-devel
64 This package provides kernel map and etc information.
65
66 %package -n %{variant}-linux-kernel-headers
67 License: GPL-2.0
68 Summary: Linux support headers for userspace development
69 Group: System/Kernel
70 Provides: kernel-headers-tizen-dev
71
72 %description -n %{variant}-linux-kernel-headers
73 This package provides userspaces headers from the Linux kernel. These
74 headers are used by the installed headers for GNU glibc and other system
75  libraries.
76
77 %prep
78 %setup -q
79
80 %build
81 %{?asan:/usr/bin/gcc-unforce-options}
82 %{?ubsan:/usr/bin/gcc-unforce-options}
83
84 # Make sure EXTRAVERSION says what we want it to say
85 sed -i "s/^EXTRAVERSION.*/EXTRAVERSION = -%{variant}/" Makefile
86
87 # 0. extract uapi headers
88 make headers_check %{?_smp_mflags}
89 make headers_install %{?_smp_mflags}
90
91 # 1-1. Set config file
92 make %{config_name} %{?_smp_mflags}
93
94 # 1-2. Build Image/Image.gz
95 make %{?_smp_mflags}
96
97 # 1-3. Build dtbs
98 make dtbs %{?_smp_mflags}
99
100 # 1-4. Build modules
101 make modules %{?_smp_mflags}
102
103 %install
104 QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
105
106 # 2-1. Destination directories
107 mkdir -p %{buildroot}/boot
108 mkdir -p %{buildroot}/lib/modules
109
110 # 2-2. Install kernel binary and DTB
111 %ifarch aarch64
112 install -m 644 arch/%{buildarch}/boot/Image %{buildroot}/boot/
113 install -m 644 arch/%{buildarch}/boot/dts/broadcom/bcm*.dtb %{buildroot}/boot/
114 %else
115 install -m 644 arch/%{buildarch}/boot/zImage %{buildroot}/boot/
116 install -m 644 arch/%{buildarch}/boot/dts/bcm*.dtb %{buildroot}/boot/
117 %endif
118
119 # 2-3. Install modules
120 make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install
121
122 # 2-4. Install boot binary files
123 %ifarch aarch64
124 install -m 644 rpi4/boot/config_64bit.txt %{buildroot}/boot/config.txt
125 %else
126 install -m 644 rpi4/boot/config.txt %{buildroot}/boot/
127 %endif
128 install -m 644 rpi4/boot/LICENCE.broadcom %{buildroot}/boot/
129 install -m 644 rpi4/boot/start*.elf %{buildroot}/boot/
130 install -m 644 rpi4/boot/fixup*.dat %{buildroot}/boot/
131
132 # 2-5. Install kernel headers
133 make headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr
134
135 # 3. Copy files for devel package
136 mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-%{variant}
137 rsync -r \
138     --include "/scripts/**.c" \
139     --exclude "/debug*.list" \
140     --exclude "/documentation.list" \
141     --exclude "/*.manifest" \
142     --exclude "/packaging/" \
143     --exclude "/.gbs.conf" \
144     --exclude "/.git**" \
145     --exclude ".gitignore" \
146     --exclude "*\.c" \
147     --exclude ".tmp_vmlinux*" \
148     --exclude ".*dtb*tmp" \
149     --exclude ".*dtb" \
150     --exclude "*.*tmp" \
151     --exclude "vmlinux" \
152     --exclude "Image" \
153     --exclude "zImage" \
154     --exclude "Image.gz" \
155     --exclude "*.cmd" \
156     --exclude "*.ko" \
157     --exclude "*.o" \
158     --exclude "*.S" \
159     --exclude "*.HEX" \
160 %{_builddir}/%{name}-%{version}/ %{buildroot}/boot/kernel/devel/kernel-devel-%{variant}
161
162 %clean
163 rm -rf %{buildroot}
164
165 %files -n %{variant}-linux-kernel-modules
166 /lib/modules/*
167
168 %files -n %{variant}-linux-kernel-devel
169 /boot/kernel/devel/*
170
171 %files -n %{variant}-linux-kernel
172 %license COPYING
173 %ifarch aarch64
174 /boot/Image
175 %else
176 /boot/zImage
177 %endif
178 /boot/bcm*.dtb
179 /boot/config.txt
180 /boot/LICENCE.broadcom
181 /boot/start*.elf
182 /boot/fixup*.dat
183
184 %files -n %{variant}-linux-kernel-headers
185 /usr/include/*