packaging: Only build for armv7l
[platform/adaptation/renesas_rcar/renesas_kernel.git] / packaging / kernel-rcar-m2.spec
1 #
2 # Spec written for Tizen Mobile, some bits and pieces originate
3 # from MeeGo/Moblin/Fedora
4 #
5
6 %define upstream_version snapshot3+hdmi
7 %define platform rcar-m2
8 %define profile ivi
9
10 %if !%{defined platform}
11 %define platform default
12 %endif
13
14 %define variant %{profile}-%{_arch}-%{platform}
15 %define kernel_version %{version}-%{release}
16 %define kernel_full_version %{version}-%{release}-%{variant}
17 %define arch_32bits i386 i586 i686 %{ix86}
18
19 # Default arch config for tizen per arch (unless overiden after)
20 %define kernel_image bzImage
21 %define defconfig tizen_defconfig
22
23 %define dtbs_supported 0
24 %define modules_supported 1
25 %define trace_supported 1
26 %define uboot_supported 0
27 %define vdso_supported 1
28
29
30 # Overide per configuration
31
32 %ifarch %{arch_32bits}
33 %define kernel_arch i386
34 %define kernel_arch_subdir arch/x86
35 %define defconfig %{profile}_x86_defconfig
36 %endif
37
38 %ifarch x86_64
39 %define kernel_arch x86_64
40 %define kernel_arch_subdir arch/x86
41 %define defconfig %{profile}_%{kernel_arch}_defconfig
42 %endif
43
44 %ifarch %arm
45 %define kernel_arch arm
46 %define kernel_arch_subdir arch/%{kernel_arch}
47 %define kernel_image zImage
48 %define vdso_supported 0
49 %define modules_supported 0
50 %endif
51
52 %if ( "rcar-m2" == "%{platform}" )
53 %define defconfig tizen_%{platform}_defconfig
54 %define uboot_supported 1
55 %define dtbs_supported 1
56 %define loadaddr 40008000
57 %define kernel_image uImage
58 %endif
59
60
61 Name: kernel-ivi
62 Summary: Tizen kernel
63 Group: System/Kernel
64 License: GPL-2.0
65 URL: http://www.kernel.org/
66 Version: %{upstream_version}
67
68 # The below is used when we are on an -rc version
69 #%#define rc_num 6
70 #%#define release_ver 0
71 #%#define rc_str %{?rc_num:0.rc%{rc_num}}%{!?rc_num:1}
72 #%if ! 0%{?opensuse_bs}
73 #Release: 0
74 #%else
75 #Release: 0
76 #%endif
77 Release: 0
78
79 BuildRequires: module-init-tools
80 BuildRequires: findutils
81 BuildRequires: libelf-devel
82 BuildRequires: binutils-devel
83 BuildRequires: which
84 BuildRequires: bc
85 # net-tools provides the 'hostname' utility which kernel build wants
86 BuildRequires: net-tools
87 # The below is required for building perf
88 BuildRequires: flex
89 BuildRequires: bison
90 BuildRequires: libdw-devel
91 BuildRequires: python-devel
92 %if %{uboot_supported}
93 BuildRequires: u-boot-tools
94 %endif
95
96 ExclusiveArch: armv7l
97
98 Source0: %{name}-%{version}.tar.bz2
99
100 %description
101 This package contains the Linux kernel for Tizen.
102
103
104 %package -n kernel-%{variant}
105 Summary: Tizen kernel
106 Group: System/Kernel
107 Provides: kernel-profile-%{profile} = %{version}-%{release}
108 Provides: kernel-uname-r = %{kernel_full_version}
109 Requires(post): /usr/bin/ln
110 Requires(post): /usr/bin/sort
111 Requires(post): rpm
112
113 # We use 'setup-scripts-bootloader-conf' in post and postun, so ideally we need to
114 # have the below here, but this causes gbs/obs build failures like this:
115 #    "have choice for virtual-setup-scripts-bootloader needed by kernel-x86-scripts: setup-extlinux setup-gummiboot"
116 # The reason is that it will try to install the kernel to the build root, and
117 # fail with the above error. To fix it one would need to add 'setup-extlinux'
118 # or 'setup-gummiboot' to 'review.tizen.org/gerrit/scm/meta/build-config'. But
119 # it is probably not worth the trouble, so I commented out the below two lines.
120 # -- Artem
121 #Requires(post): virtual-setup-scripts-bootloader
122 #Requires(postun): virtual-setup-scripts-bootloader
123
124 #Requires(post): setup-gummiboot
125 #Requires(postun): setup-gummiboot
126
127 Requires(post): /usr/sbin/depmod
128 Requires(post): /usr/bin/dracut
129 Requires(post): /usr/bin/kmod
130
131 Requires(postun): /usr/bin/ln
132 Requires(postun): /usr/bin/sed
133 Requires(postun): rpm
134
135 # We can't let RPM do the dependencies automatic because it'll then pick up
136 # a correct but undesirable perl dependency from the module headers which
137 # isn't required for the kernel proper to function
138 AutoReq: no
139 AutoProv: yes
140
141 %description -n kernel-%{variant}
142 This package contains the Linux kernel for Tizen (%{profile} profile, architecure %{_arch})
143
144 %package -n kernel-%{variant}-devel
145 Summary: Development package for building kernel modules
146 Group: Development/System
147 Provides: kernel-devel = %{kernel_full_version}
148 Provides: kernel-devel-uname-r = %{kernel_full_version}
149 Requires(post): /usr/bin/find
150 Requires: kernel-%{variant} = %{version}-%{release}
151 AutoReqProv: no
152
153 %description -n kernel-%{variant}-devel
154 This package provides kernel headers and makefiles sufficient to build modules
155 against the %{variant} kernel package.
156
157
158 %package -n perf
159 Summary: The 'perf' performance counter tool
160 Group: System/Kernel
161 Provides: perf = %{kernel_full_version}
162 Requires: kernel-%{variant} = %{version}-%{release}
163
164 %description -n perf
165 This package provides the "perf" tool that can be used to monitor performance
166 counter events as well as various kernel internal events.
167
168
169
170 ###
171 ### PREP
172 ###
173 %prep
174 # Unpack the kernel tarball
175 %setup -q -n %{name}-%{version}
176
177
178
179 ###
180 ### BUILD
181 ###
182 %build
183 # Make sure EXTRAVERSION says what we want it to say
184 sed -i "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}-%{variant}/" Makefile
185
186 # Build perf
187 make -s -C tools/lib/traceevent ARCH=%{kernel_arch} %{?_smp_mflags}
188 make -s -C tools/perf WERROR=0 ARCH=%{kernel_arch}
189
190 %if %{defined loadaddr}
191 export LOADADDR=%{loadaddr}
192 %endif
193
194 # Build kernel and modules
195 make -s ARCH=%{kernel_arch} %{defconfig}
196 make %{?_smp_mflags} %{kernel_image} ARCH=%{kernel_arch}
197
198 %if %modules_supported
199 make -s ARCH=%{kernel_arch} %{?_smp_mflags} modules
200 %endif
201
202 %if %dtbs_supported
203 make -s ARCH=%{kernel_arch} %{?_smp_mflags} dtbs
204 %endif
205
206
207
208 ###
209 ### INSTALL
210 ###
211 %install
212 install -d %{buildroot}/boot
213
214 install -m 644 .config %{buildroot}/boot/config-%{kernel_full_version}
215 install -m 644 System.map %{buildroot}/boot/System.map-%{kernel_full_version}
216 install -m 755 %{kernel_arch_subdir}/boot/%{kernel_image} %{buildroot}/boot/vmlinuz-%{kernel_full_version}
217 # Dummy initrd, will not be included in the actual package but needed for files
218 touch %{buildroot}/boot/initrd-%{kernel_full_version}.img
219
220 %if %modules_supported
221 make -s ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{buildroot} modules_install KERNELRELEASE=%{kernel_full_version}
222 %endif
223
224 %if %vdso_supported
225 make -s ARCH=%{kernel_arch} INSTALL_MOD_PATH=%{buildroot} vdso_install KERNELRELEASE=%{kernel_full_version}
226 %endif
227
228 %if %dtbs_supported
229 install -d "%{buildroot}/boot/"
230 find "arch/%{kernel_arch}/" -iname "*.dtb" -exec install "{}" "%{buildroot}/boot/" \;
231 %endif
232
233 rm -rf %{buildroot}/lib/firmware
234
235 # And save the headers/makefiles etc for building modules against
236 #
237 # This all looks scary, but the end result is supposed to be:
238 # * all arch relevant include/ files
239 # * all Makefile/Kconfig files
240 # * all script/ files
241
242 # Remove existing build/source links and create pristine dirs
243 rm -f %{buildroot}/lib/modules/%{kernel_full_version}/build
244 rm -f %{buildroot}/lib/modules/%{kernel_full_version}/source
245 install -d %{buildroot}/lib/modules/%{kernel_full_version}/build
246 ln -fs build %{buildroot}/lib/modules/%{kernel_full_version}/source
247
248
249 # First, copy all dirs containing Makefile of Kconfig files
250 cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` %{buildroot}/lib/modules/%{kernel_full_version}/build
251 install Module.symvers %{buildroot}/lib/modules/%{kernel_full_version}/build/
252 install System.map %{buildroot}/lib/modules/%{kernel_full_version}/build/
253
254 # Then, drop all but the needed Makefiles/Kconfig files
255 rm -rf %{buildroot}/lib/modules/%{kernel_full_version}/build/Documentation
256 rm -rf %{buildroot}/lib/modules/%{kernel_full_version}/build/scripts
257 rm -rf %{buildroot}/lib/modules/%{kernel_full_version}/build/include
258
259 # Copy config and scripts
260 install .config %{buildroot}/lib/modules/%{kernel_full_version}/build/
261 cp -a scripts %{buildroot}/lib/modules/%{kernel_full_version}/build
262 if [ -d %{kernel_arch_subdir}/scripts ]; then
263     cp -a %{kernel_arch_subdir}/scripts %{buildroot}/lib/modules/%{kernel_full_version}/build/%{kernel_arch_subdir}/ || :
264 fi
265 if [ -f %{kernel_arch_subdir}/*lds ]; then
266     cp -a %{kernel_arch_subdir}/*lds %{buildroot}/lib/modules/%{kernel_full_version}/build/%{kernel_arch_subdir}/ || :
267 fi
268 rm -f %{buildroot}/lib/modules/%{kernel_full_version}/build/scripts/*.o
269 rm -f %{buildroot}/lib/modules/%{kernel_full_version}/build/scripts/*/*.o
270 cp -a --parents %{kernel_arch_subdir}/include %{buildroot}/lib/modules/%{kernel_full_version}/build
271
272 # Copy include files
273 mkdir -p %{buildroot}/lib/modules/%{kernel_full_version}/build/include
274 find include/ -mindepth 1 -maxdepth 1 -type d | xargs -I{} cp -a {} %{buildroot}/lib/modules/%{kernel_full_version}/build/include
275
276 # Save the vmlinux file for kernel debugging into the devel package
277 cp vmlinux %{buildroot}/lib/modules/%{kernel_full_version}
278
279 # Mark modules executable so that strip-to-file can strip them
280 find %{buildroot}/lib/modules/%{kernel_full_version} -name "*.ko" -type f | xargs --no-run-if-empty chmod 755
281
282 # Move the devel headers out of the root file system
283 install -d %{buildroot}/usr/src/kernels
284 mv %{buildroot}/lib/modules/%{kernel_full_version}/build %{buildroot}/usr/src/kernels/%{kernel_full_version}
285
286 ln -sf /usr/src/kernels/%{kernel_full_version} %{buildroot}/lib/modules/%{kernel_full_version}/build
287
288 # Install perf
289 install -d %{buildroot}
290 make -s -C tools/perf DESTDIR=%{buildroot} install
291 install -d  %{buildroot}%{_bindir}
292 install -d  %{buildroot}%{_libexecdir}
293 mv %{buildroot}/bin/* %{buildroot}%{_bindir}
294 mv %{buildroot}/libexec/* %{buildroot}%{_libexecdir}
295 rm %{buildroot}/etc/bash_completion.d/perf
296
297 # Dont package debug files
298 rm -rf %{buildroot}/usr/lib/debug/.build-id
299 rm -rf %{buildroot}/usr/lib/debug/lib/traceevent/plugins/*.debug
300
301
302
303 ###
304 ### SCRIPTS
305 ###
306
307 %post -n kernel-%{variant}
308 if [ -f "/boot/loader/loader.conf" ]; then
309         # EFI boot with gummiboot
310         INSTALLERFW_MOUNT_PREFIX="/" /usr/sbin/setup-scripts-gummiboot-conf
311     # "/etc/installerfw-environment" does not exist in MIC environment, when it
312     # builds the image. MIC will add boot-loader entries later using the
313     # 'setup-scripts-boot' script.
314     if [ -f "/etc/installerfw-environment" ] && \
315         [ -x "/usr/sbin/setup-scripts-bootloader-conf" ]; then
316             /usr/sbin/setup-scripts-bootloader-conf add -f vmlinuz-%{kernel_full_version}
317             /usr/sbin/setup-scripts-bootloader-conf default -f vmlinuz-%{kernel_full_version}
318     fi
319 else
320         # Legacy boot
321         last_installed_ver="$(rpm -q --qf '%{INSTALLTIME}: %{VERSION}-%{RELEASE}\n' kernel-%{variant} | sort -r | sed -e 's/[^:]*: \(.*\)/\1/g' | sed -n -e "1p")"
322         ln -sf vmlinuz-$last_installed_ver-%{variant} /boot/vmlinuz
323
324         if [ -z "$last_installed_ver" ]; then
325                 # Something went wrong, print some diagnostics
326                 printf "%s\n" "Error: cannot find kernel version" 1>&2
327                 printf "%s\n" "The command was: rpm -q --qf '%{INSTALLTIME}: %{VERSION}-%{RELEASE}\n' kernel-%{variant} | sort -r | sed -e 's/[^:]*: \(.*\)/\1/g' | sed -n -e \"1p\"" 1>&2
328                 printf "%s\n" "Output of the \"rpm -q --qf '%{INSTALLTIME}: %{VERSION}-%{RELEASE}\n' kernel-%{variant}\" is:" 1>&2
329                 result="$(rpm -q --qf '%{INSTALLTIME}: %{VERSION}-%{RELEASE}\n' kernel-%{variant})"
330                 printf "%s\n" "$result" 1>&2
331         fi
332 fi
333
334 %{_bindir}/dracut /boot/initrd-%{kernel_full_version}.img %{kernel_full_version}
335
336 %post -n kernel-%{variant}-devel
337 if [ -x /usr/sbin/hardlink ]; then
338         cd /usr/src/kernels/%{kernel_full_version}
339         /usr/bin/find . -type f | while read f; do
340                 hardlink -c /usr/src/kernels/*/$f $f
341         done
342 fi
343
344 %postun -n kernel-%{variant}
345 if [ -f "/boot/loader/loader.conf" ]; then
346         # EFI boot with gummiboot
347         INSTALLERFW_MOUNT_PREFIX="/" /usr/sbin/setup-scripts-gummiboot-conf
348     if [ -f "/etc/installerfw-environment" ] && \
349         [ -x "/usr/sbin/setup-scripts-bootloader-conf" ]; then
350             /usr/sbin/setup-scripts-bootloader-conf remove -f vmlinuz-%{kernel_full_version}
351     fi
352
353 else
354         last_installed_ver="$(rpm -q --qf '%{INSTALLTIME}: %{VERSION}-%{RELEASE}\n' kernel-%{variant} | sort -r | sed -e 's/[^:]*: \(.*\)/\1/g' | sed -n -e "1p")"
355         if [ -n "$last_installed_ver" ]; then
356                 ln -sf vmlinuz-$last_installed_ver-%{variant} /boot/vmlinuz
357         else
358                 rm -rf /boot/vmlinuz
359         fi
360 fi
361
362
363
364 ###
365 ### FILES
366 ###
367 %files -n kernel-%{variant}
368 %license COPYING
369 /boot/vmlinuz-%{kernel_full_version}
370 /boot/System.map-%{kernel_full_version}
371 /boot/config-%{kernel_full_version}
372 %if %modules_supported
373 %dir /lib/modules/%{kernel_full_version}
374 /lib/modules/%{kernel_full_version}/kernel
375 /lib/modules/%{kernel_full_version}/modules.*
376 %endif
377 /lib/modules/%{kernel_full_version}/build
378 /lib/modules/%{kernel_full_version}/source
379
380 %if %vdso_supported
381 /lib/modules/%{kernel_full_version}/vdso
382 %endif
383 %if %dtbs_supported
384 /boot/*.dtb
385 %endif
386 %ghost /boot/initrd-%{kernel_full_version}.img
387
388
389 %files -n kernel-%{variant}-devel
390 %license COPYING
391 %verify(not mtime) /usr/src/kernels/%{kernel_full_version}
392 /lib/modules/%{kernel_full_version}/vmlinux
393
394
395 %files -n perf
396 %license COPYING
397 %{_bindir}/perf
398 %{_libexecdir}/perf-core
399 %if %trace_supported
400 %{_bindir}/trace
401 /%{_lib}/traceevent/plugins/*.so
402 %endif