init commit

This commit is contained in:
Pratham Patel 2023-09-12 16:49:32 +05:30
commit b756208efc
No known key found for this signature in database
8 changed files with 324 additions and 0 deletions

39
configure-linux.sh Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -xeu
export EXTRA_LINUX_MODULES=()
export EXTRA_LINUX_BUILTIN=()
EXTRA_LINUX_CONFIG=()
for FILE in ./extra-configs/*.sh; do
source "${FILE}"
done
if [[ "${EXTRA_LINUX_MODULES[*]}" != "" ]]; then
for CONFIG_MODULE in "${EXTRA_LINUX_MODULES[@]}"; do
EXTRA_LINUX_CONFIG+=("${CONFIG_MODULE}"'=m')
done
fi
if [[ "${EXTRA_LINUX_BUILTIN[*]}" != "" ]]; then
for CONFIG_BUILTIN in "${EXTRA_LINUX_BUILTIN[@]}"; do
EXTRA_LINUX_CONFIG+=("${CONFIG_BUILTIN}"'=y')
done
fi
function verify_config {
[[ "${EXTRA_LINUX_CONFIG[*]}" == "" ]] && >&2 echo '**** WARNING: List of extra config options to check is empty, doing nothing.'
if [[ ! -f .config ]]; then
>&2 echo '**** ERROR: The config file could not be found.'
exit 1
fi
for CONFIG_OPTION in "${EXTRA_LINUX_CONFIG[@]}"; do
if ! grep "${CONFIG_OPTION}" .config 2>&1 /dev/null; then
>&2 echo "**** ERROR: Config option '${CONFIG_OPTION}' not found in the config file."
exit 1
fi
done
}

23
extra-configs/r8169.sh Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
EXTRA_LINUX_MODULES+=('CONFIG_R8169')
# Q: What requires this option to be enabled?
# A: Enabling this option adds support for the Realtek RTL8125 2.5GbE Controller
# that is present on the Radxa Rock 5 Model B SBC, connected via the PCIe bus.
# ```sh
# $ sudo lspci -k
# 0004:01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
# Subsystem: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller
# Kernel driver in use: r8169
# Kernel modules: r8169
# ```
#
# Q: Why wasn't this option enabled by `make defconfig`?
# A: There are two reasons for this:
# 1. None of the symbols that are enabled by the defconfig (built-in or
# otherwise)--that are needed by CONFIG_R8169--"select" this option. The
# dependencies are already enabled (built-in or otherwise). So all that
# needs to be done is to enable this tristate module as a **loadable module**.
# 2. Since this Ethernet controller is connected via the PCIe bus and is not
# the Ethernet PHY offered by the RK3588 SoC itself, it is not selected
# by 'CONFIG_ARCH_ROCKCHIP' either.

15
kernel-collabora-tfg.spec Normal file
View File

@ -0,0 +1,15 @@
# change version here
%global fake_ver 1
%global rel_ver 0
%global commit_id b034abfca55f329be85c37a84768775c60f52885
%global short_commit_id b034abfc
Name: kernel-collabora-tfg
Version: %{fake_ver}.%{short_commit_id}
Release: %{rel_ver}%{?dist}
Source0: https://gitlab.collabora.com/hardware-enablement/rockchip-3588/linux/-/archive/%{commit_id}.tar.gz
Source1: master.inc
%global src_dir linux-%{commit_id}
%include %{SOURCE1}

18
kernel-lts-tfg.spec Normal file
View File

@ -0,0 +1,18 @@
# change version here
%global rel_ver 0
%global major_ver 6
%global minor_ver 1
%global patch_ver 52
%global lts_flag 1
Name: kernel-lts-tfg
Version: %{major_ver}.%{minor_ver}.%{patch_ver}
Release: %{rel_ver}%{?dist}
BuildRequires: gnupg2
Source0: https://cdn.kernel.org/pub/linux/kernel/v%{major_ver}.x/linux-%{version}.tar.gz
Source1: master.inc
Source99: https://cdn.kernel.org/pub/linux/kernel/v%{major_ver}.x/linux-%{version}.tar.sign
%global src_dir linux-%{version}
%include %{SOURCE1}

13
kernel-next-tfg.spec Normal file
View File

@ -0,0 +1,13 @@
# change version here
%global rel_ver 0
%global next_snapshot_date 20230911
Name: kernel-next-tfg
Version: %{next_snapshot_date}
Release: %{rel_ver}%{?dist}
Source0: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/snapshot/linux-next-next-%{next_snapshot_date}.tar.gz
Source1: master.inc
%global src_dir linux-next-next-%{next_snapshot_date}
%include %{SOURCE1}

15
kernel-rc-tfg.spec Normal file
View File

@ -0,0 +1,15 @@
# change version here
%global rel_ver 0
%global major_ver 6
%global minor_ver 6
%global rc_ver 1
Name: kernel-rc-tfg
Version: %{major_ver}.%{minor_ver}.0
Release: rc%{rc_ver}.%{rel_ver}%{?dist}
Source0: https://git.kernel.org/torvalds/t/linux-%{major_ver}.%{minor_ver}-rc%{rc_ver}.tar.gz
Source1: master.inc
%global src_dir linux-%{major_ver}.%{minor_ver}-rc%{rc_ver}
%include %{SOURCE1}

17
kernel-stable-tfg.spec Normal file
View File

@ -0,0 +1,17 @@
# change version here
%global rel_ver 0
%global major_ver 6
%global minor_ver 5
%global patch_ver 2
Name: kernel-stable-tfg
Version: %{major_ver}.%{minor_ver}.%{patch_ver}
Release: %{rel_ver}%{?dist}
BuildRequires: gnupg2
Source0: https://cdn.kernel.org/pub/linux/kernel/v%{major_ver}.x/linux-%{version}.tar.gz
Source1: master.inc
Source99: https://cdn.kernel.org/pub/linux/kernel/v%{major_ver}.x/linux-%{version}.tar.sign
%global src_dir linux-%{version}
%include %{SOURCE1}

184
master.inc Normal file
View File

@ -0,0 +1,184 @@
%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}