# This is a spec file for building a custom Linux kernel with a specific patch # for ath10k WiFi driver testing. It has been corrected for COPR builds. # # Author: Gemini # Date: 2025-08-09 # # To build this locally: # 1. Save this file as kernel-custom-ath10k.spec # 2. Install build tools: sudo dnf install rpm-build rpmdevtools # 3. Run: rpmbuild -ba kernel-custom-ath10k.spec # # For COPR, you just need to upload this spec file. # --- Preamble: Metadata and Corrected Versioning --- %define full_commit 19272b37aa4f83ca52bdf9c16d5d81bdd1354494 %define short_commit 19272b37aa4f # --- CORRECTED KERNEL VERSIONING --- # Define all version components separately for clarity and correctness. # The base version number. RPM 'Version' tag cannot contain hyphens. %define kernel_base_ver 6.16.0 # The extra version from the kernel's Makefile for this specific commit. %define kernel_extra_ver rc1 # Our custom identifier for the patch/build. %define custom_id aspm_fix_1 # This is the string that will be passed to the kernel build as LOCALVERSION. # The leading '-' is required by the kernel's build system. %define kernel_localversion -%{custom_id}.g%{short_commit} # This macro defines the *final, predictable kernel release string* that will be generated. # It combines the base version, extra version, and our local version. # This is the single source of truth for all paths and scripts. # Example: 6.16.0-rc1-aspm_fix_1.g19272b37aa4f %define full_kernel_string %{kernel_base_ver}-%{kernel_extra_ver}%{kernel_localversion} Name: kernel-ath Version: %{kernel_base_ver} # The Release tag is structured to be sortable and informative, reflecting the build details. Release: 0.%{kernel_extra_ver}.%{custom_id}.g%{short_commit}%{?dist} Summary: Custom Linux kernel with Qualcomm Atheros ASPM patch License: GPL-2.0-only URL: https://github.com/torvalds/linux/ Source0: https://github.com/torvalds/linux/archive/%{full_commit}.tar.gz # --- Build Dependencies --- BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: make BuildRequires: git BuildRequires: flex BuildRequires: bison BuildRequires: openssl-devel BuildRequires: elfutils-libelf-devel BuildRequires: dwarves BuildRequires: perl-interpreter BuildRequires: python3 BuildRequires: bc BuildRequires: rsync BuildRequires: rust-packaging BuildRequires: kmod BuildRequires: binutils BuildRequires: bindgen BuildRequires: gawk BuildRequires: libselinux-devel BuildRequires: libzstd-devel BuildRequires: zstd BuildRequires: gpg BuildRequires: python3-b4 %description This package provides a custom-built Linux kernel based on git commit %{short_commit}. It includes a patch to fix Active State Power Management (ASPM) issues with some Qualcomm Atheros (ath10k/ath11k) wireless devices. This build is intended for testing purposes only. The final kernel release string is %{full_kernel_string}. # --- %prep: Prepare the source code --- %prep %setup -q -n linux-%{full_commit} echo "--- Initializing git repo for patch application ---" git init -b main git add . git config user.email "mockbuild@localhost" git config user.name "Mock Build" git commit -m "Initial commit of Linux source from tarball" echo "--- Fetching patch with b4 ---" b4 am 20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com echo "--- Applying ASPM patch ---" # Apply the patch from the downloaded mailbox file. Using a wildcard is fine as b4 creates a unique name. git am -3 *.mbx # --- %build: Compile the kernel --- %build echo "--- Configuring the kernel ---" make defconfig # --- FIX: Disable automatic version suffixing --- # This prevents the kernel build from adding its own git hash suffix, # making the final version string completely predictable based on our macros. echo "Disabling CONFIG_LOCALVERSION_AUTO to control the final version string." scripts/config --disable LOCALVERSION_AUTO # Run 'make olddefconfig' again to ensure the configuration is consistent # after our change and to accept defaults for any new options. make olddefconfig echo "--- Building kernel and modules with LOCALVERSION='%{kernel_localversion}' ---" # We pass our custom localversion to the make command. make %{?_smp_mflags} LOCALVERSION=%{kernel_localversion} bzImage modules # --- %install: Install the compiled files --- %install echo "--- Installing kernel and modules to buildroot ---" # The kernel automatically combines its version with LOCALVERSION. make INSTALL_MOD_PATH=%{buildroot} LOCALVERSION=%{kernel_localversion} modules_install # --- FIX: Use the consistent, full kernel string for all installed files --- install -d %{buildroot}/boot install -m 644 arch/x86/boot/bzImage %{buildroot}/boot/vmlinuz-%{full_kernel_string} install -m 644 System.map %{buildroot}/boot/System.map-%{full_kernel_string} install -m 644 .config %{buildroot}/boot/config-%{full_kernel_string} # --- %post: Post-installation script --- %post echo "--- Running kernel-install to add the new kernel ---" # --- FIX: Use the full kernel string to add the entry to the bootloader --- /sbin/kernel-install add %{full_kernel_string} /boot/vmlinuz-%{full_kernel_string} # --- %postun: Post-uninstallation script --- %postun echo "--- Running kernel-install to remove the old kernel ---" # --- FIX: Use the full kernel string to remove the entry from the bootloader --- /sbin/kernel-install remove %{full_kernel_string} # --- %files: List of files to be included in the RPM --- # This section now correctly points to the files and directories that are actually created. %files # --- FIX: Use the full kernel string for all file paths --- /boot/vmlinuz-%{full_kernel_string} /boot/System.map-%{full_kernel_string} /boot/config-%{full_kernel_string} /lib/modules/%{full_kernel_string}/ # --- %changelog: Record of changes to the spec file --- %changelog * Sat Aug 09 2025 Gemini - 6.16.0-0.rc1.aspm_fix_1.g19272b37aa4f - Corrected kernel versioning logic to prevent "Directory not found" error. - Introduced a %full_kernel_string macro to ensure consistency between the generated module path and the %files section. - Added 'scripts/config --disable LOCALVERSION_AUTO' to make the final kernel version string predictable. - Updated %install, %post, %postun, and %files to use the new consistent version string. - Adjusted RPM Version and Release tags for clarity and proper sorting. * Fri Aug 09 2024 Gemini - 6.16.0-aspm_fix_1.19272b37aa4f - Fixed "No such file or directory" error in %prep by using a proper Source0 URL and the -n flag with the %setup macro. - Defined a full_commit macro to ensure the directory name matches the GitHub archive name. * Fri Aug 09 2024 Gemini - 6.16.0-aspm_fix_1.19272b37aa4f - Corrected spec file to fix directory not found error in prep section. - Moved b4 patch download and move commands to separate lines for clarity. - Replaced host config copy with 'make defconfig' for isolated build environments. * Fri Aug 09 2024 Gemini - 6.10.0-rc2.aspm_fix_1.19272b37 - Switched to using 'b4 am' to fetch patch as requested by user. - Added user-requested build dependencies. - Removed explicit module enabling to stick closer to original steps. * Fri Aug 09 2024 Gemini - 6.10.0-rc2.aspm_fix_1.19272b37 - Initial build with ASPM patch for ath10k/ath11k testing.