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 6Name: kernel 7Summary: The Linux Kernel 8Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') 9Release: %{pkg_release} 10License: GPL 11Group: System Environment/Kernel 12Vendor: The Linux Community 13URL: https://www.kernel.org 14Source0: linux.tar.gz 15Source1: config 16Source2: diff.patch 17Provides: kernel-%{KERNELRELEASE} 18BuildRequires: bc binutils bison dwarves 19BuildRequires: (elfutils-devel or libdw-devel) 20BuildRequires: (elfutils-libelf-devel or libelf-devel) flex 21BuildRequires: gcc make openssl openssl-devel perl python3 rsync 22 23%description 24The Linux Kernel, the operating system core itself 25 26%package headers 27Summary: Header files for the Linux kernel for use by glibc 28Group: Development/System 29Obsoletes: kernel-headers < %{version} 30Provides: kernel-headers = %{version} 31%description headers 32Kernel-headers includes the C header files that specify the interface 33between the Linux kernel and userspace libraries and programs. The 34header files define structures and constants that are needed for 35building most standard programs and are also needed for rebuilding the 36glibc package. 37 38%if %{with_devel} 39%package devel 40Summary: Development package for building kernel modules to match the %{version} kernel 41Group: System Environment/Kernel 42AutoReqProv: no 43%description -n kernel-devel 44This package provides kernel headers and makefiles sufficient to build modules 45against the %{version} kernel package. 46%endif 47 48%if %{with_debuginfo} 49# list of debuginfo-related options taken from distribution kernel.spec 50# files 51%undefine _include_minidebuginfo 52%undefine _find_debuginfo_dwz_opts 53%undefine _unique_build_ids 54%undefine _unique_debug_names 55%undefine _unique_debug_srcs 56%undefine _debugsource_packages 57%undefine _debuginfo_subpackages 58%global _find_debuginfo_opts -r 59%global _missing_build_ids_terminate_build 1 60%global _no_recompute_build_ids 1 61%{debug_package} 62%endif 63# some (but not all) versions of rpmbuild emit %%debug_package with 64# %%install. since we've already emitted it manually, that would cause 65# a package redefinition error. ensure that doesn't happen 66%define debug_package %{nil} 67 68# later, we make all modules executable so that find-debuginfo.sh strips 69# them up. but they don't actually need to be executable, so remove the 70# executable bit, taking care to do it _after_ find-debuginfo.sh has run 71%define __spec_install_post \ 72 %{?__debug_package:%{__debug_install_post}} \ 73 %{__arch_install_post} \ 74 %{__os_install_post} \ 75 find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\ 76 | xargs --no-run-if-empty chmod u-x 77 78%prep 79%setup -q -n linux 80cp %{SOURCE1} .config 81patch -p1 < %{SOURCE2} 82 83%build 84%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} 85 86%install 87mkdir -p %{buildroot}/lib/modules/%{KERNELRELEASE} 88cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz 89# DEPMOD=true makes depmod no-op. We do not package depmod-generated files. 90%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} DEPMOD=true modules_install 91%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install 92cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE} 93cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config 94if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then 95 %{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install 96fi 97ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build 98%if %{with_devel} 99%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' 100%endif 101 102{ 103 echo "/lib/modules/%{KERNELRELEASE}" 104 105 for x in alias alias.bin builtin.alias.bin builtin.bin dep dep.bin \ 106 devname softdep symbols symbols.bin weakdep; do 107 echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}" 108 done 109 110 for x in System.map config vmlinuz; do 111 echo "%ghost /boot/${x}-%{KERNELRELEASE}" 112 done 113 114 if [ -d "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" ];then 115 find "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" -printf "%%%ghost /boot/dtb-%{KERNELRELEASE}/%%P\n" 116 fi 117 118 echo "%exclude /lib/modules/%{KERNELRELEASE}/build" 119} > %{buildroot}/kernel.list 120 121# make modules executable so that find-debuginfo.sh strips them. this 122# will be undone later in %%__spec_install_post 123find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \ 124 | xargs --no-run-if-empty chmod u+x 125 126%if %{with_debuginfo} 127# copying vmlinux directly to the debug directory means it will not get 128# stripped (but its source paths will still be collected + fixed up) 129mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} 130cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} 131%endif 132 133%clean 134rm -rf %{buildroot} 135rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \ 136 elfbins.list 137 138%post 139if [ -x /usr/bin/kernel-install ]; then 140 /usr/bin/kernel-install add %{KERNELRELEASE} /lib/modules/%{KERNELRELEASE}/vmlinuz 141fi 142for file in vmlinuz System.map config; do 143 if ! cmp --silent "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"; then 144 cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}" 145 fi 146done 147if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ] && \ 148 ! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" >/dev/null 2>&1; then 149 rm -rf "/boot/dtb-%{KERNELRELEASE}" 150 cp -r "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" 151fi 152if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then 153 /usr/sbin/depmod %{KERNELRELEASE} 154fi 155 156%preun 157if [ -x /usr/bin/kernel-install ]; then 158kernel-install remove %{KERNELRELEASE} 159fi 160 161%files -f %{buildroot}/kernel.list 162%defattr (-, root, root) 163%exclude /kernel.list 164 165%files headers 166%defattr (-, root, root) 167/usr/include 168 169%if %{with_devel} 170%files devel 171%defattr (-, root, root) 172/usr/src/kernels/%{KERNELRELEASE} 173/lib/modules/%{KERNELRELEASE}/build 174%endif 175