diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2023-07-22 13:48:02 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2023-07-25 00:59:33 +0900 |
commit | 49c803cd919d39321979494aa39417b2ffd22e1e (patch) | |
tree | ab5f73cb78685c3bc42211667475c61f308e3bb9 | |
parent | 2a291fc315b6aec2f209aa44da90515ddd4f89d0 (diff) |
kbuild: rpm-pkg: split out the body of spec file
Most of the lines in the spec file are independent of any build
condition.
Split the body of the spec file into scripts/package/kernel.spec.
scripts/package/mkspec will prepend some env-dependent variables.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-rw-r--r-- | scripts/package/kernel.spec | 117 | ||||
-rwxr-xr-x | scripts/package/mkspec | 123 |
2 files changed, 120 insertions, 120 deletions
diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec new file mode 100644 index 000000000000..ac3f2ee6d7a0 --- /dev/null +++ b/scripts/package/kernel.spec @@ -0,0 +1,117 @@ +# _arch is undefined if /usr/lib/rpm/platform/*/macros was not included. +%{!?_arch: %define _arch dummy} +%{!?make: %define make make} +%define makeflags %{?_smp_mflags} ARCH=%{ARCH} +%define __spec_install_post /usr/lib/rpm/brp-compress || : +%define debug_package %{nil} + +Name: kernel +Summary: The Linux Kernel +Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') +Release: %{pkg_release} +License: GPL +Group: System Environment/Kernel +Vendor: The Linux Community +URL: https://www.kernel.org +Source0: linux.tar.gz +Source1: config +Source2: diff.patch +Provides: kernel-%{KERNELRELEASE} +BuildRequires: bc binutils bison dwarves +BuildRequires: (elfutils-libelf-devel or libelf-devel) flex +BuildRequires: gcc make openssl openssl-devel perl python3 rsync + +%description +The Linux Kernel, the operating system core itself + +%package headers +Summary: Header files for the Linux kernel for use by glibc +Group: Development/System +Obsoletes: kernel-headers +Provides: kernel-headers = %{version} +%description headers +Kernel-headers includes the C header files that specify the interface +between the Linux kernel and userspace libraries and programs. The +header files define structures and constants that are needed for +building most standard programs and are also needed for rebuilding the +glibc package. + +%if %{with_devel} +%package devel +Summary: Development package for building kernel modules to match the %{version} kernel +Group: System Environment/Kernel +AutoReqProv: no +%description -n kernel-devel +This package provides kernel headers and makefiles sufficient to build modules +against the %{version} kernel package. +%endif + +%prep +%setup -q -n linux +cp %{SOURCE1} .config +patch -p1 < %{SOURCE2} + +%build +%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} + +%install +mkdir -p %{buildroot}/boot +%ifarch ia64 +mkdir -p %{buildroot}/boot/efi +cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE} +ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/ +%else +cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} +%endif +%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install +%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install +cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} +cp .config %{buildroot}/boot/config-%{KERNELRELEASE} +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source +%if %{with_devel} +%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' +%endif + +%clean +rm -rf %{buildroot} + +%post +if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then +cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm +cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm +rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE} +/sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm +rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm +fi + +%preun +if [ -x /sbin/new-kernel-pkg ]; then +new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img +elif [ -x /usr/bin/kernel-install ]; then +kernel-install remove %{KERNELRELEASE} +fi + +%postun +if [ -x /sbin/update-bootloader ]; then +/sbin/update-bootloader --remove %{KERNELRELEASE} +fi + +%files +%defattr (-, root, root) +/lib/modules/%{KERNELRELEASE} +%exclude /lib/modules/%{KERNELRELEASE}/build +%exclude /lib/modules/%{KERNELRELEASE}/source +/boot/* + +%files headers +%defattr (-, root, root) +/usr/include + +%if %{with_devel} +%files devel +%defattr (-, root, root) +/usr/src/kernels/%{KERNELRELEASE} +/lib/modules/%{KERNELRELEASE}/build +/lib/modules/%{KERNELRELEASE}/source +%endif diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 511cae46a90d..c08567ae7fb1 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -23,127 +23,10 @@ else echo '%define with_devel 0' fi -cat<<-EOF +cat<<EOF %define ARCH ${ARCH} %define KERNELRELEASE ${KERNELRELEASE} %define pkg_release $("${srctree}/init/build-version") - -# _arch is undefined if /usr/lib/rpm/platform/*/macros was not included. -%{!?_arch: %define _arch dummy} -%{!?make: %define make make} -%define makeflags %{?_smp_mflags} ARCH=%{ARCH} - - Name: kernel - Summary: The Linux Kernel - Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') - Release: %{pkg_release} - License: GPL - Group: System Environment/Kernel - Vendor: The Linux Community - URL: https://www.kernel.org - Source0: linux.tar.gz - Source1: config - Source2: diff.patch - Provides: kernel-%{KERNELRELEASE} - BuildRequires: bc binutils bison dwarves - BuildRequires: (elfutils-libelf-devel or libelf-devel) flex - BuildRequires: gcc make openssl openssl-devel perl python3 rsync - - %define __spec_install_post /usr/lib/rpm/brp-compress || : - %define debug_package %{nil} - - %description - The Linux Kernel, the operating system core itself - - %package headers - Summary: Header files for the Linux kernel for use by glibc - Group: Development/System - Obsoletes: kernel-headers - Provides: kernel-headers = %{version} - %description headers - Kernel-headers includes the C header files that specify the interface - between the Linux kernel and userspace libraries and programs. The - header files define structures and constants that are needed for - building most standard programs and are also needed for rebuilding the - glibc package. - - %if %{with_devel} - %package devel - Summary: Development package for building kernel modules to match the %{version} kernel - Group: System Environment/Kernel - AutoReqProv: no - %description -n kernel-devel - This package provides kernel headers and makefiles sufficient to build modules - against the %{version} kernel package. - %endif - - %prep - %setup -q -n linux - cp %{SOURCE1} .config - patch -p1 < %{SOURCE2} - - %build - %{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} - - %install - mkdir -p %{buildroot}/boot - %ifarch ia64 - mkdir -p %{buildroot}/boot/efi - cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE} - ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/ - %else - cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} - %endif - %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install - %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install - cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} - cp .config %{buildroot}/boot/config-%{KERNELRELEASE} - ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build - ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source - %if %{with_devel} - %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' - %endif - - %clean - rm -rf %{buildroot} - - %post - if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then - cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm - cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm - rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE} - /sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm - rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm - fi - - %preun - if [ -x /sbin/new-kernel-pkg ]; then - new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img - elif [ -x /usr/bin/kernel-install ]; then - kernel-install remove %{KERNELRELEASE} - fi - - %postun - if [ -x /sbin/update-bootloader ]; then - /sbin/update-bootloader --remove %{KERNELRELEASE} - fi - - %files - %defattr (-, root, root) - /lib/modules/%{KERNELRELEASE} - %exclude /lib/modules/%{KERNELRELEASE}/build - %exclude /lib/modules/%{KERNELRELEASE}/source - /boot/* - - %files headers - %defattr (-, root, root) - /usr/include - - %if %{with_devel} - %files devel - %defattr (-, root, root) - /usr/src/kernels/%{KERNELRELEASE} - /lib/modules/%{KERNELRELEASE}/build - /lib/modules/%{KERNELRELEASE}/source - %endif EOF + +cat "${srctree}/scripts/package/kernel.spec" |