%global debug_package %{nil} # Disabling strict shebang verification in the kernel module directory (solves the ambiguous python shebang error) %global __brp_mangle_shebangs_exclude_from ^/lib/modules/.* %global __provides_exclude_from ^/lib/modules/.*\.ko$ %global __requires_exclude_from ^/lib/modules/.*\.ko$ %define kernel_flavor xanmod Name: kernel-xanmod Version: 7.1.9 Release: 1%{?dist} Summary: Linux XanMod Kernel optimized for x86_64-v2 License: GPL-2.0-only URL: https://xanmod.org/ Source0: https://gitlab.com/xanmod/linux/-/archive/%{version}-xanmod1.tar.bz2 BuildRequires: bc, bison, flex, gcc, gcc-c++, make, openssl, perl, python3 BuildRequires: openssl-devel, elfutils-libelf-devel, dwarves, ncurses-devel BuildRequires: tar, xz, zstd, kmod, dracut, grubby, rsync, findutils Requires(post): dracut, grubby, kmod Requires(postun): dracut, grubby %global kernel_release %{version}-%{release}.%{kernel_flavor} %description The Linux XanMod kernel with custom settings and new features, built to provide a stable, responsive and smooth desktop experience. Optimized for x86_64-v2 instruction set. %package devel Summary: Development files for the %{kernel_flavor} kernel Requires: %{name} = %{version}-%{release} Provides: kernel-devel = %{version} Provides: kernel-%{kernel_flavor}-devel = %{version} %description devel This package contains the kernel headers and makefiles sufficient to build external modules against the %{name} kernel package. %prep #GitLab adds the hash of the commit to the folder name inside the archive. # We unpack it manually and rename it to a predictable name so as not to hardcode the hash. rm -rf linux-%{version}-xanmod1 tar -xjf %{SOURCE0} mv linux-%{version}-xanmod1-* linux-%{version}-xanmod1 cd linux-%{version}-xanmod1 echo "Using XanMod default config from CONFIGS/x86_64/config" cp CONFIGS/x86_64/config .config %build # Install the local version of the kernel sed -i "s/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=\"-%{kernel_flavor}\"/" .config scripts/config --disable CONFIG_DEBUG_INFO scripts/config --disable CONFIG_DEBUG_INFO_BTF scripts/config --disable CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT # Applying the changes to the configuration make ARCH=x86 olddefconfig make %{?_smp_mflags} ARCH=x86 %install KREL=$(make -s ARCH=x86 kernelrelease) echo "Installing kernel with release string: ${KREL}" install -d %{buildroot}/boot install -d %{buildroot}/lib/modules/${KREL} install -d %{buildroot}/etc/dracut.conf.d install -m 0644 arch/x86/boot/bzImage %{buildroot}/boot/vmlinuz-${KREL} install -m 0644 System.map %{buildroot}/boot/System.map-${KREL} install -m 0644 .config %{buildroot}/boot/config-${KREL} # INSTALL_MOD_STRIP=1 removes debugging symbols from .ko modules, speeding up installation and reducing size make ARCH=x86 \ INSTALL_MOD_PATH=%{buildroot} \ INSTALL_MOD_STRIP=1 \ DEPMOD=/bin/true \ modules_install rm -f %{buildroot}/lib/modules/${KREL}/build rm -f %{buildroot}/lib/modules/${KREL}/source mkdir -p %{buildroot}/lib/modules/${KREL}/build # Copy only what is necessary to build external modules rsync -a --exclude='*.o' \ --exclude='*.ko' \ --exclude='*.cmd' \ --exclude='.tmp_*' \ --exclude='*.mod.c' \ --exclude='modules.order' \ --exclude='Module.markers' \ --exclude='.git*' \ --exclude='Documentation' \ --exclude='tools' \ . %{buildroot}/lib/modules/${KREL}/build/ cp Module.symvers %{buildroot}/lib/modules/${KREL}/build/ cp System.map %{buildroot}/lib/modules/${KREL}/build/ cp .config %{buildroot}/lib/modules/${KREL}/build/ cp modules.builtin %{buildroot}/lib/modules/${KREL}/ if [ -f modules.builtin.alias ]; then cp modules.builtin.alias %{buildroot}/lib/modules/${KREL}/ fi if [ -f modules.builtin.modinfo ]; then cp modules.builtin.modinfo %{buildroot}/lib/modules/${KREL}/ fi ln -sf build %{buildroot}/lib/modules/${KREL}/source cat > %{buildroot}/etc/dracut.conf.d/90-xanmod.conf <<'EOF' omit_dracutmodules+=" rsync " EOF echo "${KREL}" > %{buildroot}/boot/.kernel-release-%{kernel_flavor} %post KREL=$(cat /boot/.kernel-release-%{kernel_flavor} 2>/dev/null || echo "") if [ -n "${KREL}" ] && [ -d "/lib/modules/${KREL}" ]; then echo "Regenerating module dependencies for ${KREL}..." /sbin/depmod -a "${KREL}" echo "Generating initramfs for kernel ${KREL}..." /usr/bin/dracut --force --kver "${KREL}" "/boot/initramfs-${KREL}.img" if [ -x /usr/sbin/grubby ]; then echo "Adding kernel to GRUB bootloader via grubby..." /usr/sbin/grubby --add-kernel="/boot/vmlinuz-${KREL}" \ --initrd="/boot/initramfs-${KREL}.img" \ --title="AlmaLinux (${KREL}) XanMod" \ --make-default || true fi fi %preun if [ "$1" = "0" ]; then KREL=$(cat /boot/.kernel-release-%{kernel_flavor} 2>/dev/null || echo "") if [ -n "${KREL}" ]; then echo "Removing initramfs and bootloader entry for kernel ${KREL}..." rm -f "/boot/initramfs-${KREL}.img" /usr/sbin/grubby --remove-kernel="/boot/vmlinuz-${KREL}" || true fi fi %postun if [ "$1" = "0" ]; then KREL=$(cat /boot/.kernel-release-%{kernel_flavor} 2>/dev/null || echo "") if [ -n "${KREL}" ]; then /sbin/depmod -a fi fi %files %defattr(-,root,root) /boot/vmlinuz-*%{kernel_flavor}* /boot/System.map-*%{kernel_flavor}* /boot/config-*%{kernel_flavor}* /boot/.kernel-release-%{kernel_flavor} /lib/modules/*%{kernel_flavor}* %dir /etc/dracut.conf.d %config(noreplace) /etc/dracut.conf.d/90-xanmod.conf %exclude /lib/modules/*%{kernel_flavor}*/build %exclude /lib/modules/*%{kernel_flavor}*/source %files devel %defattr(-,root,root) /lib/modules/*%{kernel_flavor}*/build /lib/modules/*%{kernel_flavor}*/source %changelog * Mon Aug 24 2026 Inga Vesnova - 7.1.9-1 - Fixed ambiguous python shebang error for AlmaLinux 10 - Fixed prep stage to handle GitLab commit hash in directory name dynamically - Disabled DEBUG_INFO and added INSTALL_MOD_STRIP to significantly reduce build time