185 lines
6.0 KiB
PHP
185 lines
6.0 KiB
PHP
%global KVERREL %{version}-%{release}.%{_target_cpu}
|
|
|
|
# disable the '-debug{info,source}' pkgs
|
|
%define debug_package %{nil}
|
|
# also disable packaging files in '/usr/lib/.build-id/'
|
|
%define _build_id_links none
|
|
|
|
Summary: The Linux Kernel
|
|
License: GPL
|
|
URL: https://www.kernel.org
|
|
Provides: %{name}-%{KVERREL}
|
|
BuildRequires: bc binutils bison dwarves
|
|
BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
|
|
BuildRequires: gcc make openssl openssl-devel perl python3 rsync
|
|
BuildRequires: opencsd-devel
|
|
BuildRequires: kmod
|
|
BuildRequires: python3-devel
|
|
Requires: coreutils systemd dracut
|
|
Requires: /usr/bin/kernel-install
|
|
Requires: linux-firmware
|
|
|
|
%ifarch aarch64
|
|
%global build_arch arm64
|
|
%global make_targets Image.gz modules dtbs
|
|
%endif
|
|
|
|
%ifarch riscv64
|
|
%global build_arch riscv64
|
|
%global make_targets Image.gz modules dtbs
|
|
%endif
|
|
|
|
%global kernel_image $(make -s image_name)
|
|
%global make make KERNELRELEASE=%{KVERREL}
|
|
|
|
Source2: https://git.thefossguy.com/enterprise-linux/kernel-tfg/archive/master.tar.gz
|
|
|
|
%description
|
|
The Linux Kernel, the operating system core itself
|
|
|
|
%package headers
|
|
Summary: Header files for the Linux kernel for use by glibc
|
|
%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
|
|
|
|
%package devel
|
|
Summary: Development package for building kernel modules to match the kernel
|
|
%description devel
|
|
This package provides kernel headers and makefiles sufficient to build modules
|
|
against the kernel package.
|
|
|
|
%prep
|
|
if [ -f ../SOURCES/linux-%{version}.tar.sign ]; then
|
|
gzip --decompress --keep %{SOURCE0}
|
|
gpg2 --locate-keys torvalds@kernel.org gregkh@kernel.org
|
|
gpg2 --verify %{SOURCE99} || exit 1
|
|
|
|
# not needed anymore, might as well delete it to make space for the
|
|
# build and install phases
|
|
rm -vf linux-%{version}.tar
|
|
fi
|
|
%setup -q -n %{src_dir}
|
|
|
|
# Mangle all Python shebangs to be Python 3 explicitly.
|
|
# -i specifies the interpreter for the shebang
|
|
# -n prevents creating ~backup files
|
|
# -p preserves timestamps
|
|
# This fixes errors such as
|
|
# *** ERROR: ambiguous python shebang in /usr/bin/kvm_stat: #!/usr/bin/python. Change it to python3 (or python2) explicitly.
|
|
# Process all files in the Documentation, scripts and tools directories.
|
|
pathfix.py -i "%{__python3} %{py3_shbang_opts}" -n -p \
|
|
tools/kvm/kvm_stat/kvm_stat \
|
|
scripts/show_delta \
|
|
scripts/jobserver-exec \
|
|
scripts/diffconfig \
|
|
scripts/clang-tools \
|
|
scripts/bloat-o-meter \
|
|
tools \
|
|
scripts \
|
|
Documentation \
|
|
drivers
|
|
|
|
tar -xf %{SOURCE2} -C .
|
|
cp -vr kernel-tfg/{configure-linux.sh,extra-configs} .
|
|
rm -rf kernel-tfg/
|
|
|
|
source ./configure-linux.sh
|
|
|
|
[ -f .config ] && rm -vf .config*
|
|
%{make} distclean
|
|
|
|
%{make} "${EXTRA_LINUX_CONFIG[@]}" defconfig
|
|
verify_config
|
|
|
|
%build
|
|
source ./configure-linux.sh
|
|
%{make} %{?_smp_mflags} PYTHON=%{__python3} %{make_targets}
|
|
verify_config
|
|
|
|
%install
|
|
rm -rf $RPM_BUILD_ROOT
|
|
mkdir -p $RPM_BUILD_ROOT
|
|
|
|
mkdir -p $RPM_BUILD_ROOT/boot
|
|
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
|
|
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KVERREL}
|
|
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/systemtap
|
|
|
|
# install DTBs
|
|
%ifarch aarch64 || riscv64
|
|
%{make} %{?_smp_mflags} dtbs_install INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/boot/dtb-%{KVERREL}
|
|
cp -r $RPM_BUILD_ROOT/boot/dtb-%{KVERREL} $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/dtb
|
|
find arch/%{build_arch}/boot/dts -name '*.dtb' -type f -delete
|
|
%endif
|
|
|
|
# install modules
|
|
# Disable depmod with by passing '/doesnt/exist' to the DEPMOD environment variable.
|
|
# '$(mod-fw)' is overridden because there is no reason to install any firmware
|
|
# since we already have 'linux-firmware' package as the dependency of this package.
|
|
%{make} %{?_smp_mflags} modules_install INSTALL_MOD_PATH=$RPM_BUILD_ROOT DEPMOD=/doesnt/exist mod-fw=
|
|
|
|
# install headers
|
|
%{make} %{?_smp_mflags} headers_install INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr
|
|
|
|
# install other key files too
|
|
cp System.map $RPM_BUILD_ROOT/boot/System.map-%{KVERREL}
|
|
cp .config $RPM_BUILD_ROOT/boot/config-%{KVERREL}
|
|
|
|
# install the kernel
|
|
cp %{kernel_image} $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL}
|
|
chmod 755 $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL}
|
|
cp $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL} $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/vmlinuz
|
|
|
|
# cleanup of sorts
|
|
EXCLUDES="--exclude=SCCS --exclude=BitKeeper --exclude=.svn \
|
|
--exclude=CVS --exclude=.pc --exclude=.hg --exclude=.git \
|
|
--exclude=*vmlinux* --exclude=*.mod \
|
|
--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
|
|
--exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s"
|
|
rm -rf $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/build
|
|
rm -rf $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/source
|
|
mkdir -p $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}
|
|
tar cf - $EXCLUDES . | tar xf - -C $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}
|
|
cd $RPM_BUILD_ROOT/lib/modules/%{KVERREL}
|
|
ln -fns /usr/src/kernels/%{KVERREL} $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/build
|
|
ln -fns /usr/src/kernels/%{KVERREL} $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/source
|
|
|
|
%clean
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
%post
|
|
if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KVERREL} -a -r /boot/System.map-%{KVERREL} ]; then
|
|
cp /boot/vmlinuz-%{KVERREL} /boot/.vmlinuz-%{KVERREL}-rpm
|
|
cp /boot/System.map-%{KVERREL} /boot/.System.map-%{KVERREL}-rpm
|
|
rm -f /boot/vmlinuz-%{KVERREL} /boot/System.map-%{KVERREL}
|
|
/sbin/installkernel %{KVERREL} /boot/.vmlinuz-%{KVERREL}-rpm /boot/.System.map-%{KVERREL}-rpm
|
|
rm -f /boot/.vmlinuz-%{KVERREL}-rpm /boot/.System.map-%{KVERREL}-rpm
|
|
fi
|
|
|
|
%preun
|
|
if [ -x /sbin/new-kernel-pkg ]; then
|
|
new-kernel-pkg --remove %{KVERREL} --rminitrd --initrdfile=/boot/initramfs-%{KVERREL}.img
|
|
elif [ -x /usr/bin/kernel-install ]; then
|
|
kernel-install remove %{KVERREL}
|
|
fi
|
|
|
|
%postun
|
|
if [ -x /sbin/update-bootloader ]; then
|
|
/sbin/update-bootloader --remove %{KVERREL}
|
|
fi
|
|
|
|
%files
|
|
%defattr (-, root, root)
|
|
/boot
|
|
/lib/modules/%{KVERREL}
|
|
|
|
%files headers
|
|
/usr/include
|
|
|
|
%files devel
|
|
/usr/src/kernels/%{KVERREL}
|