1#!/bin/sh 2# 3# Output a simple RPM spec file. 4# This version assumes a minimum of RPM 4.13 5# 6# The only gothic bit here is redefining install_post to avoid 7# stripping the symbols from files in the kernel which we want 8# 9# Patched for non-x86 by Opencon (L) 2002 <[email protected]> 10# 11 12# how we were called determines which rpms we build and how we build them 13if [ -z "$1" ]; then 14 mkdir -p rpmbuild/SOURCES 15 cp linux.tar.gz rpmbuild/SOURCES 16 cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config 17 "${srctree}/scripts/package/gen-diff-patch" rpmbuild/SOURCES/diff.patch 18fi 19 20if grep -q CONFIG_MODULES=y include/config/auto.conf; then 21echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}' 22else 23echo '%define with_devel 0' 24fi 25 26cat<<-EOF 27%define ARCH ${ARCH} 28%define KERNELRELEASE ${KERNELRELEASE} 29%define pkg_release $("${srctree}/init/build-version") 30 31# _arch is undefined if /usr/lib/rpm/platform/*/macros was not included. 32%{!?_arch: %define _arch dummy} 33%{!?make: %define make make} 34%define makeflags %{?_smp_mflags} ARCH=%{ARCH} 35 36 Name: kernel 37 Summary: The Linux Kernel 38 Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') 39 Release: %{pkg_release} 40 License: GPL 41 Group: System Environment/Kernel 42 Vendor: The Linux Community 43 URL: https://www.kernel.org 44 Source0: linux.tar.gz 45 Source1: config 46 Source2: diff.patch 47 Provides: kernel-%{KERNELRELEASE} 48 BuildRequires: bc binutils bison dwarves 49 BuildRequires: (elfutils-libelf-devel or libelf-devel) flex 50 BuildRequires: gcc make openssl openssl-devel perl python3 rsync 51 52 %define __spec_install_post /usr/lib/rpm/brp-compress || : 53 %define debug_package %{nil} 54 55 %description 56 The Linux Kernel, the operating system core itself 57 58 %package headers 59 Summary: Header files for the Linux kernel for use by glibc 60 Group: Development/System 61 Obsoletes: kernel-headers 62 Provides: kernel-headers = %{version} 63 %description headers 64 Kernel-headers includes the C header files that specify the interface 65 between the Linux kernel and userspace libraries and programs. The 66 header files define structures and constants that are needed for 67 building most standard programs and are also needed for rebuilding the 68 glibc package. 69 70 %if %{with_devel} 71 %package devel 72 Summary: Development package for building kernel modules to match the %{version} kernel 73 Group: System Environment/Kernel 74 AutoReqProv: no 75 %description -n kernel-devel 76 This package provides kernel headers and makefiles sufficient to build modules 77 against the %{version} kernel package. 78 %endif 79 80 %prep 81 %setup -q -n linux 82 cp %{SOURCE1} .config 83 patch -p1 < %{SOURCE2} 84 85 %build 86 %{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} 87 88 %install 89 mkdir -p %{buildroot}/boot 90 %ifarch ia64 91 mkdir -p %{buildroot}/boot/efi 92 cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE} 93 ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/ 94 %else 95 cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} 96 %endif 97 %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install 98 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install 99 cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} 100 cp .config %{buildroot}/boot/config-%{KERNELRELEASE} 101 ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build 102 ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source 103 %if %{with_devel} 104 %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' 105 %endif 106 107 %clean 108 rm -rf %{buildroot} 109 110 %post 111 if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then 112 cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm 113 cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm 114 rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE} 115 /sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm 116 rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm 117 fi 118 119 %preun 120 if [ -x /sbin/new-kernel-pkg ]; then 121 new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img 122 elif [ -x /usr/bin/kernel-install ]; then 123 kernel-install remove %{KERNELRELEASE} 124 fi 125 126 %postun 127 if [ -x /sbin/update-bootloader ]; then 128 /sbin/update-bootloader --remove %{KERNELRELEASE} 129 fi 130 131 %files 132 %defattr (-, root, root) 133 /lib/modules/%{KERNELRELEASE} 134 %exclude /lib/modules/%{KERNELRELEASE}/build 135 %exclude /lib/modules/%{KERNELRELEASE}/source 136 /boot/* 137 138 %files headers 139 %defattr (-, root, root) 140 /usr/include 141 142 %if %{with_devel} 143 %files devel 144 %defattr (-, root, root) 145 /usr/src/kernels/%{KERNELRELEASE} 146 /lib/modules/%{KERNELRELEASE}/build 147 /lib/modules/%{KERNELRELEASE}/source 148 %endif 149EOF 150