2023-09-12 11:19:32 +00:00
|
|
|
%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
|
|
|
|
|
2023-10-07 14:17:28 +00:00
|
|
|
Name: kernel-%{kname}-tfg
|
2023-09-12 11:19:32 +00:00
|
|
|
Summary: The Linux Kernel
|
|
|
|
License: GPL
|
|
|
|
URL: https://www.kernel.org
|
2023-10-08 07:11:21 +00:00
|
|
|
Provides: kernel-%{kname}-tfg = %{KVERREL}
|
2023-09-12 11:19:32 +00:00
|
|
|
BuildRequires: bc binutils bison dwarves
|
2023-10-09 04:52:43 +00:00
|
|
|
BuildRequires: elfutils-libelf-devel flex
|
2023-10-08 06:51:11 +00:00
|
|
|
BuildRequires: make openssl openssl-devel perl python3 rsync
|
|
|
|
BuildRequires: clang lld llvm llvm-devel
|
2023-09-12 11:19:32 +00:00
|
|
|
BuildRequires: opencsd-devel
|
|
|
|
BuildRequires: kmod
|
2023-10-15 14:57:46 +00:00
|
|
|
BuildRequires: /usr/bin/pathfix.py
|
2023-09-12 11:19:32 +00:00
|
|
|
Requires: coreutils systemd dracut
|
|
|
|
Requires: /usr/bin/kernel-install
|
2023-10-08 05:16:08 +00:00
|
|
|
Requires: /usr/sbin/installkernel
|
2023-09-12 11:19:32 +00:00
|
|
|
Requires: linux-firmware
|
|
|
|
|
|
|
|
%ifarch aarch64
|
|
|
|
%global build_arch arm64
|
2023-10-08 15:50:09 +00:00
|
|
|
%global make_targets olddefconfig Image.gz modules dtbs
|
2023-09-12 11:19:32 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
%ifarch riscv64
|
|
|
|
%global build_arch riscv64
|
2023-10-08 15:50:09 +00:00
|
|
|
%global make_targets olddefconfig Image.gz modules dtbs
|
2023-09-12 11:19:32 +00:00
|
|
|
%endif
|
|
|
|
|
2023-10-08 06:51:11 +00:00
|
|
|
%global make make -j$(( $(nproc) + 2 )) KERNELRELEASE=%{KVERREL}
|
2023-09-12 11:19:32 +00:00
|
|
|
|
2023-10-01 04:41:34 +00:00
|
|
|
Source2: https://git.resf.org/thefossguy/kernel-tfg/archive/master.tar.gz
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
%description
|
|
|
|
The Linux Kernel, the operating system core itself
|
|
|
|
|
|
|
|
%package headers
|
|
|
|
Summary: Header files for the Linux kernel for use by glibc
|
2023-10-07 14:17:28 +00:00
|
|
|
Obsoletes: kernel-%{kname}-headers-tfg
|
|
|
|
Provides: kernel-%{kname}-headers-tfg = %{KVERREL}
|
2023-09-12 11:19:32 +00:00
|
|
|
%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
|
2023-10-07 14:17:28 +00:00
|
|
|
Provides: kernel-%{kname}-devel-tfg = %{KVERREL}
|
2023-09-12 15:58:44 +00:00
|
|
|
AutoReqProv: no
|
2023-09-12 11:19:32 +00:00
|
|
|
%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
|
2023-10-09 07:27:32 +00:00
|
|
|
[ -f ../SOURCES/linux-%{version}.tar ] || gzip --decompress --keep %{SOURCE0}
|
2023-09-12 11:19:32 +00:00
|
|
|
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}
|
2023-10-07 14:11:04 +00:00
|
|
|
find ../../SOURCES -type f -name "patch-*.patch" -print0 | sort -z | xargs --no-run-if-empty -t -0 -n 1 patch -p1 -i
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
# 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 \
|
2023-10-05 01:29:25 +00:00
|
|
|
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 >/dev/null 2>&1
|
2023-09-12 11:19:32 +00:00
|
|
|
|
2023-10-08 06:51:11 +00:00
|
|
|
export LLVM=1 AR=llvm-ar CC=clang HOSTAR=llvm-ar HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld LD=ld.lld NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf STRIP=llvm-strip
|
2023-09-12 11:19:32 +00:00
|
|
|
[ -f .config ] && rm -vf .config*
|
|
|
|
%{make} distclean
|
|
|
|
|
2023-10-24 11:30:43 +00:00
|
|
|
%{make} defconfig
|
2023-10-01 03:09:43 +00:00
|
|
|
|
|
|
|
tar -xf %{SOURCE2} -C .
|
2023-10-28 04:13:47 +00:00
|
|
|
if [ -d 'kernel-tfg/extra-configs' ]; then
|
|
|
|
cp -vr kernel-tfg/{configure-linux.sh,extra-configs} .
|
|
|
|
rm -rf kernel-tfg/
|
|
|
|
./configure-linux.sh
|
|
|
|
else
|
|
|
|
echo "Extra configs not found, not modifying anything"
|
|
|
|
fi
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
%build
|
2023-10-08 06:51:11 +00:00
|
|
|
%{make} PYTHON=%{__python3} %{make_targets}
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
%install
|
2023-10-10 07:52:18 +00:00
|
|
|
rm -rf %{buildroot}
|
|
|
|
mkdir -p %{buildroot}
|
2023-09-12 11:19:32 +00:00
|
|
|
|
2023-09-13 00:14:25 +00:00
|
|
|
# install the kernel
|
2023-10-10 07:52:18 +00:00
|
|
|
mkdir -p %{buildroot}/boot
|
|
|
|
cp $(%{make} -s image_name) %{buildroot}/boot/vmlinuz-%{KVERREL}
|
|
|
|
chmod 755 %{buildroot}/boot/vmlinuz-%{KVERREL}
|
2023-09-13 00:14:25 +00:00
|
|
|
|
2023-09-12 11:19:32 +00:00
|
|
|
# install DTBs
|
|
|
|
%ifarch aarch64 || riscv64
|
2023-10-10 07:52:18 +00:00
|
|
|
%{make} INSTALL_DTBS_PATH=%{buildroot}/boot/dtb-%{KVERREL} dtbs_install
|
2023-10-09 00:12:24 +00:00
|
|
|
# delete "arch/%{build_arch}/boot/dts" because "$PWD" will be packaged in "%devel"
|
2023-09-12 11:19:32 +00:00
|
|
|
find arch/%{build_arch}/boot/dts -name '*.dtb' -type f -delete
|
|
|
|
%endif
|
|
|
|
|
|
|
|
# install modules
|
|
|
|
# '$(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.
|
2023-10-10 07:52:18 +00:00
|
|
|
%{make} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} mod-fw= modules_install
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
# install headers
|
2023-10-10 07:52:18 +00:00
|
|
|
%{make} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
# install other key files too
|
2023-10-10 07:52:18 +00:00
|
|
|
install -m 644 .config %{buildroot}/boot/config-%{KVERREL}
|
|
|
|
install -m 644 .config %{buildroot}/lib/modules/%{KVERREL}/config
|
|
|
|
install -m 644 System.map %{buildroot}/boot/System.map-%{KVERREL}
|
|
|
|
install -m 644 System.map %{buildroot}/lib/modules/%{KVERREL}/System.map
|
2023-09-12 11:19:32 +00:00
|
|
|
|
2023-09-13 00:14:25 +00:00
|
|
|
# fix links
|
2023-10-10 07:52:18 +00:00
|
|
|
rm -rf %{buildroot}/lib/modules/%{KVERREL}/build
|
|
|
|
rm -rf %{buildroot}/lib/modules/%{KVERREL}/source
|
|
|
|
ln -fns /usr/src/kernels/%{KVERREL} %{buildroot}/lib/modules/%{KVERREL}/build
|
|
|
|
ln -fns /usr/src/kernels/%{KVERREL} %{buildroot}/lib/modules/%{KVERREL}/source
|
2023-09-12 11:19:32 +00:00
|
|
|
|
2023-09-13 00:14:25 +00:00
|
|
|
# install actual Linux src to /usr/src/kernels/%{KVERREL}
|
2023-10-10 07:52:18 +00:00
|
|
|
mkdir -p %{buildroot}/usr/src/kernels/%{KVERREL}
|
2023-10-04 06:46:17 +00:00
|
|
|
if [ -f scripts/package/install-extmod-build ]; then
|
2023-10-10 07:52:18 +00:00
|
|
|
%{make} run-command KBUILD_RUN_COMMAND='%{_builddir}/%{src_dir}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KVERREL}'
|
2023-10-04 06:46:17 +00:00
|
|
|
else
|
2023-10-17 03:31:33 +00:00
|
|
|
touch %{buildroot}/usr/src/kernels/%{KVERREL}/EMPTY
|
2023-10-04 06:46:17 +00:00
|
|
|
fi
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
%clean
|
2023-10-10 07:52:18 +00:00
|
|
|
rm -rf %{buildroot}
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
%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
|
2023-10-08 10:20:17 +00:00
|
|
|
|
2023-09-12 11:19:32 +00:00
|
|
|
%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
|
2023-10-09 00:12:24 +00:00
|
|
|
[ -d /boot/dtb ] && rm -rf /boot/dtb
|
2023-09-12 11:19:32 +00:00
|
|
|
|
|
|
|
%files headers
|
2023-09-12 15:58:44 +00:00
|
|
|
%defattr (-, root, root)
|
2023-09-12 11:19:32 +00:00
|
|
|
/usr/include
|
|
|
|
|
|
|
|
%files devel
|
2023-09-12 15:58:44 +00:00
|
|
|
%defattr (-, root, root)
|
2023-09-12 11:19:32 +00:00
|
|
|
/usr/src/kernels/%{KVERREL}
|
2023-09-12 15:58:44 +00:00
|
|
|
/lib/modules/%{KVERREL}/build
|
|
|
|
/lib/modules/%{KVERREL}/source
|
2023-09-12 13:06:28 +00:00
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr (-, root, root)
|
2023-09-13 00:14:25 +00:00
|
|
|
%exclude /lib/modules/%{KVERREL}/build
|
|
|
|
%exclude /lib/modules/%{KVERREL}/source
|
2023-09-12 13:06:28 +00:00
|
|
|
/lib/modules/%{KVERREL}
|
|
|
|
/boot/*
|