xref: /openbmc/linux/scripts/package/kernel.spec (revision 046b212a)
1# _arch is undefined if /usr/lib/rpm/platform/*/macros was not included.
2%{!?_arch: %define _arch dummy}
3%{!?make: %define make make}
4%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
5%define __spec_install_post /usr/lib/rpm/brp-compress || :
6%define debug_package %{nil}
7
8Name: kernel
9Summary: The Linux Kernel
10Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g')
11Release: %{pkg_release}
12License: GPL
13Group: System Environment/Kernel
14Vendor: The Linux Community
15URL: https://www.kernel.org
16Source0: linux.tar.gz
17Source1: config
18Source2: diff.patch
19Provides: kernel-%{KERNELRELEASE}
20BuildRequires: bc binutils bison dwarves
21BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
22BuildRequires: gcc make openssl openssl-devel perl python3 rsync
23
24%description
25The Linux Kernel, the operating system core itself
26
27%package headers
28Summary: Header files for the Linux kernel for use by glibc
29Group: Development/System
30Obsoletes: kernel-headers
31Provides: kernel-headers = %{version}
32%description headers
33Kernel-headers includes the C header files that specify the interface
34between the Linux kernel and userspace libraries and programs.  The
35header files define structures and constants that are needed for
36building most standard programs and are also needed for rebuilding the
37glibc package.
38
39%if %{with_devel}
40%package devel
41Summary: Development package for building kernel modules to match the %{version} kernel
42Group: System Environment/Kernel
43AutoReqProv: no
44%description -n kernel-devel
45This package provides kernel headers and makefiles sufficient to build modules
46against the %{version} kernel package.
47%endif
48
49%prep
50%setup -q -n linux
51cp %{SOURCE1} .config
52patch -p1 < %{SOURCE2}
53
54%build
55%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release}
56
57%install
58mkdir -p %{buildroot}/boot
59%ifarch ia64
60mkdir -p %{buildroot}/boot/efi
61cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE}
62ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/
63%else
64cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE}
65%endif
66%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install
67%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
68cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE}
69cp .config %{buildroot}/boot/config-%{KERNELRELEASE}
70ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
71ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source
72%if %{with_devel}
73%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
74%endif
75
76%clean
77rm -rf %{buildroot}
78
79%post
80if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then
81cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm
82cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm
83rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE}
84/sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm
85rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm
86fi
87
88%preun
89if [ -x /sbin/new-kernel-pkg ]; then
90new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img
91elif [ -x /usr/bin/kernel-install ]; then
92kernel-install remove %{KERNELRELEASE}
93fi
94
95%postun
96if [ -x /sbin/update-bootloader ]; then
97/sbin/update-bootloader --remove %{KERNELRELEASE}
98fi
99
100%files
101%defattr (-, root, root)
102/lib/modules/%{KERNELRELEASE}
103%exclude /lib/modules/%{KERNELRELEASE}/build
104%exclude /lib/modules/%{KERNELRELEASE}/source
105/boot/*
106
107%files headers
108%defattr (-, root, root)
109/usr/include
110
111%if %{with_devel}
112%files devel
113%defattr (-, root, root)
114/usr/src/kernels/%{KERNELRELEASE}
115/lib/modules/%{KERNELRELEASE}/build
116/lib/modules/%{KERNELRELEASE}/source
117%endif
118