1 %define config_name tizen_tm2_defconfig
2 %define buildarch arm64
3 %define target_board tm2
4 %define variant %{buildarch}-%{target_board}
6 Name: %{target_board}-linux-kernel
7 Summary: The Linux Kernel for TM2/TM2E board
11 ExclusiveArch: %{arm} aarch64
13 Vendor: The Linux Community
14 URL: https://www.kernel.org
15 Source0: linux-kernel-%{version}.tar.xz
16 BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root
18 %define fullVersion %{version}-%{variant}
19 %define __spec_install_post /usr/lib/rpm/brp-compress || :
20 %define debug_package %{nil}
23 BuildRequires: module-init-tools
24 BuildRequires: u-boot-tools >= 2016.03
27 The Linux Kernel, the operating system core itself
30 %package -n %{variant}-linux-kernel
32 Summary: Tizen kernel for %{target_board}
34 Provides: %{variant}-kernel-profile-mobile = %{version}-%{release}
35 Provides: %{variant}-kernel-uname-r = %{fullVersion}
36 Provides: linux-kernel = %{version}-%{release}
38 %description -n %{variant}-linux-kernel
39 This package contains the Linux kernel for Tizen (mobile profile, arch %{buildarch}, target board %{target_board})
41 %package -n %{variant}-linux-kernel-modules
42 Summary: Kernel modules for %{target_board}
44 Provides: %{variant}-kernel-modules = %{fullVersion}
45 Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}
47 %description -n %{variant}-linux-kernel-modules
48 Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board}
50 %package -n %{variant}-linux-kernel-debuginfo
52 Summary: Linux support debug symbol
55 %description -n %{variant}-linux-kernel-debuginfo
56 This package provides the %{target_board} linux kernel's debugging files.
58 %package -n %{variant}-linux-kernel-devel
60 Summary: Linux support kernel map and etc for other packages
62 Provides: %{variant}-kernel-devel = %{fullVersion}
63 Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}
65 %description -n %{variant}-linux-kernel-devel
66 This package provides kernel map and etc information.
69 %package -n %{variant}-linux-kernel-headers
71 Summary: Linux support headers for userspace development
73 Provides: kernel-headers-tizen-dev
75 %description -n %{variant}-linux-kernel-headers
76 This package provides userspaces headers from the Linux kernel. These
77 headers are used by the installed headers for GNU glibc and other system
81 %setup -q -n linux-kernel-%{version}
84 %{?asan:/usr/bin/gcc-unforce-options}
85 %{?ubsan:/usr/bin/gcc-unforce-options}
87 # Make sure EXTRAVERSION says what we want it to say
88 sed -i "s/^EXTRAVERSION.*/EXTRAVERSION = -%{variant}/" Makefile
90 # 1-1. extract uapi headers
91 mkdir -p uapi-headers/usr
94 make headers_install INSTALL_HDR_PATH=uapi-headers/usr
97 # 1-2. set config file
100 # 1-3. Build Image/Image.gz
104 make dtbs %{?_smp_mflags}
106 # 1-5. Build u-boot itb image
107 mkimage -f arch/arm64/boot/tizen-tm2.its kernel.img
110 make modules %{?_smp_mflags}
114 QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
116 # 2-1. Destination directories
117 mkdir -p %{_builddir}/boot
119 mkdir -p %{_builddir}/lib/modules
121 # 2-2. Install kernel.img
122 install -m 644 kernel.img %{_builddir}/boot/
124 # 2-3. Install Image.gz, dtbs, System.map, ...
125 install -m 644 arch/%{buildarch}/boot/Image.gz %{_builddir}/boot/
126 install -m 644 arch/%{buildarch}/boot/dts/exynos/*.dtb %{_builddir}/boot/
127 install -m 644 System.map %{_builddir}/boot/
128 install -m 644 .config %{_builddir}/boot/config-%{fullVersion}
129 install -m 644 vmlinux %{_builddir}/boot/
130 install -m 644 COPYING %{_builddir}/boot/
132 # 2-4. Install modules
133 make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{_builddir} modules_install
136 # 2-5. Install uapi headers
137 find uapi-headers/usr/include -name ".install" -delete
138 find uapi-headers/usr/include -name "..install.cmd" -delete
139 rm -f uapi-headers/usr/include/asm*/atomic.h
140 rm -f uapi-headers/usr/include/asm*/io.h
141 mv uapi-headers/usr %{_builddir}/
143 # 3-1. remove unnecessary files to prepare for devel package
144 rm -rf arch/%{buildarch}/boot/vmlinux*
150 find %{_builddir}/linux-kernel-%{version} -name "*\.HEX" -type f -delete
151 find %{_builddir}/linux-kernel-%{version} -name ".tmp_vmlinux*" -delete
152 find %{_builddir}/linux-kernel-%{version} -name ".gitignore" -delete
153 find %{_builddir}/linux-kernel-%{version} -name "\.*dtb*tmp" -delete
154 find %{_builddir}/linux-kernel-%{version} -name "\.*dtb" -delete
155 find %{_builddir}/linux-kernel-%{version} -name "*\.*tmp" -delete
156 find %{_builddir}/linux-kernel-%{version} -name "vmlinux" -delete
157 find %{_builddir}/linux-kernel-%{version} -name "Image" -delete
158 find %{_builddir}/linux-kernel-%{version} -name "Image.gz" -delete
159 find %{_builddir}/linux-kernel-%{version} -name "*.cmd" -delete
160 find %{_builddir}/linux-kernel-%{version} -name "*\.ko" -delete
161 find %{_builddir}/linux-kernel-%{version} -name "*\.o" -delete
162 find %{_builddir}/linux-kernel-%{version} -name "*\.S" -delete
163 find %{_builddir}/linux-kernel-%{version} -name "*\.c" -not -path "%{_builddir}/linux-kernel-%{version}/scripts/*" -delete
165 # 3-2. move files for devel package
167 mv %{_builddir}/usr %{buildroot}/
169 mv linux-kernel-%{version} kernel-devel-%{variant}
170 mkdir -p linux-kernel-%{version}
172 # 4. Move files for each package
173 mkdir -p %{buildroot}/boot/kernel/devel
174 mv %{_builddir}/boot/COPYING %{buildroot}/
175 mv %{_builddir}/boot/* %{buildroot}/boot/
176 rm -rf %{_builddir}/boot
177 mv %{_builddir}/lib %{buildroot}/
178 mv %{_builddir}/kernel-devel-%{variant} %{buildroot}/boot/kernel/devel/
183 rm -rf %{_builddir}/COPYING
184 rm -rf %{_builddir}/boot
185 rm -rf %{_builddir}/lib
186 rm -rf %{_builddir}/usr
187 rm -rf %{_builddir}/kernel-devel-%{variant}
190 %files -n %{variant}-linux-kernel
194 %files -n %{variant}-linux-kernel-modules
197 %files -n %{variant}-linux-kernel-devel
200 %files -n %{variant}-linux-kernel-debuginfo
208 %files -n %{variant}-linux-kernel-headers