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}/lib/modules/%{KERNELRELEASE} 59cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz 60%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install 61%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install 62cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE} 63cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config 64if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then 65 %{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install 66fi 67ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build 68%if %{with_devel} 69%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' 70%endif 71 72{ 73 for x in System.map config kernel modules.builtin \ 74 modules.builtin.modinfo modules.order vmlinuz; do 75 echo "/lib/modules/%{KERNELRELEASE}/${x}" 76 done 77 78 for x in alias alias.bin builtin.alias.bin builtin.bin dep dep.bin \ 79 devname softdep symbols symbols.bin; do 80 echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}" 81 done 82 83 for x in System.map config vmlinuz; do 84 echo "%ghost /boot/${x}-%{KERNELRELEASE}" 85 done 86 87 if [ -d "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" ];then 88 echo "/lib/modules/%{KERNELRELEASE}/dtb" 89 find "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" -printf "%%%ghost /boot/dtb-%{KERNELRELEASE}/%%P\n" 90 fi 91 92 echo "%exclude /lib/modules/%{KERNELRELEASE}/build" 93} > %{buildroot}/kernel.list 94 95%clean 96rm -rf %{buildroot} 97 98%post 99if [ -x /usr/bin/kernel-install ]; then 100 /usr/bin/kernel-install add %{KERNELRELEASE} /lib/modules/%{KERNELRELEASE}/vmlinuz 101fi 102for file in vmlinuz System.map config; do 103 if ! cmp --silent "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"; then 104 cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}" 105 fi 106done 107if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ] && \ 108 ! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" >/dev/null 2>&1; then 109 rm -rf "/boot/dtb-%{KERNELRELEASE}" 110 cp -r "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" 111fi 112if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then 113 /usr/sbin/depmod %{KERNELRELEASE} 114fi 115 116%preun 117if [ -x /usr/bin/kernel-install ]; then 118kernel-install remove %{KERNELRELEASE} 119fi 120 121%files -f %{buildroot}/kernel.list 122%defattr (-, root, root) 123%exclude /kernel.list 124 125%files headers 126%defattr (-, root, root) 127/usr/include 128 129%if %{with_devel} 130%files devel 131%defattr (-, root, root) 132/usr/src/kernels/%{KERNELRELEASE} 133/lib/modules/%{KERNELRELEASE}/build 134%endif 135