# NOTE !!! # (tmb) Do NOT blindly backport this spec to Mageia 8 or older as packages # are renamed and spec is reworked in several incompatible ways... # # upstream versioning %define kernelversion 6 %define patchlevel 18 # sublevel is now used for -stable patches %define sublevel 2 # kernel Makefile extraversion is substituted by # rcX wich are either 0 (empty), X (as in rcX ) %define rcX 0 # this is the releaseversion %define mgarelease 1 # This is only to make life easier for people that creates derivative kernels # a.k.a name it kernel-tmb :) %define kname kernel-linus %define rpmtag %{distsuffix}%{mgaver} %if %rcX %define rpmrel %mkrel 0.rc%{rcX}.%{mgarelease} %else %define rpmrel %mkrel %{mgarelease} %endif # When we are using a pre/rc patch, the tarball is a sublevel -1 %if %rcX %if %sublevel %define tar_ver %{kernelversion}.%{patchlevel} %else %define tar_ver %{kernelversion}.%(expr %{patchlevel} - 1) %endif %else %define tar_ver %{kernelversion}.%{patchlevel} %endif %define kversion %{kernelversion}.%{patchlevel}.%{sublevel} %define kverrel %{kversion}-%{rpmrel} # having different top level names for packges means that you have to remove them by hard :( %define top_dir_name %{kname}-%{_arch} %define build_dir %{_builddir}/%{top_dir_name} %define src_dir %{build_dir}/linux-%{tar_ver} # compress modules with xz %ifnarch %{arm} %define build_modxz 0 %else %define build_modxz 0 %endif # disable useless debug rpms... %global debug_package %{nil} %global _enable_debug_packages %{nil} %global __debug_package %{nil} %global __debug_install_post %{nil} %global _build_id_links none # no bytecompiling wanted as it breaks build on selftests we dont even ship # for older buildsystems %global _python_bytecompile_build 0 # for systems with >= rpm-mageia-setup-2.29-1.mga7 %global __brp_python_bytecompile %nil # Speed-up package building %global _binary_payload w9T0.zstdio # build defines %define build_doc 1 %define build_source 1 %define build_devel 1 %define distro_branch %(perl -pe '/(\\d+)\\.(\\d)\\.?(\\d)?/; $_="$1.$2"' /etc/mageia-release) # End of user definitions %{?_without_doc: %global build_doc 0} %{?_without_source: %global build_source 0} %{?_without_devel: %global build_devel 0} %{?_with_doc: %global build_doc 1} %{?_with_source: %global build_source 1} %{?_with_devel: %global build_devel 1} %if %(if [ -z "$CC" ] ; then echo 0; else echo 1; fi) %define kmake %make_build CC="$CC" %else %define kmake %make_build %endif # there are places where parallel make doesn't work %define smake make # Parallelize xargs invocations on SMP machines %define kxargs xargs %([ -z "$RPM_BUILD_NCPUS" ] \\\ && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\ [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-P $RPM_BUILD_NCPUS") # Aliases for amd64 builds (better make source links?) %define target_cpu %(echo %{_target_cpu} | sed -e "s/amd64/x86_64/") %define target_arch %(echo %{_arch} | sed -e 's/amd64/x86_64/' -e "s/arm.*/arm/" -e 's/aarch64/arm64/') # src.rpm and kernel info Summary: The Linux kernel (the core of the Linux operating system) Name: %{kname} Version: %{kversion} Release: %{rpmrel} License: GPLv2 Group: System/Kernel and hardware ExclusiveArch: %{ix86} x86_64 %{arm} aarch64 ExclusiveOS: Linux URL: https://www.kernel.org/ # Buildrequires BuildRequires: gcc BuildRequires: kmod >= 12-2 BuildRequires: bc BuildRequires: gawk >= 5.2.0-4 BuildRequires: binutils >= 1:2.37-1 # for orc unwinder BuildRequires: elfutils-devel # for crypto stuff BuildRequires: pkgconfig(openssl) # since 4.16 BuildRequires: bison BuildRequires: flex # Provides Provides: should-restart = system Provides: installonlypkg(kernel) Provides: kernel = %{kverrel} Provides: %{kname}-%{kverrel} Provides: alsa # Requires Requires: bootloader-utils >= 1.16-1 Requires: dracut >= 046-2 Requires: kmod >= 12-2 Requires: sysfsutils >= 2.1.0-16 Requires: kernel-firmware >= 20170101-1 # conflict dkms packages that dont support kernel-5.12 Conflicts: dkms-broadcom-wl < 6.30.223.271-61 Conflicts: dkms-nvidia-current < 460.67-1 Conflicts: dkms-nvidia390 < 390.143-1 Conflicts: dkms-virtualbox < 6.1.20-1 Conflicts: dkms-xtables-addons < 3.17-1 # (tmb) conflict older btrfs-progs to get the new in same transaction and in initrd Conflicts: btrfs-progs < 5.10-1 # (tmb) conflict too old radeon-firmware to get the uvd firmwares in initrd Conflicts: radeon-firmware < 20201218-1 # (tmb) conflict old firmware to get the firmwares in initrd Conflicts: kernel-firmware-nonfree < 20201230-1 # (tmb) conflict old microcode to get updated ones in initrd for early loading Conflicts: microcode < 0.20201118-2 # (tmb) conflict old theme to get mga8 theme in initrd Conflicts: mageia-gfxboot-theme < 4.5.14.11-2 # (tmb) force new theme in initrd Conflicts: mageia-theme < 8.0-2 # (tmb) conflict too old grub2(-efi) Conflicts: grub2 < 2.02.0-15 Conflicts: grub2-efi < 2.02.0-15 # (tmb) conflict too old efibootmgr Conflicts: efibootmgr < 16-3 # (tmb) conflict for vmmouse breakage (for mga5, mga#16954) Conflicts: x11-driver-input-vmmouse < 13.1.0-1 %ifarch %{ix86} Conflicts: arch(x86_64) %endif #################################################################### # # Sources # ### This is for full SRC RPM Source0: https://cdn.kernel.org/pub/linux/kernel/v%{kernelversion}.x/linux-%{tar_ver}.tar.xz Source1: https://cdn.kernel.org/pub/linux/kernel/v%{kernelversion}.x/linux-%{tar_ver}.tar.sign # This is for disabling mrproper and other targets on -devel rpms Source2: disable-mrproper-in-devel-rpms.patch Source4: README.kernel-sources # Kernel defconfigs Source10: update-defconfigs.sh # synced with core kernel defconfig-i386-desktop586 Source20: i386_defconfig # synced with core kernel defconfig-x86_64-desktop Source21: x86_64_defconfig # synced with core kernel defconfig-arm-desktop Source22: arm_defconfig # synced with core kernel defconfig-arm64-desktop #Source23: aarch64_defconfig Source23: arm64_defconfig #################################################################### # # Patches # # Patch0 to Patch100 are for core kernel upgrades. # # Pre linus patch: https://cdn.kernel.org/pub/linux/kernel/v(kernelversion).(patchlevel)/testing %if %sublevel Patch1: https://cdn.kernel.org/pub/linux/kernel/v%{kernelversion}.x/patch-%{kernelversion}.%{patchlevel}.%{sublevel}.xz %endif %if %rcX # (tmb) Created with: # wget https://git.kernel.org/torvalds/p/v5.10-rc6/v5.9 -O patch-5.10-rc6 # xz -6e patch-5.10-rc6 Patch2: patch-%{kernelversion}.%{patchlevel}-rc%{rcX}.xz %endif Patch20: stable-queue-coalesced-6.18-20251229.patch # python3 Patch50: linux-6.15-python3.patch # hack for broken rlta cleaner #Patch51: hack-broken-rtla-cleaner.patch # # critical fixes # other fixes Patch1553: 0001-drivers-firmware-skip-simpledrm-if-nvidia-drm.modese.patch #END #################################################################### # # kernel # %description This kernel is compiled for desktop use, single or multiple %{_arch} processor(s)/core(s), using HZ_1000, voluntary preempt, CFS cpu scheduler and cfq i/o scheduler. This kernel relies on in-kernel smp alternatives to switch between up & smp mode depending on detected hardware. To force the kernel to boot in single processor mode, use the "nosmp" boot parameter. NOTE: This kernel has no Mageia patches and no third-party drivers. # # kernel-source: kernel sources # %if %build_source %package -n %{kname}-source Version: %{kversion} Release: %{rpmrel} Provides: kernel-source = %{kverrel} Obsoletes: %{kname}-source-latest < %{kverrel} Requires: glibc-devel, ncurses-devel, make, gcc, perl, diffutils Summary: The source code for the Linux kernel Group: Development/Kernel Autoreqprov: no Buildarch: noarch %description -n %{kname}-source The %{kname}-source package contains the source code files for the Linux kernel. These source files are only needed if you want to build your own custom kernel that is better tuned to your particular hardware. If you only want the files needed to build 3rdparty (nVidia, Ati, dkms-*,...) drivers against, install the *-devel-* rpm that is matching your kernel. NOTE: This kernel has no Mageia patches and no third-party drivers. %endif # # kernel-devel: stripped kernel sources # %if %build_devel %package -n %{kname}-devel Version: %{kversion} Release: %{rpmrel} Provides: kernel-devel = %{kverrel} Provides: %{kname}-devel-%{kverrel} Summary: The %{kname} devel files for 3rdparty modules build Group: Development/Kernel Autoreqprov: no Requires: glibc-devel, ncurses-devel, make, gcc, perl Requires: pkgconfig(libelf) %ifarch %{ix86} Conflicts: arch(x86_64) %endif %description -n %{kname}-devel This package contains the kernel-devel files that should be enough to build 3rdparty drivers against for use with the %{kname}-%{kverrel}. If you want to build your own kernel, you need to install the full %{kname}-source rpm. NOTE: This kernel has no Mageia patches and no third-party drivers. %endif # # kernel-doc: documentation for the Linux kernel # %if %build_doc %package -n %{kname}-doc Version: %{kversion} Release: %{rpmrel} Summary: Various documentation bits found in the kernel source Group: Documentation Buildarch: noarch %description -n %{kname}-doc This package contains documentation files form the kernel source. Various bits of information about the Linux kernel and the device drivers shipped with it are documented in these files. You also might want install this package if you need a reference to the options that can be passed to Linux kernel modules at load time. %endif # # kernel-latest: virtual rpm # %package -n %{kname}-latest Version: %{kversion} Release: %{rpmrel} Summary: Virtual rpm for latest %{kname} Group: System/Kernel and hardware Requires: %{kname}-%{kverrel} %ifarch %{ix86} Conflicts: arch(x86_64) %endif %description -n %{kname}-latest This package is a virtual rpm that aims to make sure you always have the latest %{kname} installed... # # kernel-devel-latest: virtual rpm # %if %build_devel %package -n %{kname}-devel-latest Version: %{kversion} Release: %{rpmrel} Summary: Virtual rpm for latest %{kname}-devel Group: System/Kernel and hardware Requires: %{kname}-devel-%{kverrel} %ifarch %{ix86} Conflicts: arch(x86_64) %endif %description -n %{kname}-devel-latest This package is a virtual rpm that aims to make sure you always have the latest %{kname}-devel installed... %endif # # End packages - here begins build stage # %prep %setup -q -n %top_dir_name -c pushd %src_dir %if %sublevel %patch -P 1 -p1 %endif %if %rcX %patch -P 2 -p1 %endif %patch -P 20 -p1 # python 3 %patch -P 50 -p1 # broken rtla cleaner #patch -P 51 -p1 # critical fixes # other fixes %patch -P 1553 -p1 popd # PATCH END # # Setup Begin # # Install defconfigs... install %{SOURCE20} %{build_dir}/linux-%{tar_ver}/arch/x86/configs/ install %{SOURCE21} %{build_dir}/linux-%{tar_ver}/arch/x86/configs/ install %{SOURCE22} %{build_dir}/linux-%{tar_ver}/arch/arm/configs/ install %{SOURCE23} %{build_dir}/linux-%{tar_ver}/arch/arm64/configs/ # make sure the kernel has the sublevel we know it has... LC_ALL=C perl -p -i -e "s/^SUBLEVEL.*/SUBLEVEL = %{sublevel}/" linux-%{tar_ver}/Makefile %build # Common target directories %define _bootdir /boot %define _modulesdir /lib/modules %define _srcdir /usr/src/%{kname}-%{kverrel} %define _develdir /usr/src/%{kname}-devel-%{kverrel} # Directories definition needed for building %define temp_root %{build_dir}/temp-root %define temp_boot %{temp_root}%{_bootdir} %define temp_modules %{temp_root}%{_modulesdir} %define temp_source %{temp_root}%{_srcdir} %define temp_devel %{temp_root}%{_develdir} # Create a simulacro of buildroot rm -rf %{temp_root} install -d %{temp_root} # make sure we are in the directory cd %{src_dir} # fix missing exec flag on file introduced in 4.14.10-rc1 chmod 755 tools/objtool/sync-check.sh # make sure EXTRAVERSION says what we want it to say LC_ALL=C perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{rpmrel}/" Makefile # Prepare the kernel %smake -s mrproper %ifarch %{ix86} x86_64 cp arch/x86/configs/%{target_arch}_defconfig .config %else cp arch/%{target_arch}/configs/%{target_arch}_defconfig .config %endif %smake ARCH=%{target_arch} oldconfig # Build the kernel %kmake ARCH=%{target_arch} -s all # Install kernel install -d %{temp_boot} install -m 644 System.map %{temp_boot}/System.map-%{kverrel} install -m 644 .config %{temp_boot}/config-%{kverrel} %ifarch %{arm} cp -f arch/arm/boot/zImage %{temp_boot}/vmlinuz-%{kverrel} install -d %{temp_root}%{_modulesdir}/%{kverrel}/dtb %{make} ARCH=%{target_arch} dtbs INSTALL_DTBS_PATH=%{temp_root}%{_modulesdir}/%{kverrel}/dtb %{make} ARCH=%{target_arch} dtbs_install INSTALL_DTBS_PATH=%{temp_root}%{_modulesdir}/%{kverrel}/dtb %else %ifarch aarch64 cp -f arch/%{target_arch}/boot/Image.gz %{temp_boot}/vmlinuz-%{kverrel} %else cp -f arch/%{target_arch}/boot/bzImage %{temp_boot}/vmlinuz-%{kverrel} %endif %endif # Install modules install -d %{temp_modules}/%{kverrel} %smake ARCH=%{target_arch} INSTALL_MOD_PATH=%{temp_root} KERNELRELEASE=%{kverrel} modules_install # Save devel tree %if %build_devel mkdir -p %{temp_devel} for i in $(find . -name 'Makefile*'); do cp -R --parents $i %{temp_devel};done for i in $(find . -name 'Kconfig*' -o -name 'Kbuild*' -o -name config.mk); do cp -R --parents $i %{temp_devel};done cp -fR include %{temp_devel} cp -fR scripts %{temp_devel} cp -fR tools/include %{temp_devel}/tools/ # needed for selinux cp -R --parents security/selinux/include/*.h %{temp_devel} %ifarch %{arm} cp -fR arch/%{target_arch}/tools %{temp_devel}/arch/%{target_arch}/ cp -f arch/%{target_arch}/kernel/signal.h %{temp_devel}/arch/%{target_arch}/kernel/ %endif %ifarch aarch64 cp -f arch/x86/entry/syscalls/syscall_32.tbl %{temp_devel}/arch/x86/entry/syscalls/ cp -f arch/x86/entry/vdso/vgetrandom.c %{temp_devel}/arch/x86/entry/vdso/ cp -f arch/arm64/kernel/vdso/*.{S,sh} %{temp_devel}/arch/arm64/kernel/vdso/ cp -f arch/arm64/kernel/vdso/vgettimeofday.c %{temp_devel}/arch/arm64/kernel/vdso/ cp -f arch/arm64/kernel/vdso/vgetrandom.c %{temp_devel}/arch/arm64/kernel/vdso/ cp -f arch/arm64/tools/{cpucaps,gen-cpucaps.awk,gen-sysreg.awk,sysreg} %{temp_devel}/arch/arm64/tools/ # aarch64 build wants x86 syscall tables cp -f arch/x86/entry/syscalls/syscall_{32,64}.tbl %{temp_devel}/arch/x86/entry/syscalls/ cp -f lib/vdso/gettimeofday.c %{temp_devel}/lib/vdso/ %endif %ifarch %{ix86} x86_64 # cp -f arch/x86/boot/{ctype.h,string.{c,h}} %{temp_devel}/arch/x86/boot/ cp -f arch/x86/kernel/asm-offsets.{c,s} %{temp_devel}/arch/x86/kernel/ cp -f arch/x86/kernel/asm-offsets_{32,64}.c %{temp_devel}/arch/x86/kernel/ mkdir -p %{temp_devel}/arch/x86/kvm/vmx cp -f arch/x86/kvm/vmx/*.h %{temp_devel}/arch/x86/kvm/vmx/ cp -f arch/x86/kvm/*.h %{temp_devel}/arch/x86/kvm/ cp -f arch/x86/lib/insn.c %{temp_devel}/arch/x86/lib/ cp -fR arch/x86/purgatory/* %{temp_devel}/arch/x86/purgatory/ cp -fR arch/x86/entry/syscalls/syscall* %{temp_devel}/arch/x86/entry/syscalls/ cp -fR arch/x86/include %{temp_devel}/arch/x86/ cp -fR arch/x86/tools %{temp_devel}/arch/x86/ %else cp -f arch/%{target_arch}/kernel/asm-offsets.{c,s} %{temp_devel}/arch/%{target_arch}/kernel/ for f in $(find arch/%{target_arch} -name include); do cp -fR --parents $f %{temp_devel}; done %endif %ifarch x86_64 # orc unwinder needs theese cp -f tools/build/Build.include %{temp_devel}/tools/build # cp -f tools/build/Build %{temp_devel}/tools/build cp -f tools/build/fixdep.c %{temp_devel}/tools/build/ cp -f tools/lib/{rbtree.c,ctype.c,str_error_r.c,string.c} %{temp_devel}/tools/lib/ cp -fR tools/lib/subcmd/* %{temp_devel}/tools/lib/subcmd/ cp -fR tools/objtool/* %{temp_devel}/tools/objtool/ cp -f tools/scripts/utilities.mak %{temp_devel}/tools/scripts/ mkdir -p %{temp_devel}/tools/arch/x86/tools cp -f tools/arch/x86/tools/gen-insn-attr-x86.awk %{temp_devel}/tools/arch/x86/tools/ mkdir -p %{temp_devel}/tools/arch/x86/lib cp -f tools/arch/x86/lib/{inat.c,insn.c,x86-opcode-map.txt} %{temp_devel}/tools/arch/x86/lib/ mkdir -p %{temp_devel}/tools/arch/x86/include/asm cp -f tools/arch/x86/include/asm/{asm.h,emulate_prefix.h,inat.h,inat_types.h,insn.h,nops.h,orc_types.h} %{temp_devel}/tools/arch/x86/include/asm/ %endif # for 6.12.x and beyond %ifarch aarch64 cp -f lib/vdso/getrandom.c %{temp_devel}/lib/vdso/ cp -f tools/build/fixdep.c %{temp_devel}/tools/build/ cp -f tools/build/Build.include %{temp_devel}/tools/build/ mkdir -p %{temp_devel}/tools/arch/arm64/include/asm cp -f tools/scripts/utilities.mak %{temp_devel}/tools/scripts/ cp -f tools/lib/subcmd/s* %{temp_devel}/tools/lib/subcmd/ cp -f tools/lib/subcmd/{exec-cmd.h,help.h,pager.h,run-command.h} %{temp_devel}/tools/lib/subcmd/ cp -f tools/lib/{rbtree.c,string.c,ctype.c,str_error_r.c} %{temp_devel}/tools/lib/ cp -fR tools/lib/subcmd/* %{temp_devel}/tools/lib/subcmd/ %endif %ifarch %{arm} cp -f lib/vdso/getrandom.c %{temp_devel}/lib/vdso/ cp -f tools/build/fixdep.c %{temp_devel}/tools/build/ cp -f tools/build/Build.include %{temp_devel}/tools/build/ mkdir -p %{temp_devel}/tools/arch/arm/include/asm cp -f tools/scripts/utilities.mak %{temp_devel}/tools/scripts/ cp -f tools/lib/subcmd/s* %{temp_devel}/tools/lib/subcmd/ cp -f tools/lib/subcmd/{exec-cmd.h,help.h,pager.h,run-command.h} %{temp_devel}/tools/lib/subcmd/ cp -f tools/lib/{rbtree.c,string.c,ctype.c,str_error_r.c} %{temp_devel}/tools/lib/ cp -fR tools/lib/subcmd/* %{temp_devel}/tools/lib/subcmd/ %endif # for 6.12.x and beyond %ifarch %{ix86} x86_64 cp -fR tools/arch/x86/include/uapi %{temp_devel}/tools/arch/x86/include/ cp -fR tools/arch/x86/include/asm %{temp_devel}/tools/arch/x86/include/ %endif %ifarch aarch64 cp -fR tools/arch/arm64/include/uapi %{temp_devel}/tools/arch/arm64/include/ cp -fR tools/arch/arm64/include/asm %{temp_devel}/tools/arch/arm64/include/ %endif %ifarch %{arm} cp -fR tools/arch/arm/include/uapi %{temp_devel}/tools/arch/arm/include/ cp -fR tools/arch/arm/include/asm %{temp_devel}/tools/arch/arm/include/ %endif cp -f tools/lib/zalloc.c %{temp_devel}/tools/lib/ for i in alpha arc avr32 blackfin c6x cris csky frv h8300 hexagon ia64 loongarch m32r m68k m68knommu metag microblaze \ mips mn10300 nds32 nios2 openrisc parisc powerpc riscv s390 score sh sparc tile unicore32 xtensa; do rm -rf %{temp_devel}/arch/$i rm -rf %{temp_devel}/scripts/dtc/include-prefixes/$i rm -rf %{temp_devel}/tools/arch/$i done %ifnarch %{arm} aarch64 rm -rf %{temp_devel}/arch/arm* rm -rf %{temp_devel}/include/kvm/arm* rm -rf %{temp_devel}/scripts/dtc/include-prefixes/arm* # rm -rf %{temp_devel}/tools/arch/arm* %endif %ifnarch %{ix86} x86_64 # avoid removing %{temp_devel}/arch/x86 as it's required by arch/x86/entry/syscalls/syscall_{32,64}.tbl during aarch64 build #rm -rf %{temp_devel}/arch/x86 # rm -rf %{temp_devel}/tools/arch/x86 # arch/x86/ras/Kconfig is included by drivers/ras/Kconfig # and kconfig's source command seems to be evaluated even under a false conditional mkdir -p %{temp_devel}/arch/x86/ras cp -f arch/x86/ras/Kconfig %{temp_devel}/arch/x86/ras/ %endif # 6.18.x and beyond cp -f -p kernel/sched/{rq-offsets.c,sched.h,cpupri.h,cpudeadline.h,features.h,stats.h,ext.h} %{temp_devel}/kernel/sched/ cp -f -p kernel/workqueue_internal.h %{temp_devel}/kernel/ cp -fRp tools/testing %{temp_devel}/tools/ # (6.1 breakage) keep crypto Kconfig deps happy cp --parents arch/arm/crypto/Kconfig %{temp_devel} cp --parents arch/arm64/crypto/Kconfig %{temp_devel} cp --parents arch/loongarch/crypto/Kconfig %{temp_devel} cp --parents arch/mips/crypto/Kconfig %{temp_devel} cp --parents arch/powerpc/crypto/Kconfig %{temp_devel} cp --parents arch/s390/crypto/Kconfig %{temp_devel} cp --parents arch/sparc/crypto/Kconfig %{temp_devel} cp --parents arch/x86/crypto/Kconfig %{temp_devel} cp --parents arch/riscv/crypto/Kconfig %{temp_devel} # 6.18.x for rust cp -fR rust %{temp_devel} # Needed for generation of kernel/bounds.s cp -f kernel/bounds.c %{temp_devel}/kernel/ # needed by include/generated/timeconst.h cp -f kernel/time/timeconst.bc %{temp_devel}/kernel/time/ # ship config and symvers cp -f .config Module.symvers %{temp_devel} # Needed for truecrypt build (Danny) cp -f drivers/md/dm.h %{temp_devel}/drivers/md/ # 6.18.x and beyond: needed for proper make clean cp -fR drivers/gpu/drm/lib %{temp_devel}/drivers/gpu/drm/ %ifnarch %{ix86} x86_64 # avoid removing %{temp_devel}/arch/x86 as it's required by arch/x86/entry/syscalls/syscall_{32,64}.tbl during aarch64 build #rm -rf %{temp_devel}/arch/x86 rm -rf %{temp_devel}/tools/arch/x86 # arch/x86/ras/Kconfig is included by drivers/ras/Kconfig # and kconfig's source command seems to be evaluated even under a false conditional mkdir -p %{temp_devel}/arch/x86/ras cp -f arch/x86/ras/Kconfig %{temp_devel}/arch/x86/ras/ %endif cp -fR tools/lib/bpf %{temp_devel}/tools/lib/ cp -fR tools/bpf %{temp_devel}/tools/ cp -f -p kernel/bpf/disasm.{c,h} %{temp_devel}/kernel/bpf/ # cp -fR tools/power %{temp_devel}/tools/ cp -fR tools/perf %{temp_devel}/tools/ cp -fR tools/sched_ext %{temp_devel}/tools/ # Check and clean the -devel tree pushd %{temp_devel} >/dev/null %smake ARCH=%{target_arch} -s prepare scripts %smake ARCH=%{target_arch} clean popd >/dev/null rm -f %{temp_devel}/.config.old # fix permissions chmod -R a+rX %{temp_devel} # Disable mrproper and other targets patch -p1 --fuzz=0 -d %{temp_devel} -i %{SOURCE2} %endif #make sure we are in the directory cd %src_dir # kernel-source is shipped as an unprepared tree %smake ARCH=%{target_arch} -s mrproper ### ### Install ### %install install -m 644 %{SOURCE4} . cd %src_dir # Directories definition needed for installing %define target_source %{buildroot}/%{_srcdir} %define target_boot %{buildroot}%{_bootdir} %define target_modules %{buildroot}%{_modulesdir} %define target_devel %{buildroot}%{_develdir} # We want to be able to test several times the install part rm -rf %{buildroot} cp -a %{temp_root} %{buildroot} # Create directories infastructure %if %build_source install -d %{target_source} tar cf - . | tar xf - -C %{target_source} chmod -R a+rX %{target_source} # we remove all the source files that we don't ship # first architecture files for i in alpha arc avr32 blackfin c6x cris csky frv h8300 hexagon ia64 loongarch m32r m68k m68knommu metag microblaze \ mips mn10300 nds32 nios2 openrisc parisc powerpc ppc riscv s390 score sh sh64 sparc tile unicore32 v850 xtensa; do # rm -rf %{target_source}/arch/$i rm -rf %{target_source}/tools/arch/$i rm -rf %{target_source}/tools/testing/selftests/$i %if %build_devel rm -rf %{target_devel}/arch/$i %endif done %ifnarch %{arm} aarch64 rm -rf %{target_source}/include/kvm/arm* rm -rf %{target_source}/scripts/dtc/include-prefixes/arm* # rm -rf %{target_source}/tools/arch/arm* %endif # remove arch files based on target arch in -devel rpms %if %build_devel %ifnarch %{ix86} x86_64 rm -rf %{target_devel}/arch/x86 %endif %ifnarch %{arm} aarch64 rm -rf %{target_devel}/arch/arm rm -rf %{target_devel}/arch/arm64 rm -rf %{target_devel}/include/kvm/arm* %endif %endif # other misc files rm -f %{target_source}/{.clang-format,.cocciconfig,.editorconfig,.get_maintainer.ignore,.gitattributes,.mailmap,.config.cmd,.config.old,.gitignore,.tmp_gas_check,.missing-syscalls.d,arch/.gitignore,rust/.gitignore,.clippy.toml,.pylintrc} rm -rf %{target_source}/.tmp_depmod/ # clean tools tree pushd %{target_source} # lots of gitignore files find -iname ".gitignore" -delete %smake -C tools clean %smake -C tools/build clean %smake -C tools/build/feature clean popd # nuke last as it gets re-created rm -f %{target_source}/.cache.mk #endif %build_source %endif # compressing modules %if %{build_modxz} find %{target_modules} -name "*.ko" | %kxargs xz -6 %else find %{target_modules} -name "*.ko" | %kxargs gzip -9 %endif # We used to have a copy of PrepareKernel here # Now, we make sure that the thing in the linux dir is what we want it to be for i in %{target_modules}/*; do rm -f $i/build $i/source done # sniff, if we gzipped all the modules, we change the stamp :( # we really need the depmod -ae here pushd %{target_modules} for i in *; do /sbin/depmod -ae -b %{buildroot} -F %{target_boot}/System.map-$i $i echo $? done for i in *; do pushd $i echo "Creating module.description for $i" modules=`find . -name "*.ko.[g,x]z"` echo $modules | xargs /sbin/modinfo \ | perl -lne 'print "$name\t$1" if $name && /^description:\s*(.*)/; $name = $1 if m!^filename:\s*(.*)\.k?o!; $name =~ s!.*/!!' > modules.description popd done popd # remove arch dependent files from noarch package rm -f %{buildroot}%{_srcdir}/tools/objtool/fixdep rm -f %{buildroot}%{_srcdir}/tools/objtool/libsubcmd/fixdep rm -f %{buildroot}%{_srcdir}/tools/objtool/objtool rm -f %{buildroot}%{_srcdir}/tools/testing/selftests/tc-testing/action-ebpf rm -f %{buildroot}%{_srcdir}/arch/x86/tools/relocs rm -f %{buildroot}%{_srcdir}/scripts/basic/fixdep rm -f %{buildroot}%{_srcdir}/scripts/unifdef rm -f %{buildroot}%{_srcdir}/rust/libpin_init_internal.so ### ### Clean ### %clean rm -rf %{buildroot} # We don't want to remove this, the whole reason of its existence is to be # able to do several rpm --short-circuit -bi for testing install # phase without repeating compilation phase #rm -rf %{temp_root} ### ### Scripts ### ### kernel %post /sbin/installkernel -L %{kverrel} if [ -d /usr/src/%{kname}-devel-%{kverrel} ]; then ln -sf /usr/src/%{kname}-devel-%{kverrel} /lib/modules/%{kverrel}/build ln -sf /usr/src/%{kname}-devel-%{kverrel} /lib/modules/%{kverrel}/source fi pushd /boot > /dev/null ln -sf vmlinuz-%{kverrel} vmlinuz-linus ln -sf initrd-%{kverrel}.img initrd-linus.img popd > /dev/null %posttrans if [ -x /usr/sbin/dkms_autoinstaller -a -d /usr/src/%{kname}-devel-%{kverrel} ]; then /usr/sbin/dkms_autoinstaller start %{kverrel} fi %postun pushd /boot > /dev/null if [ -L vmlinuz-linus ]; then if [ "$(readlink vmlinuz-linus)" = "vmlinuz-%{kverrel}" ]; then rm -f vmlinuz-linus fi fi if [ -L initrd-linus.img ]; then if [ "$(readlink initrd-linus.img)" = "initrd-%{kverrel}.img" ]; then rm -f initrd-linus.img fi fi popd > /dev/null /sbin/kernel_remove_initrd %{kverrel} /sbin/installkernel -R %{kverrel} rm -rf /lib/modules/%{kverrel} > /dev/null if [ -d /var/lib/dkms ]; then rm -f /var/lib/dkms/*/kernel-%{kverrel}-%{_target_cpu} >/dev/null rm -rf /var/lib/dkms/*/*/%{kverrel} >/dev/null fi ### kernel-devel %if %build_devel %post -n %{kname}-devel # place /build and /source symlinks in place. if [ -d /lib/modules/%{kverrel} ]; then ln -sf /usr/src/%{kname}-devel-%{kverrel} /lib/modules/%{kverrel}/build ln -sf /usr/src/%{kname}-devel-%{kverrel} /lib/modules/%{kverrel}/source fi %preun -n %{kname}-devel # we need to delete /{build,source} at uninstall if [ -L /lib/modules/%{kverrel}/build ]; then rm -f /lib/modules/%{kverrel}/build fi if [ -L /lib/modules/%{kverrel}/source ]; then rm -f /lib/modules/%{kverrel}/source fi exit 0 %endif ### ### file lists ### # kernel %files %{_bootdir}/config-%{kverrel} %{_bootdir}/vmlinuz-%{kverrel} %{_bootdir}/System.map-%{kverrel} %dir %{_modulesdir}/%{kverrel}/ %ifarch %{arm} %{_modulesdir}/%{kverrel}/dtb %endif %{_modulesdir}/%{kverrel}/kernel %{_modulesdir}/%{kverrel}/modules.* %doc README.kernel-sources # kernel-source %if %build_source %files -n %{kname}-source %doc %{_srcdir}/LICENSES %dir %{_srcdir} %dir %{_srcdir}/arch %dir %{_srcdir}/include %{_srcdir}/.rustfmt.toml %{_srcdir}/COPYING %{_srcdir}/CREDITS %{_srcdir}/Documentation %{_srcdir}/Kbuild %{_srcdir}/Kconfig %{_srcdir}/MAINTAINERS %{_srcdir}/Makefile %{_srcdir}/README %{_srcdir}/arch/Kconfig %{_srcdir}/arch/alpha %{_srcdir}/arch/arc %{_srcdir}/arch/arm %{_srcdir}/arch/arm64 %{_srcdir}/arch/csky %{_srcdir}/arch/hexagon %{_srcdir}/arch/loongarch %{_srcdir}/arch/m68k %{_srcdir}/arch/microblaze %{_srcdir}/arch/mips %{_srcdir}/arch/nios2 %{_srcdir}/arch/openrisc %{_srcdir}/arch/parisc %{_srcdir}/arch/powerpc %{_srcdir}/arch/riscv %{_srcdir}/arch/s390 %{_srcdir}/arch/sh %{_srcdir}/arch/sparc %{_srcdir}/arch/x86 %{_srcdir}/arch/xtensa %{_srcdir}/arch/um %{_srcdir}/block %{_srcdir}/certs %{_srcdir}/crypto %{_srcdir}/drivers %{_srcdir}/fs %{_srcdir}/include/acpi %{_srcdir}/include/asm-generic %{_srcdir}/include/clocksource %{_srcdir}/include/crypto %{_srcdir}/include/cxl %{_srcdir}/include/drm %{_srcdir}/include/dt-bindings %{_srcdir}/include/hyperv %{_srcdir}/include/kunit %{_srcdir}/include/keys %{_srcdir}/include/kvm %{_srcdir}/include/linux %{_srcdir}/include/math-emu %{_srcdir}/include/media %{_srcdir}/include/memory %{_srcdir}/include/misc %{_srcdir}/include/net %{_srcdir}/include/pcmcia %{_srcdir}/include/ras %{_srcdir}/include/rdma %{_srcdir}/include/rv %{_srcdir}/include/scsi %{_srcdir}/include/soc %{_srcdir}/include/sound %{_srcdir}/include/target %{_srcdir}/include/trace %{_srcdir}/include/uapi %{_srcdir}/include/ufs %dir %{_srcdir}/include/vdso %{_srcdir}/include/vdso/*.h %{_srcdir}/include/video %{_srcdir}/include/xen %{_srcdir}/init %{_srcdir}/io_uring %{_srcdir}/ipc %{_srcdir}/kernel %{_srcdir}/lib %{_srcdir}/mm %{_srcdir}/net %{_srcdir}/rust %{_srcdir}/samples %{_srcdir}/scripts %{_srcdir}/security %{_srcdir}/sound %{_srcdir}/tools %{_srcdir}/usr %{_srcdir}/virt %{_srcdir}/include/Kbuild %doc README.kernel-sources %endif # kernel-devel %if %build_devel %files -n %{kname}-devel %dir %{_develdir} %dir %{_develdir}/arch %dir %{_develdir}/include %{_develdir}/.config %{_develdir}/Documentation %{_develdir}/Kbuild %{_develdir}/Kconfig %{_develdir}/Makefile %{_develdir}/Module.symvers %{_develdir}/arch/Kconfig %ifarch %{arm} aarch64 %{_develdir}/arch/arm %{_develdir}/arch/arm64 %endif %ifarch %{ix86} x86_64 %{_develdir}/arch/x86 %endif %{_develdir}/arch/um %{_develdir}/block %{_develdir}/certs %{_develdir}/crypto %{_develdir}/drivers %{_develdir}/fs %{_develdir}/include/acpi %{_develdir}/include/asm-generic %{_develdir}/include/clocksource %{_develdir}/include/config %{_develdir}/include/cxl %{_develdir}/include/crypto %{_develdir}/include/drm %{_develdir}/include/dt-bindings %{_develdir}/include/generated %{_develdir}/include/hyperv %{_develdir}/include/Kbuild %{_develdir}/include/keys %{_develdir}/include/kunit %{_develdir}/include/kvm %{_develdir}/include/linux %{_develdir}/include/math-emu %{_develdir}/include/memory %{_develdir}/include/misc %{_develdir}/include/net %{_develdir}/include/pcmcia %{_develdir}/include/ras %{_develdir}/include/rv %{_develdir}/include/rdma %{_develdir}/include/scsi %{_develdir}/include/soc %{_develdir}/include/sound %{_develdir}/include/target %{_develdir}/include/trace %{_develdir}/include/uapi %{_develdir}/include/ufs %{_develdir}/include/vdso/*.h %{_develdir}/include/video %{_develdir}/include/media %{_develdir}/include/xen %{_develdir}/init %{_develdir}/io_uring %{_develdir}/ipc %{_develdir}/kernel %{_develdir}/lib %{_develdir}/mm %{_develdir}/net %{_develdir}/rust %{_develdir}/samples %{_develdir}/scripts %{_develdir}/security %{_develdir}/sound %{_develdir}/tools %{_develdir}/usr %{_develdir}/virt %endif %if %build_doc %files -n %{kname}-doc %doc linux-%{tar_ver}/Documentation/* %endif %files -n %{kname}-latest %if %build_devel %files -n %{kname}-devel-latest %endif