kernel-tfg/master.inc

203 lines
6.6 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
Name: kernel-%{kname}-tfg
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 make make KERNELRELEASE=%{KVERREL}
Source2: https://git.resf.org/thefossguy/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
Obsoletes: kernel-%{kname}-headers-tfg
Provides: kernel-%{kname}-headers-tfg = %{KVERREL}
%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
Provides: kernel-%{kname}-devel-tfg = %{KVERREL}
AutoReqProv: no
%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}
find ../../SOURCES -type f -name "patch-*.patch" -print0 | sort -z | xargs --no-run-if-empty -t -0 -n 1 patch -p1 -i
# 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 >/dev/null 2>&1
[ -f .config ] && rm -vf .config*
%{make} distclean
%{make} "${EXTRA_LINUX_CONFIG[@]}" %{target_config}
tar -xf %{SOURCE2} -C .
cp -vr kernel-tfg/{configure-linux.sh,extra-configs} .
rm -rf kernel-tfg/
./configure-linux.sh
# "remake" the .config since './scripts/config' does not handle dependencies at all
make olddefconfig
# diff for viewing later :)
# 0 means no diff /diff [1/4]
# 1 means diff
# 2 means trouble
diff .config .config.old || echo "Diffing done"
%build
%{make} %{?_smp_mflags} PYTHON=%{__python3} %{make_targets}
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
# install the kernel
mkdir -p $RPM_BUILD_ROOT/boot
cp $(%{make} -s image_name) $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL}
chmod 755 $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL}
echo "%{KVERREL}" > $RPM_BUILD_ROOT/boot/.uname-%{KVERREL}
# install DTBs
%ifarch aarch64 || riscv64
%{make} %{?_smp_mflags} INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/boot/dtb-%{KVERREL} dtbs_install
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.
%if "%{name}" == "kernel-next-tfg"
%{make} %{?_smp_mflags} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$RPM_BUILD_ROOT mod-fw= DEPMOD=/doesnt/exist modules_install
%else
%{make} %{?_smp_mflags} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$RPM_BUILD_ROOT mod-fw= modules_install
%endif
# install headers
%{make} %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install
# install other key files too
install -m 644 .config $RPM_BUILD_ROOT/boot/config-%{KVERREL}
install -m 644 .config $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/config
install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-%{KVERREL}
install -m 644 System.map $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/System.map
# fix links
rm -rf $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/build
rm -rf $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/source
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
# install actual Linux src to /usr/src/kernels/%{KVERREL}
mkdir -p $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}
if [ -f scripts/package/install-extmod-build ]; then
%{make} run-command KBUILD_RUN_COMMAND='${RPM_BUILD_DIR}/%{src_dir}/scripts/package/install-extmod-build $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}'
else
touch $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}/MAYBE_THIS_WORKS
fi
%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
ln /boot/.uname-%{KVERREL} /boot/.uname
%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 headers
%defattr (-, root, root)
/usr/include
%files devel
%defattr (-, root, root)
/usr/src/kernels/%{KVERREL}
/lib/modules/%{KVERREL}/build
/lib/modules/%{KVERREL}/source
%files
%defattr (-, root, root)
%exclude /lib/modules/%{KVERREL}/build
%exclude /lib/modules/%{KVERREL}/source
/lib/modules/%{KVERREL}
/boot/.uname-%{KVERREL}
/boot/*