2005-04-16 22:20:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2013-07-08 17:14:06 +00:00
|
|
|
# Output a simple RPM spec file.
|
2023-01-11 10:11:56 +00:00
|
|
|
# This version assumes a minimum of RPM 4.13
|
2005-04-16 22:20:36 +00:00
|
|
|
#
|
|
|
|
# The only gothic bit here is redefining install_post to avoid
|
|
|
|
# stripping the symbols from files in the kernel which we want
|
|
|
|
#
|
|
|
|
# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
|
|
|
|
#
|
|
|
|
|
|
|
|
# how we were called determines which rpms we build and how we build them
|
2023-07-22 04:48:01 +00:00
|
|
|
if [ -z "$1" ]; then
|
2023-03-15 15:50:17 +00:00
|
|
|
mkdir -p rpmbuild/SOURCES
|
|
|
|
cp linux.tar.gz rpmbuild/SOURCES
|
|
|
|
cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config
|
kbuild: give up untracked files for source package builds
When the source tree is dirty and contains untracked files, package
builds may fail, for example, when a broken symlink exists, a file
path contains whitespaces, etc.
Since commit 05e96e96a315 ("kbuild: use git-archive for source package
creation"), the source tarball only contains committed files because
it is created by 'git archive'. scripts/package/gen-diff-patch tries
to address the diff from HEAD, but including untracked files by the
hand-crafted script introduces more complexity. I wrote a patch [1] to
make it work in most cases, but still wonder if this is what we should
aim for.
To simplify the code, this patch just gives up untracked files. Going
forward, it is your responsibility to do 'git add' for what you want in
the source package. The script shows a warning just in case you forgot
to do so. It should be checked only when building source packages.
[1]: https://lore.kernel.org/all/CAK7LNAShbZ56gSh9PrbLnBDYKnjtTkHMoCXeGrhcxMvqXGq9=g@mail.gmail.com/2-0001-kbuild-make-package-builds-more-robust.patch
Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2023-04-10 12:09:07 +00:00
|
|
|
"${srctree}/scripts/package/gen-diff-patch" rpmbuild/SOURCES/diff.patch
|
2005-04-16 22:20:36 +00:00
|
|
|
fi
|
|
|
|
|
2023-03-15 15:50:17 +00:00
|
|
|
if grep -q CONFIG_MODULES=y include/config/auto.conf; then
|
2023-07-22 04:48:01 +00:00
|
|
|
echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}'
|
2017-09-30 01:10:07 +00:00
|
|
|
else
|
2023-07-22 04:48:01 +00:00
|
|
|
echo '%define with_devel 0'
|
2017-09-30 01:10:07 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-22 04:48:01 +00:00
|
|
|
cat<<-EOF
|
2023-07-22 04:47:52 +00:00
|
|
|
%define ARCH ${ARCH}
|
2023-07-22 04:47:54 +00:00
|
|
|
%define KERNELRELEASE ${KERNELRELEASE}
|
2023-07-22 04:47:59 +00:00
|
|
|
%define pkg_release $("${srctree}/init/build-version")
|
2023-07-22 04:47:52 +00:00
|
|
|
|
2023-07-22 04:47:58 +00:00
|
|
|
# _arch is undefined if /usr/lib/rpm/platform/*/macros was not included.
|
|
|
|
%{!?_arch: %define _arch dummy}
|
2023-07-22 04:47:50 +00:00
|
|
|
%{!?make: %define make make}
|
2023-07-22 04:47:52 +00:00
|
|
|
%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
|
2023-07-22 04:47:50 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
Name: kernel
|
|
|
|
Summary: The Linux Kernel
|
2023-07-22 04:47:57 +00:00
|
|
|
Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g')
|
2023-07-22 04:47:59 +00:00
|
|
|
Release: %{pkg_release}
|
2017-09-30 01:10:06 +00:00
|
|
|
License: GPL
|
|
|
|
Group: System Environment/Kernel
|
|
|
|
Vendor: The Linux Community
|
2020-07-19 19:46:02 +00:00
|
|
|
URL: https://www.kernel.org
|
2023-07-22 04:47:59 +00:00
|
|
|
Source0: linux.tar.gz
|
|
|
|
Source1: config
|
|
|
|
Source2: diff.patch
|
2023-07-22 04:47:54 +00:00
|
|
|
Provides: kernel-%{KERNELRELEASE}
|
2023-07-22 04:47:59 +00:00
|
|
|
BuildRequires: bc binutils bison dwarves
|
|
|
|
BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
|
|
|
|
BuildRequires: gcc make openssl openssl-devel perl python3 rsync
|
2022-11-21 14:48:45 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%define __spec_install_post /usr/lib/rpm/brp-compress || :
|
|
|
|
%define debug_package %{nil}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%description
|
|
|
|
The Linux Kernel, the operating system core itself
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%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.
|
2017-09-30 01:10:05 +00:00
|
|
|
|
2023-07-22 04:48:01 +00:00
|
|
|
%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
|
|
|
|
|
2023-07-22 04:47:59 +00:00
|
|
|
%prep
|
|
|
|
%setup -q -n linux
|
|
|
|
cp %{SOURCE1} .config
|
|
|
|
patch -p1 < %{SOURCE2}
|
|
|
|
|
|
|
|
%build
|
|
|
|
%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release}
|
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%install
|
2017-09-30 01:10:08 +00:00
|
|
|
mkdir -p %{buildroot}/boot
|
2017-09-30 01:10:06 +00:00
|
|
|
%ifarch ia64
|
2017-09-30 01:10:08 +00:00
|
|
|
mkdir -p %{buildroot}/boot/efi
|
2023-07-22 04:47:54 +00:00
|
|
|
cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE}
|
|
|
|
ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/
|
2017-09-30 01:10:06 +00:00
|
|
|
%else
|
2023-07-22 04:47:54 +00:00
|
|
|
cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE}
|
2017-09-30 01:10:06 +00:00
|
|
|
%endif
|
2023-07-22 04:48:00 +00:00
|
|
|
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install
|
2023-07-22 04:47:51 +00:00
|
|
|
%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
|
2023-07-22 04:47:54 +00:00
|
|
|
cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE}
|
|
|
|
cp .config %{buildroot}/boot/config-%{KERNELRELEASE}
|
2023-07-22 04:48:00 +00:00
|
|
|
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
|
|
|
|
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source
|
2023-07-22 04:48:01 +00:00
|
|
|
%if %{with_devel}
|
|
|
|
%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
|
|
|
|
%endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%clean
|
2017-09-30 01:10:08 +00:00
|
|
|
rm -rf %{buildroot}
|
2009-02-12 05:10:57 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%post
|
2023-07-22 04:47:54 +00:00
|
|
|
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
|
2017-09-30 01:10:06 +00:00
|
|
|
fi
|
2013-07-08 17:14:06 +00:00
|
|
|
|
2017-09-30 01:10:06 +00:00
|
|
|
%preun
|
|
|
|
if [ -x /sbin/new-kernel-pkg ]; then
|
2023-07-22 04:47:54 +00:00
|
|
|
new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img
|
2018-04-11 18:15:24 +00:00
|
|
|
elif [ -x /usr/bin/kernel-install ]; then
|
2023-07-22 04:47:54 +00:00
|
|
|
kernel-install remove %{KERNELRELEASE}
|
2017-09-30 01:10:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
%postun
|
|
|
|
if [ -x /sbin/update-bootloader ]; then
|
2023-07-22 04:47:54 +00:00
|
|
|
/sbin/update-bootloader --remove %{KERNELRELEASE}
|
2017-09-30 01:10:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr (-, root, root)
|
2023-07-22 04:48:00 +00:00
|
|
|
/lib/modules/%{KERNELRELEASE}
|
|
|
|
%exclude /lib/modules/%{KERNELRELEASE}/build
|
|
|
|
%exclude /lib/modules/%{KERNELRELEASE}/source
|
2017-09-30 01:10:06 +00:00
|
|
|
/boot/*
|
|
|
|
|
|
|
|
%files headers
|
|
|
|
%defattr (-, root, root)
|
|
|
|
/usr/include
|
2023-07-22 04:48:01 +00:00
|
|
|
|
|
|
|
%if %{with_devel}
|
|
|
|
%files devel
|
|
|
|
%defattr (-, root, root)
|
|
|
|
/usr/src/kernels/%{KERNELRELEASE}
|
|
|
|
/lib/modules/%{KERNELRELEASE}/build
|
|
|
|
/lib/modules/%{KERNELRELEASE}/source
|
|
|
|
%endif
|
2017-09-30 01:10:06 +00:00
|
|
|
EOF
|