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