%global pkgvers 0 %global scdate0 20241117 %global sctags0 v6.12 %global scfilt0 refs/tags/v[0-9].[0-9]*$ %global source0 https://github.com/torvalds/linux.git %define sysarch linux-gnu %define targets aarch64;or1k;ppc64le;riscv32;riscv64 Name: cross-%{sysarch}-kernel-headers Version: %(curl -s https://raw.githubusercontent.com/torvalds/linux/%{sctags0}/Makefile | grep -m3 -e "VERSION " -e "PATCHLEVEL " -e "SUBLEVEL " | awk '{print $3}' | sed ':a;N;$!ba;s/\n/./g') Release: %{scdate0}.%{pkgvers}%{?dist} Summary: Header files of Linux kernel License: GPLv2 BuildArch: noarch URL: https://www.kernel.org BuildRequires: git make gcc rsync perl-interpreter %define cpulist %(echo "%{targets}" | sed "s|%{_arch}||g") %description Header files of Linux kernel. %{lua: for target in string.gmatch(rpm.expand("%{cpulist}"), "[%w_-]+") do print("%package -n "..target.."-"..rpm.expand("%{sysarch}").."-kernel-headers\n") print("Summary: Header files of Linux kernel for "..target.." target\n") print("Obsoletes: kernel-cross-headers\n") print("Provides: "..target.."-kernel-headers\n") print("%description -n "..target.."-"..rpm.expand("%{sysarch}").."-kernel-headers\n") print("Header files of Linux kernel for "..target.." target.\n") print("\n") end} %prep %setup -T -c -n %{name} git clone --depth 1 -n -b %{sctags0} %{source0} . git fetch --depth 1 origin %{sctags0} git reset --hard %{sctags0} git --no-pager log --format=fuller %autosetup -D -p 0 -T -c -n %{name} %build %install for target in $(echo "%{cpulist}" | sed 's|;| |g'); do echo "Installing for [$target]" cross_arch=$target case $target in arm*) cross_arch="arm" ;; aarch64*) cross_arch="arm64" ;; or1k*) cross_arch="openrisc" ;; ppc*) cross_arch="powerpc" ;; riscv*) cross_arch="riscv" ;; esac %{__make} ARCH=$cross_arch mrproper install -d %{buildroot}%{_prefix}/$target-%{sysarch} %{__make} headers_install ARCH=$cross_arch \ INSTALL_HDR_PATH=%{buildroot}%{_prefix}/$target-%{sysarch}/%{_prefix} find %{buildroot}%{_prefix}/$target-%{sysarch} -name .install -delete find %{buildroot}%{_prefix}/$target-%{sysarch} -name ..install.cmd -delete done %{lua: for target in string.gmatch(rpm.expand("%{cpulist}"), "[%w_-]+") do print("%files -n "..target.."-"..rpm.expand("%{sysarch}").."-kernel-headers\n") print("%dir /usr/"..target.."-"..rpm.expand("%{sysarch}").."/usr/include\n") print("/usr/"..target.."-"..rpm.expand("%{sysarch}").."/usr/include/*\n") print("\n") end} %changelog * Fri Aug 07 2020 Cristian Balint - git upstream releases