%global __requires_exclude ^.*/bin/env* %define microarchitecture_level "V2" # _get_email() in %%build contains bashisms for regexping %define _buildshell /usr/bin/bash # brp-python-bytecompile uses /usr/bin/python, # but it is a different python version in different ROSA # releases; there is no good way to tell brp-python-bytecompile # which iterpreter to use; so just disable it to avoid problems %define _python_bytecompile_build 0 # Probably dwz bug, on i686 only file is not packaged: # /usr/lib/debug/usr/bin/trace-5.4.40-3.i386.debug.#dwz#.b5xuKG # dwz compresses only debuginfo from perf, cpupower, uml, # not the kernel itself (because it is stripped not by RPM), # so we do not loose much by disabling it. %global _find_debuginfo_dwz_opts %{nil} # Put everything into one non-standard debuginfo subpackage # TODO: make multiple debuginfo packages coinstallable as installonlypkg, # to achive this, there must be no conflicting files. # Probably signing and compressing of kernel modules # has to be moved to %%_spec_install_post. %global _debuginfo_subpackages %{nil} %global _debuginfo_template %{nil} %undefine _debugsource_packages # Hack: flavour and major version are variable, make %%_build_pkgcheck_* always detect and use this config %global _build_pkgcheck_set %(echo "%{_build_pkgcheck_set}" | sed -e 's,/%{name}.rpmlintrc,/kernel.rpmlintrc,') %global _build_pkgcheck_srpm %(echo "%{_build_pkgcheck_srpm}" | sed -e 's,/%{name}.rpmlintrc,/kernel.rpmlintrc,') %define kernelversion 6 %define patchlevel 7 # sublevel is used for stable-based kernels %define sublevel 2 %define patch_name xanmod %define patch_rel 1 # Release number. Increase this before a rebuild. %define rpmrel 1.k %define fullrpmrel %{rpmrel} %define rpmtag %{disttag} # version defines %define kversion_base %{kernelversion}.%{patchlevel}.%{sublevel} %define kversion %{kversion_base}.xm%{patch_rel} %define kverrel %{kversion}-%{fullrpmrel} %define tar_ver %{kernelversion}.%{patchlevel} %ifarch %{ix86} %define arch_suffix i586 %endif %ifarch %{x86_64} %define arch_suffix x86_64 %endif %ifarch aarch64 %define arch_suffix arm64 %endif %define buildrpmrel %{rpmtag}-%{arch_suffix} %define buildrel %{kversion}-%{fullrpmrel}-%{buildrpmrel} # Add not only the build time generated key to the trusted keyring, # but also add public keys of private ROSA's keys %bcond_without additional_keys # Fail the build after "make oldconfig" to edit kernel configs %bcond_with fail # User Mode Linux, https://habr.com/ru/company/itsumma/blog/459558/ # Not buildable on aarch64 %ifarch %{x86_64} %bcond_without uml %else %bcond_with uml %endif %if %{mdvver} >= 201905 # Build binary out-of-tree kernel modules (experimental) %bcond_without binary_extra_modules %bcond_without nvidia_module # Sign kernel modules with GOST key (experimental) %bcond_without gost_sign %else %bcond_with binary_extra_modules %bcond_with gost_sign %endif %bcond_with ccache %bcond_without flow_abi # shredder-kernel works only on x86_64, makes manipulations with syscalls tables, # loading/unloading of the module failed sometimes on kernel 5.4 # and it has not been adapted for kernel 5.10 (is not buildable) %bcond_with binary_shredder # compress modules with zstd (zstd is good compression and fast decompression) %bcond_without compress_modules # Spend more resources on compression, but make resulting size less; # decompression speed will not be affected, but more memory will be required # which should not a problem here (performance penalty from allocating more # memory should not be big, I think, but I did not benchmark). %define zstd_cmd zstd -q --format=zstd --ultra -22 %define flavour xanmod # The full kernel version %define kver_full %{kversion}-%{fullrpmrel}-%{flavour}-%{buildrpmrel} ############################################################################ %define top_dir_name kernel-%{_arch} %define build_dir ${RPM_BUILD_DIR}/%{top_dir_name} %define src_dir %{build_dir}/linux-%{tar_ver} # Common target directories %define _bootdir /boot %define _modulesdir /lib/modules %define devel_root /usr/src/linux-%{kver_full} %define initrd_path %{_bootdir}/initrd-%{kver_full}.img # Directories needed for building %define temp_root %{build_dir}/temp-root %define temp_boot %{temp_root}%{_bootdir} %define temp_modules %{temp_root}%{_modulesdir} %define temp_devel_root %{temp_root}%{devel_root} # Directories definition needed for installing %define target_boot %{buildroot}%{_bootdir} %define target_modules %{buildroot}%{_modulesdir} %define kernel_files %{_builddir}/kernel_files.list %define debuginfo_files %{_builddir}/debuginfo_files.list # Append list of files generate by find-debuginfo.sh to our custom list %global __debug_install_post \ %{__debug_install_post} \ cat %{_builddir}/debugfiles.list >> %{debuginfo_files} ############################################################################ %if %{with binary_extra_modules} %if %{with nvidia_module} # global instead of define to speed up things %global nvidia_545_j %{kroko_j -p kernel-source-nvidia545 -r 545} %global nvidia_545_n %{kroko_n -p kernel-source-nvidia545 -r 545} %endif # For SRPM stage when auto-krokodil-rpm-macros is not installed %{?!kroko_mk_release:%global kroko_mk_release(n:) %{nil}} %{?!kroko_req_modules_in_kernel:%global kroko_req_modules_in_kernel(j:n:p:) %{nil}} # global, not define, must be expanded only once %global kroko_release %kroko_mk_release -n kernel-%{kernelversion}.%{patchlevel}-%{flavour} %endif ############################################################################ # Build defines %define build_doc 0 %define build_devel 1 %define build_debug 1 # Build kernel-headers package %define build_headers 1 # build perf and cpupower tools %if %{mdvver} > 201610 %define build_perf 1 %define build_cpupower 1 %else # This is not the main kernel in rosa2016.1 # This one will be in contrib, not main, in rosa2016.1 %define build_perf 0 %define build_cpupower 0 %endif # End of user definitions # buildtime flags %{?_without_doc: %global build_doc 0} %{?_without_devel: %global build_devel 0} %{?_without_debug: %global build_debug 0} %{?_without_perf: %global build_perf 0} %{?_without_cpupower: %global build_cpupower 0} %{?_with_doc: %global build_doc 1} %{?_with_devel: %global build_devel 1} %{?_with_debug: %global build_debug 1} %{?_with_perf: %global build_perf 1} %{?_with_cpupower: %global build_cpupower 1} %if %{with compress_modules} %define kmod_suffix .zst %else %define kmod_suffix %{nil} %endif %if !%{build_debug} # Disable debug rpms. %define _enable_debug_packages %{nil} %define debug_package %{nil} %endif # http://nickdesaulniers.github.io/blog/2018/06/02/speeding-up-linux-kernel-builds-with-ccache/ %if %{with ccache} %define kmake KBUILD_BUILD_TIMESTAMP='' %make CC='ccache gcc' ARCH="%{arch_type}" %else %define kmake %make CC='gcc' ARCH="%{arch_type}" %endif # there are places where parallel make don't work %define smake make %ifarch %{ix86} %{x86_64} %define arch_type x86 %endif %ifarch aarch64 %define arch_type arm64 %endif # 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") # # SRC RPM description # Summary: The Linux kernel Name: kernel-%{kernelversion}.%{patchlevel}-%{flavour} Version: %{kversion} Release: %{fullrpmrel} License: GPLv2 Group: System/Kernel and hardware URL: http://www.kernel.org #################################################################### # # Sources # Source0: https://cdn.kernel.org/pub/linux/kernel/v%{kernelversion}.x/linux-%{tar_ver}.tar.xz # Kernel configuration files. Source1: kernel-xanmod.config # TODO: make a separate package "ksobirator" and BR it # after testing these macros properly Source3: macros.ksobirator %{load:%{SOURCE3}} # Cpupower: the service, the config, etc. Source50: cpupower.service Source51: cpupower.config Source52: cpupower-start.sh Source53: cpupower.path Source80: kernel.rpmlintrc #################################################################### # Patches #XanMod is a general-purpose Linux kernel distribution with custom settings and new features. Built to provide a stable, responsive and smooth desktop experience. #The real-time version is recommended for critical runtime applications such as Linux gaming eSports, streaming, live productions and ultra-low latency enthusiasts. Patch0: https://github.com/xanmod/linux/releases/download/%{kversion_base}-%{patch_name}%{patch_rel}/patch-%{kversion_base}-%{patch_name}%{patch_rel}.xz # Patches from mainline # none # ROSA-specific patches # Perf docs are built after all the kernels. To validate the xml files # generated during that process, xmlto tries to get DTD files from the Net. # If it fails, the whole build fails, which is unfortunate. Let us avoid # this. Patch101: 0001-perf-skip-xmlto-validation.patch # http://bugs.rosalinux.ru/show_bug.cgi?id=6235 # http://bugs.rosalinux.ru/show_bug.cgi?id=6459 Patch102: 0001-audit-make-it-less-verbose.patch # For kmod() generator of RPM Provides # Changes version of aacraid.ko Patch111: 0001-Remove-RPM-illegal-chars-from-module-version.patch # sent to upstream, https://patchwork.kernel.org/patch/11446123/ Patch302: 0001-sign-file-full-functionality-with-modern-LibreSSL.patch # Allow to off modules signature check dynamically Patch306: 0001-ROSA-ima-allow-to-off-modules-signature-check-dynami.patch # Disable AutoReq AutoReq: 0 # but keep autoprov for kmod(xxx) AutoProv: 1 BuildRequires: bash BuildRequires: bc BuildRequires: binutils BuildRequires: gcc BuildRequires: python3-setuptools # ./scripts/mkcompile_h # in net-tools in rosa2016.1, already installed %if %{mdvver} > 201610 BuildRequires: hostname %endif # For power tools BuildRequires: pkgconfig(ncurses) BuildRequires: kmod-devel kmod-compat BuildRequires: bison BuildRequires: flex BuildRequires: bzip2 BuildRequires: rsync %ifarch x86_64 aarch64 BuildRequires: numa-devel %endif # for perf, cpufreq and all other tools # for cpupower %if %{build_cpupower} BuildRequires: pciutils-devel %endif # for perf %if %{build_perf} BuildRequires: asciidoc BuildRequires: audit-devel BuildRequires: binutils-devel BuildRequires: elfutils-devel BuildRequires: libunwind-devel BuildRequires: newt-devel BuildRequires: perl-devel BuildRequires: python3 BuildRequires: pkgconfig(python3) BuildRequires: xmlto BuildRequires: zlib-devel BuildRequires: pkgconfig(libcrypto) %endif %if %{with uml} BuildRequires: vde-devel %endif # (To generate keys) # LibreSSL has GOST support without editing openssl.cnf # or dlopen()-ing external library BuildRequires: libressl libressl-devel # To verify signatures (find, xargs, hexdump) BuildRequires: findutils util-linux %if %{with binary_extra_modules} BuildRequires: auto-krokodil-rpm-macros %ifarch %{x86_64} %if %{with nvidia_module} BuildRequires: kernel-source-nvidia545 %endif %endif BuildRequires: kernel-source-tripso BuildRequires: kernel-source-ipt-so BuildRequires: kernel-source-v4l2loopback %if %{with binary_shredder} BuildRequires: kernel-source-shredder-kernel %endif # rosa-test-suite is maintained in certified branches only # nlkm, memfreetest, pcietest %endif %if %{with ccache} BuildRequires: ccache %endif %if %{with compress_modules} BuildRequires: zstd %endif Provides: kernel = %{EVRD} Provides: kernel-%{flavour} = %{EVRD} Provides: kernel-abi(%{kver_full}) = %{EVRD} # dnf config-manager --dump | grep installonly Provides: installonlypkg(kernel) = %{EVRD}.image Provides: installonlypkg(kernel) = %{EVRD}.modules # >= because of added support of zstd-compressed modules Requires(posttrans): dracut >= 053-0.git5eb736.5 Requires(posttrans): kmod >= 28-3 # Usually necessary, but sometimes user may want to not install them Recommends: linux-firmware Recommends: wireless-regdb Recommends: crda Recommends: microcode # Set BFQ as default scheduler for HDDs # https://www.phoronix.com/scan.php?page=article&item=linux-50hdd-io Recommends: udev-rules-ioschedulers %if %{with flow_abi} Requires: kernel-%{flavour}-rosa-flow-abi %endif %ifarch %{ix86} Conflicts: arch(x86_64) %endif # XXX temporary hack to upgrade from kernel-headers 1:5.4 %if %{build_headers} Recommends: kernel-headers = %{EVRD} %endif %if %{with binary_extra_modules} %ifarch %{x86_64} %if %{with nvidia_module} %kroko_req_modules_in_kernel -j %{nvidia_545_j} -n %{nvidia_545_n} -p %{kver_full} %endif %endif %endif Obsoletes: kernel-%{flavour}-%{kernelversion}.%{patchlevel}-latest < 5.10.34-2 %description The kernel package contains the Linux kernel (vmlinuz), the core of your operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc. This is a general-purpose kernel. %posttrans # We always regenerate initrd here, even if it already exists. This may # happen if kernel-<...>-devel is installed first, triggers rebuild of # DKMS modules and some of these request remaking of initrd. The initrd # that is created then will be non-functional. But when the user installs # kernel-<...> package, that defunct initrd will be replaced with a working # one here. dracut -f %{initrd_path} %{kver_full} # File triggers from grub packages will handle this. #/usr/sbin/update-grub2 %transfiletriggerin -- %{_modulesdir}/%{kver_full} # Detect all modules, including ones inside kernel-module* packages if grep -qE '/.*\.ko(|\..*)' ; then depmod -a %{kver_full} fi %transfiletriggerpostun -- %{_modulesdir}/%{kver_full} # Handle e.g. removal of kernel-module* packages # List of files is not available here (?) depmod -a %{kver_full} %files -f %{kernel_files} %{_bootdir}/System.map-%{kver_full} %{_bootdir}/symvers-%{kver_full}.zst %{_bootdir}/config-%{kver_full} %{_bootdir}/vmlinuz-%{kver_full} %ghost %{initrd_path} %ifarch %{armx} %{_bootdir}/dtb-%{kver_full} %endif %{_modulesdir}/%{kver_full}/modules.* %if %{with flow_abi} %{_modulesdir}/%{kver_full}/kernel/zzz-%{kernelversion}.%{patchlevel}-rosa-flow-abi %endif %if %{with binary_extra_modules} %ifarch %{x86_64} %if %{with nvidia_module} #%%exclude %%{_modulesdir}/%%{kver_full}/kernel/drivers/video/nvidia515 %endif %endif %if %{with binary_shredder} %exclude %{_modulesdir}/%{kver_full}/kernel/extra/shredder-kernel.ko%{kmod_suffix} %endif %exclude %{_modulesdir}/%{kver_full}/kernel/drivers/media/v4l2loopback.ko%{kmod_suffix} %endif ############################################################################ %if %build_devel %package devel Summary: Development files for %{name} Group: Development/Kernel Requires: glibc-devel Requires: ncurses-devel Requires: make Requires: gcc Requires: perl Provides: kernel-devel = %{kverrel} Provides: kernel-%{flavour}-devel = %{kverrel} Provides: installonlypkg(kernel) = %{EVRD}.devel Obsoletes: kernel-%{flavour}-%{kernelversion}.%{patchlevel}-devel-latest < 5.10.34-2 # Have dkms updated/installed before the kernel, scriptlet here checks if dkms exists OrderWithRequires(post): dkms # Try to remove the main kernel package after removing this devel package # because there may be dkms-built kernel modules inside directories owned # by the main package, try to get rid of such files before RPM starts to # deal with directories owned in the main package # (note that the devel package does not explicitly require the main package, # there is no need to do so, a kernel module may be built using just the devel part). OrderWithRequires(postun): %{name} = %{EVRD} %ifarch %{ix86} Conflicts: arch(x86_64) %endif %description devel This package contains the kernel files (headers and build tools) that should be enough to build additional drivers for use with %{name}. %post devel if command -v dkms_autoinstaller >/dev/null 2>&1; then dkms_autoinstaller start %{kver_full} fi %preun devel # If any DKMS modules with REMAKE_INITRD=yes in their configs have been # uninstalled, initrd has been regenerated for the given kernel. However, # the kernel itself might have been uninstalled before, so that (defunct) # initrd image files would be left behind. Remove them if the kernel itself # is no longer installed. Should work if they are uninstalled in parallel # too. if ! test -f /boot/vmlinuz-%{kver_full}; then rm -f /boot/initrd-%{kver_full}.img rm -f /boot/initrd-%{kver_full}_old.img fi if ! command -v dkms >/dev/null 2>&1; then exit 0; fi for ii in $(/usr/sbin/dkms status -k %{kver_full} | awk '{ print $1 $2; }'); do mod=$(echo $ii | awk -v FS=',' '{ print $1; }') ver=$(echo $ii | awk -v FS=',' '{ print $2; }') /usr/sbin/dkms --rpm_safe_upgrade uninstall -m $mod -v $ver -k %{kver_full} || : done %files devel %{devel_root}/Documentation %dir %{devel_root} %dir %{devel_root}/arch %dir %{devel_root}/include %{devel_root}/arch/um %{devel_root}/arch/x86 %{devel_root}/arch/arm %{devel_root}/arch/arm64 %{devel_root}/block %{devel_root}/certs %{devel_root}/crypto %{devel_root}/drivers %{devel_root}/fs %{devel_root}/include/soc %{devel_root}/include/acpi %{devel_root}/include/asm-generic %{devel_root}/include/clocksource %{devel_root}/include/config %{devel_root}/include/crypto %{devel_root}/include/drm %{devel_root}/include/dt-bindings %{devel_root}/include/generated %{devel_root}/include/keys %{devel_root}/include/kvm %{devel_root}/include/kunit %{devel_root}/include/linux %{devel_root}/include/math-emu %{devel_root}/include/media %{devel_root}/include/memory %{devel_root}/include/misc %{devel_root}/include/net %{devel_root}/include/pcmcia %{devel_root}/include/ras %{devel_root}/include/rdma %{devel_root}/include/scsi %{devel_root}/include/sound %{devel_root}/include/target %{devel_root}/include/trace %{devel_root}/include/uapi %{devel_root}/include/vdso %{devel_root}/include/video %{devel_root}/include/xen %{devel_root}/include/ufs %{devel_root}/include/rv %{devel_root}/init %{devel_root}/ipc %{devel_root}/kernel %{devel_root}/lib %{devel_root}/mm %{devel_root}/net %{devel_root}/samples %{devel_root}/scripts %{devel_root}/security %{devel_root}/sound %{devel_root}/tools %{devel_root}/usr %{devel_root}/virt %{devel_root}/.config %{devel_root}/Kbuild %{devel_root}/Kconfig %{devel_root}/Makefile %{devel_root}/Module.symvers %{devel_root}/arch/Kconfig %{devel_root}/arch/loongarch %{devel_root}/io_uring %{devel_root}/rust %{_modulesdir}/%{kver_full}/build %{_modulesdir}/%{kver_full}/source %endif ############################################################################ %if %build_debug %package debuginfo Summary: Debuginfo for %{name} Group: Development/Debug Provides: kernel-debug = %{kverrel} AutoReq: 0 AutoProv: 0 %description debuginfo This package contains the files with debuginfo for %{name}. %files debuginfo -f %{debuginfo_files} %{_bootdir}/vmlinux-%{kver_full} %endif ############################################################################ %if %build_doc %package doc Summary: Various documentation bits found in the kernel source Group: Documentation Buildarch: noarch %description doc This package contains documentation files from the kernel source. %files doc %doc linux-%{tar_ver}/Documentation/* %endif ############################################################################ %if %{build_perf} %package -n perf Summary: perf tool and the supporting documentation Group: System/Kernel and hardware %description -n perf The package contains perf tool and the supporting documentation. %files -n perf %{_bindir}/perf %ifarch x86_64 %{_bindir}/perf-read-vdso32 %endif %{_bindir}/trace %dir %{_prefix}/libexec/perf-core #%%dir %%{_libdir}/traceevent #%%dir %%{_libdir}/traceevent/plugins #%%{_libdir}/traceevent/plugins/* %{_prefix}/libexec/perf-core/* %{_mandir}/man[1-8]/perf* %{_sysconfdir}/bash_completion.d/perf %{_datadir}/perf-core/strace/groups/* %{_datadir}/doc/perf-tip/*.txt #/usr/lib/perf/examples/bpf/* #/usr/lib/perf/include/bpf/* #asks for local build? #%%{_libdir}/libperf-jvmti.so %endif ############################################################################ %if %{build_cpupower} %package -n cpupower Summary: The cpupower tools Group: System/Kernel and hardware %description -n cpupower The cpupower tools. %post -n cpupower if [ $1 -ge 0 ]; then # Do not enable/disable cpupower.service directly, because it should start # when cpupower.path triggers it. /bin/systemctl enable cpupower.path >/dev/null 2>&1 || : /bin/systemctl start cpupower.path >/dev/null 2>&1 || : fi %preun -n cpupower if [ $1 -eq 0 ]; then /bin/systemctl --no-reload disable cpupower.path > /dev/null 2>&1 || : /bin/systemctl stop cpupower.path > /dev/null 2>&1 || : fi %files -n cpupower -f cpupower.lang %{_bindir}/cpupower %{_bindir}/cpupower-start.sh #%%{_libdir}/libcpupower.so.0 %{_libdir}/libcpupower.so.0.0.1 %{_libdir}/libcpupower.so.1 %{_unitdir}/cpupower.service %{_unitdir}/cpupower.path %{_datadir}/bash-completion/completions/cpupower %{_mandir}/man[1-8]/cpupower* %config(noreplace) %{_sysconfdir}/sysconfig/cpupower ############################################################################ %package -n cpupower-devel Summary: Development files for cpupower Group: Development/Kernel Requires: cpupower = %{EVRD} Conflicts: %{_lib}cpufreq-devel %description -n cpupower-devel This package contains the development files for cpupower. %files -n cpupower-devel %{_libdir}/libcpupower.so %{_includedir}/cpufreq.h %{_includedir}/cpuidle.h %endif ############################################################################ %if %{build_headers} %package -n kernel-headers Summary: Linux kernel header files mostly used by your C library Group: System/Kernel and hardware Provides: linux-userspace-headers = %{EVRD} Provides: kernel-release-headers = %{EVRD} %description -n kernel-headers C header files from the Linux kernel. The header files define structures and constants that are needed for building most standard programs, notably the C library. This package is not suitable for building kernel modules, you should use the 'kernel-devel' package instead. %files -n kernel-headers %{_includedir}/* # Don't conflict with cpupower-devel %if %{build_cpupower} %exclude %{_includedir}/cpufreq.h %exclude %{_includedir}/cpuidle.h %endif %endif ############################################################################ %if %{with uml} %package uml Summary: User Mode Linux binary Group: System/Kernel and hardware Provides: kernel-uml = %{kverrel} Provides: kernel-uml-%{flavour} = %{kverrel} Provides: installonlypkg(kernel) = %{EVRD}.uml Obsoletes: kernel-uml-%{flavour}-%{kernelversion}.%{patchlevel}-latest < 5.10.34-2 %description uml User Mode Linux binary. Stripped, debug is in %{name}-debuginfo. %files uml %{_bindir}/linux-uml-%{kver_full} #------------------------------------------------ %package uml-modules Summary: User Mode Linux (UML) kernel modules Group: System/Kernel and hardware Provides: kernel-uml-modules = %{kverrel} Provides: kernel-uml-modules-%{flavour} = %{kverrel} Provides: installonlypkg(kernel-module) = %{EVRD}.uml Obsoletes: kernel-uml-modules-%{flavour}-%{kernelversion}.%{patchlevel}-latest < 5.10.34-2 %description uml-modules User Mode Linux (UML) kernel modules - not compressed - not stripped - signed %files uml-modules /lib/modules-uml/%{kver_full} %endif #------------------------------------------------ %if %{with binary_extra_modules} %ifarch %{x86_64} %if %{with nvidia_module} %kroko_kmod_pkg -r %{kroko_release} -j %{nvidia_545_j} -n %{nvidia_545_n} -f %{flavour} -k %{kernelversion}.%{patchlevel} -m %{sublevel} -p %{kver_full} -s %{NAME} -c %{kmod_suffix} %endif %endif %if %{with binary_shredder} %ksob_mk_module_pkg -n shredder-kernel -s extra -r rosa-shredder-user %endif #------------------------------------------------ %endif ############################ %if %{with flow_abi} %package -n kernel-%{flavour}-rosa-flow-abi Summary: Directory to install third-party binary kernel modules for kernels %{kernelversion}.%{patchlevel}.x Group: System/Kernel and hardware %description -n kernel-%{flavour}-rosa-flow-abi This package contains a directory to install third-party binary kernel modules for kernels %{kernelversion}.%{patchlevel}.x. Some vendors provide binary-only kernel modules. They can put them into /lib/modules/%{kernelversion}.%{patchlevel}-rosa-flow-abi. kmod tools will find them for kernels 5.4.x of "generic" and "nickel" flavours, but there is no guarantee that these modules will load and work correctly on newer or older kernels then the ones they were build against. We call this "flow ABI" because most ABIs are not changed between %{kernelversion}.%{patchlevel}.x releases, but there are no specific guarantees. ABI may evolve and change. We highly recommend to use DKMS and build third-party kernel modules from source for every kernel! This package does nothing, just owns a directory for third-party binary kernel modules. %files -n kernel-%{flavour}-rosa-flow-abi /lib/modules/%{kernelversion}.%{patchlevel}-rosa-flow-abi %endif ################################################ %prep # avoid accidental merge %if 0%{?rpm5} %{error:Package structure is for dnf, not for urpmi!} %endif %setup -q -n %top_dir_name -c %if %{with uml} cp -r %{src_dir} %{src_dir}.uml %endif cd %src_dir %autopatch -p1 # # Setup Begin # # Kernel configuration echo "Creating the kernel configuration file." # Config cp %{SOURCE1} .config echo >> .config #Enable PSI - Pressure Stall Information #https://www.kernel.org/doc/html/latest/accounting/psi.html sed -i 's/CONFIG_PSI_DEFAULT_DISABLED=y/# CONFIG_PSI_DEFAULT_DISABLED is not set/' .config # Disable Kernel module signing sed -i 's/CONFIG_MODULE_SIG_ALL=y/# CONFIG_MODULE_SIG_ALL is not set/' .config sed -i 's/CONFIG_MODULE_SIG=y/# CONFIG_MODULE_SIG is not set/' .config sed -i 's!CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"!CONFIG_MODULE_SIG_KEY=""!' .config #to avoid error "modprobe: FATAL: Module sunrpc not found in directory /lib/modules/..." #sed -i 's/CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES=y/# CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES is not set/' .config sed -i 's!CONFIG_LOCALVERSION="-x64v1"!CONFIG_LOCALVERSION=""!' .config sed -i 's!CONFIG_LOCALVERSION="-x64v2"!CONFIG_LOCALVERSION=""!' .config sed -i 's!CONFIG_LOCALVERSION="-x64v3"!CONFIG_LOCALVERSION=""!' .config sed -i 's!CONFIG_LOCALVERSION="-x64v4"!CONFIG_LOCALVERSION=""!' .config %if %{microarchitecture_level} == "V1" sed -i 's/# CONFIG_GENERIC_CPU is not set/CONFIG_GENERIC_CPU=y/' .config sed -i 's/CONFIG_GENERIC_CPU2=y/# CONFIG_GENERIC_CPU2 is not set/' .config sed -i 's/CONFIG_GENERIC_CPU3=y/# CONFIG_GENERIC_CPU3 is not set/' .config sed -i 's/CONFIG_GENERIC_CPU4=y/# CONFIG_GENERIC_CPU4 is not set/' .config %endif %if %{microarchitecture_level} == "V2" sed -i 's/CONFIG_GENERIC_CPU=y/# CONFIG_GENERIC_CPU is not set/' .config sed -i 's/# CONFIG_GENERIC_CPU2 is not set/CONFIG_GENERIC_CPU2=y/' .config sed -i 's/CONFIG_GENERIC_CPU3=y/# CONFIG_GENERIC_CPU3 is not set/' .config sed -i 's/CONFIG_GENERIC_CPU4=y/# CONFIG_GENERIC_CPU4 is not set/' .config %endif %if %{microarchitecture_level} == "V3" sed -i 's/CONFIG_GENERIC_CPU=y/# CONFIG_GENERIC_CPU is not set/' .config sed -i 's/CONFIG_GENERIC_CPU2=y/# CONFIG_GENERIC_CPU2 is not set/' .config sed -i 's/# CONFIG_GENERIC_CPU3 is not set/CONFIG_GENERIC_CPU3=y/' .config sed -i 's/CONFIG_GENERIC_CPU4=y/# CONFIG_GENERIC_CPU4 is not set/' .config %endif %if %{microarchitecture_level} == "V4" sed -i 's/CONFIG_GENERIC_CPU=y/# CONFIG_GENERIC_CPU is not set/' .config sed -i 's/CONFIG_GENERIC_CPU2=y/# CONFIG_GENERIC_CPU2 is not set/' .config sed -i 's/CONFIG_GENERIC_CPU3=y/# CONFIG_GENERIC_CPU3 is not set/' .config sed -i 's/# CONFIG_GENERIC_CPU4 is not set/CONFIG_GENERIC_CPU4=y/' .config %endif touch %{build_dir}/.config.append # get rid of unwanted files find . -name '*~' -o -name '*.orig' -o -name '*.append' -delete # wipe all .gitignore/.get_maintainer.ignore files find . -name "*.g*ignore" -delete # Enable debug info if requested. sed -i '/CONFIG_DEBUG_INFO/d' .config %if %build_debug echo 'CONFIG_DEBUG_INFO=y' >> %{build_dir}/.config.append echo 'CONFIG_GDB_SCRIPTS=y' >> %{build_dir}/.config.append echo '# CONFIG_DEBUG_INFO_REDUCED is not set' >> %{build_dir}/.config.append echo '# CONFIG_DEBUG_INFO_COMPRESSED is not set' >> %{build_dir}/.config.append echo '# CONFIG_DEBUG_INFO_SPLIT is not set' >> %{build_dir}/.config.append echo 'CONFIG_DEBUG_INFO_DWARF4=y' >> %{build_dir}/.config.append echo '# CONFIG_DEBUG_INFO_BTF is not set' >> %{build_dir}/.config.append %else echo '# CONFIG_DEBUG_INFO is not set' >> %{build_dir}/.config.append %endif # Memory wiping # Introduced in kernel 5.3 by commit 6471384af2a6530696fc0203bafe4de41a23c9ef # Estimated performance impact is described in the commit # "Fill newly allocated pages and heap objects with zeroes." # To enable, add to cmdline: init_on_alloc=1 ####sed -i '/CONFIG_INIT_ON_ALLOC_DEFAULT_ON/d' .config ####echo CONFIG_INIT_ON_ALLOC_DEFAULT_ON=n >> %{build_dir}/.config.append # "Fill freed pages and heap objects with zeroes" # To disable, add to cmdline: init_on_free=0 ####sed -i '/CONFIG_INIT_ON_FREE_DEFAULT_ON/d' .config ####echo CONFIG_INIT_ON_FREE_DEFAULT_ON=n >> %{build_dir}/.config.append # Here enabling only either only init_on_free or only init_on_alloc # makes sense; init_on_alloc is not about protecting information. # To load kernel keyring in UML for i in STREEBOG SHA1 SHA256 SHA512 ECRDSA RSA ; do if ! grep -q "^CONFIG_CRYPTO_${i}=y$" .config; then sed -i "/CONFIG_CRYPTO_${i}/d" .config echo "CONFIG_CRYPTO_${i}=y" >> %{build_dir}/.config.append fi done cat %{build_dir}/.config.append >> .config # Store the config file in the appropriate directory. CONFIG_DIR=arch/%{arch_type}/configs mkdir -p "${CONFIG_DIR}" cfg_file=arch/%{arch_type}/configs/%{arch_suffix}_defconfig-%{flavour} make ARCH=%{arch_type} oldconfig # When it is needed to edit kernel configs, run: # abf fetch # rpmbuild --define "_sourcedir $PWD" --with=fail -bb kernel.spec # and then work with the config in the buildroot with applied patches etc. %{?_with_fail:exit 1} mv .config ${cfg_file} echo "Created ${cfg_file}." # make sure the kernel has the sublevel we know it has... LC_ALL=C sed -ri "s/^SUBLEVEL.*/SUBLEVEL = %{sublevel}/" Makefile # get rid of unwanted files find . -name '*~' -o -name '*.orig' -o -name '*.append' | %kxargs rm -f find . -name '.get_maintainer.ignore' | %kxargs rm -f # Versionize python shebang (#!/usr/bin/env python -> #!/usr/bin/python3) in scripts grep -Irl '^#!/usr/bin/env python' | xargs sed -i '1 s,^#!/usr/bin/env python$,#!%{__python3},' # Drop env from bash scripts sed -i '1 s,^#!.*env .*,#!%{_bindir}/bash,' scripts/config # Drop env from perl scripts grep -IrlE '^#!.*env perl' | xargs sed -i -e '1 s,^#!/usr/bin/env perl$,#!{_bindir}/perl,' cat /dev/null > localversion ############################################################################ %build rm -rf %{temp_root} install -d %{temp_root} cd %src_dir # .config %smake -s mrproper cp arch/%{arch_type}/configs/%{arch_suffix}_defconfig-%{flavour} .config # make sure EXTRAVERSION says what we want it to say LC_ALL=C sed -ri "s/^EXTRAVERSION.*/EXTRAVERSION = .xm%{patch_rel}-%{fullrpmrel}-%{flavour}-%{buildrpmrel}/" Makefile # build the kernel echo "Building kernel %{kver_full}" TARGETS="all" # need to install dtbs to proper boot arm64 devices %ifarch %{armx} TARGETS="$TARGETS dtbs" %endif %kmake V=1 -s $TARGETS # Install modules mkdir -p %{temp_modules}/%{kver_full} %smake INSTALL_MOD_PATH=%{temp_root} KERNELRELEASE=%{kver_full} modules_install %if %{with binary_extra_modules} # Build and install procedure is specific to each Makefile from kernmel-source-* packages # See also: https://www.kernel.org/doc/html/latest/kbuild/modules.html # Copy directory because write permissions are required # `make modules_install` must be done before this, otherwise these copied files will be deleted %if %{with nvidia_module} _build_nvidia(){ cp -r "$(rpm -q --qf "/usr/src/nvidia${1}-%%{VERSION}-%%{RELEASE}" kernel-source-nvidia${1})" kernel-source-nvidia${1} pushd kernel-source-nvidia${1} %make SYSSRC=%{src_dir} mkdir -p %{temp_modules}/%{kver_full}/kernel/drivers/video/nvidia${1}.%{kroko_release} for i in *.ko do # put them here to extract debug and compress, will be moved later install -m0644 "$i" %{temp_modules}/%{kver_full}/kernel/drivers/video/nvidia${1}.%{kroko_release}/"$i" done popd rm -fr kernel-source-nvidia${1} # for rosa-kernel-tools mkdir -p %{temp_root}/var/spool/initramfs-regen touch %{temp_root}/var/spool/initramfs-regen/nvidia${1}.%{kroko_release} } %ifarch %{x86_64} _build_nvidia 545 %endif %endif %if %{with binary_shredder} cp -r "$(rpm -q --qf '/usr/src/shredder-kernel-%%{VERSION}-%%{RELEASE}' kernel-source-shredder-kernel)" kernel-source-shredder-kernel pushd kernel-source-shredder-kernel %kmake KERNEL_PATH=%{src_dir} mkdir -p %{temp_modules}/%{kver_full}/kernel/extra/ cp shredder-kernel.ko %{temp_modules}/%{kver_full}/kernel/extra/ popd rm -fr kernel-source-shredder-kernel %endif cp -r "$(rpm -q --qf '/usr/src/v4l2loopback-%%{VERSION}-%%{RELEASE}' kernel-source-v4l2loopback)" kernel-source-v4l2loopback pushd kernel-source-v4l2loopback cat Kbuild > Makefile mkdir -p %{temp_modules}/%{kver_full}/kernel/drivers/media make -C %{src_dir} M="$PWD" modules cp v4l2loopback.ko %{temp_modules}/%{kver_full}/kernel/drivers/media pushd rm -fr kernel-source-v4l2loopback %endif %if %{with uml} pushd %{src_dir}.uml %kmake ARCH=um defconfig %kmake ARCH=um linux install -Dm0755 linux %{temp_root}%{_bindir}/linux-uml-%{kver_full} #rm -fv linux %kmake V=1 ARCH=um modules mkdir -p %{temp_root}/lib/modules-uml/%{kver_full}/ %kmake ARCH=um INSTALL_MOD_PATH=%{temp_root}/lib/modules-uml/%{kver_full}/ modules_install popd %endif install -d %{temp_boot} install -m 644 System.map %{temp_boot}/System.map-%{kver_full} install -m 644 .config %{temp_boot}/config-%{kver_full} %{zstd_cmd} Module.symvers install -m 644 Module.symvers.zst %{temp_boot}/symvers-%{kver_full}.zst %ifarch %{armx} %make_build ARCH=%{arch_type} V=1 INSTALL_DTBS_PATH=%{temp_boot}/dtb-%{kver_full} dtbs_install %endif %ifarch aarch64 cp -f arch/arm64/boot/Image.gz %{temp_boot}/vmlinuz-%{kver_full} %else cp -f arch/%{arch_type}/boot/bzImage %{temp_boot}/vmlinuz-%{kver_full} %endif # headers %if %{build_headers} %make INSTALL_HDR_PATH=%{temp_root}%{_prefix} KERNELRELEASE=%{kver_full} headers_install find %{temp_root}%{_prefix} -name .install -or -name ..install.cmd | %kxargs rm -f %endif # remove /lib/firmware, we use a separate linux-firmware package rm -rf %{temp_root}/lib/firmware # Prepare the files for kernel*-devel %if %build_devel mkdir -p %{temp_devel_root} for i in $(find . -name 'Makefile*'); do cp -R --parents $i %{temp_devel_root}; done for i in $(find . -name 'Kconfig*' -o -name 'Kbuild*'); do cp -R --parents $i %{temp_devel_root}; done cp -fR include %{temp_devel_root} cp -fR scripts %{temp_devel_root} cp -fR kernel/bounds.c %{temp_devel_root}/kernel cp -fR kernel/time/timeconst.bc %{temp_devel_root}/kernel/time cp -fR tools %{temp_devel_root}/ cp -fR arch/%{arch_type}/kernel/asm-offsets.{c,s} %{temp_devel_root}/arch/%{arch_type}/kernel/ %ifarch %{ix86} %{x86_64} cp -fR arch/%{arch_type}/kernel/asm-offsets_{32,64}.c %{temp_devel_root}/arch/%{arch_type}/kernel/ cp -fR arch/%{arch_type}/purgatory/* %{temp_devel_root}/arch/%{arch_type}/purgatory/ # needed for arch/x86/purgatory cp -fR lib/*.h lib/*.c %{temp_devel_root}/lib/ cp -fR arch/%{arch_type}/entry/syscalls/syscall* %{temp_devel_root}/arch/%{arch_type}/entry/syscalls/ cp -fR arch/%{arch_type}/tools %{temp_devel_root}/arch/%{arch_type}/ # needed for kexec cp -fR arch/%{arch_type}/boot/*.h %{temp_devel_root}/arch/%{arch_type}/boot/ cp -fR arch/%{arch_type}/boot/*.c %{temp_devel_root}/arch/%{arch_type}/boot/ %endif cp -fR arch/%{arch_type}/include %{temp_devel_root}/arch/%{arch_type}/ cp -fR .config Module.symvers %{temp_devel_root} # Needed for truecrypt build (Danny) cp -fR drivers/md/dm.h %{temp_devel_root}/drivers/md/ # Needed for lirc_gpio (#39004) cp -fR drivers/media/pci/bt8xx/bttv{,p}.h %{temp_devel_root}/drivers/media/pci/bt8xx/ cp -fR drivers/media/pci/bt8xx/bt848.h %{temp_devel_root}/drivers/media/pci/bt8xx/ cp -fR drivers/media/pci/bt8xx/btcx-risc.h %{temp_devel_root}/drivers/media/common/ # add acpica header files, needed for fglrx build cp -fR drivers/acpi/acpica/*.h %{temp_devel_root}/drivers/acpi/acpica/ # SELinux needs security/selinux/include cp -fR security/selinux/include %{temp_devel_root}/security/selinux for i in alpha arc avr32 blackfin c6x cris csky frv h8300 hexagon ia64 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_root}/arch/$i done # Clean the scripts tree, and make sure everything is ok (sanity check) # running prepare+scripts (tree was already "prepared" in build) pushd %{temp_devel_root} %smake V=1 -s clean ARCH=%{arch_type} popd rm -f %{temp_devel_root}/.config.old # fix permissions chmod -R a+rX %{temp_devel_root} # endif build_devel %endif # TODO: maybe move to /usr/lib/debug? %if %build_debug find %{temp_modules}/%{kver_full}/kernel \ -name "*.ko" | \ %kxargs -I '{}' objcopy --only-keep-debug '{}' '{}'.debug find %{temp_modules}/%{kver_full}/kernel \ -name "*.ko" | %kxargs -I '{}' \ sh -c 'cd `dirname {}`; \ objcopy --add-gnu-debuglink=`basename {}`.debug \ --strip-debug `basename {}`' %endif # https://patchwork.kernel.org/patch/11446123/ _libressl_sign(){ if [ ! -f "$1" ]; then echo "No file $1" return 0 fi f="$1" unset f } export -f _libressl_sign find %{temp_modules}/%{kver_full}/kernel \ %if %{with uml} %{temp_root}/lib/modules-uml/%{kver_full} \ %endif -name '*.ko' -print0 | sort -u | \ xargs --null -P "$(nproc)" -I {} "$SHELL" -e -x -c 'if ! _libressl_sign "{}"; \ then echo Failed _libressl_sign on "{}" && exit 1; fi' # set extraversion to match srpm to get nice version reported by the tools LC_ALL=C sed -ri "s/^EXTRAVERSION.*/EXTRAVERSION = -%{fullrpmrel}/" Makefile %if %{build_perf} %smake -C tools/perf -s PYTHON=%{__python3} HAVE_CPLUS_DEMANGLE=1 WERROR=0 NO_LIBTRACEEVENT=1 prefix=%{_prefix} lib=%{_lib} NO_GTK2=1 all %smake -C tools/perf -s prefix=%{_prefix} lib=%{_lib} NO_GTK2=1 NO_LIBTRACEEVENT=1 man %endif %if %{build_cpupower} # make sure version-gen.sh is executable. chmod +x tools/power/cpupower/utils/version-gen.sh %make -C tools/power/cpupower CPUFREQ_BENCH=false %endif ############################################################################ %install cd %src_dir # We want to be able to test several times the install part rm -rf %{buildroot} cp -a %{temp_root} %{buildroot} # compressing modules %if %{with compress_modules} # Tested on /lib/modules/5.10.34-generic-2rosa2019.1-x86_64, the results are the following: # * decompressed: 266.3 MiB # * xz -9 --extreme: 67.8 MiB # * zstd --ultra -22 without training: 73.5 MiB # * zstd -6 without training: 79.6 MiB # * zstd --ultra -22 with training: 66.3 MiB (the winner!) # Training takes only a few minutes, make it here in place with current zstd and kernel modules. # But! Decompressing also requires a dictionary for zstd, that will be too complex, so not using training :( # We already use zstd in dracut to compress initrds quickly and with good compression ration. # Testing speed of loading modules: # `time modinfo bcache.ko.xz` took 0,048s, `time modinfo bcache.ko.zstd` took 0,014s (for multiple times) # find /lib/modules/5.10.34-generic-2rosa2019.1-x86_64 -type f -name '*.ko.zst' > /tmp/zst.list # time { for i in `cat /tmp/zst.list`; do modinfo $i >/dev/null 2>&1; done ;} # took ~31-40s, with disk cache (2+ runs) ~33s # find /lib/modules/5.10.34-generic-1rosa2019.1-x86_64 -type f -name '*.ko.xz' > /tmp/xz.list # time { for i in `cat /tmp/xz.list`; do modinfo $i >/dev/null 2>&1; done ;} # took 43-47s, with disk cache (2+ runs) ~42s, +21% # zstd-compressed initramfs image initrd-5.10.34-generic-1rosa2019.1-x86_64.img with *.ko.xz is 56,3 MiB # zstd-compressed initramfs image initrd-5.10.34-generic-2rosa2019.1-x86_64.img with *.ko.zst is 58,4 MiB (+3.6%) # /lib/modules/5.10.34-generic-1rosa2019.1-x86_64 (*.ko.xz) is 78,1 MiB # /lib/modules/5.10.34-generic-2rosa2019.1-x86_64 (*.ko.zst) is 83,9 MiB (+7%) # When zstd is compressing cpio (initrd image) with zstd-compressed kernel modules inside it, does it recompress data? # It is not easy to make a choice between zstd and xz for kernel modules... Disk space (and so speed of installing # RPM packages) is not much bigger, we do not try to support super low end devices, operation speed is a bit better. # I have not seen measurable difference in startup time according to systemd-analyze. # Note that decompression after zstd --ultra -22 will consume more memory than after zstd -6, see commit message in # https://github.com/torvalds/linux/commit/73f3d1b48f5069d46b. I did not benchmark -6 vs -22 in runtime. # Let's use zstd for now. # zstd may also be used to compress linux-firmware to save a lot of space on disk, # but upstream kernels still cannot decompress it. #%%{zstd_cmd} -T0 --train $(find . -type f -name '*.ko') #[ -f dictionary ] # -T1 (one thread) because we run multiple zstd processes by xargs find %{target_modules} -name "*.ko" | %kxargs %{zstd_cmd} --rm -T1 #-D dictionary #rm -f dictionary %endif %if %{with binary_extra_modules} %if %{with nvidia_module} # Move nvidia modules to manage them via alternatives(8), leave *.debug # TODO: better handle debug here and in the package in general find %{target_modules}/%{kver_full}/kernel/drivers/video -name 'nvidia???.*' -type d -maxdepth 1 | while read -r line do nv="$(basename "$line")" mkdir -p %{buildroot}%{kroko_kmods_dir}/"$nv"-%{kver_full} mv -v "$line"/*.ko%{kmod_suffix} %{buildroot}%{kroko_kmods_dir}/"$nv"-%{kver_full} dir_no_buildroot="$(echo "$line" | sed -e 's,^%{buildroot},,')" echo "%exclude $dir_no_buildroot" >> %{kernel_files} %if %{build_debug} echo "%dir $dir_no_buildroot" >> %{debuginfo_files} %endif done %endif %endif find %{buildroot}%{_modulesdir}/%{kver_full} -type f -name '*.ko%{kmod_suffix}' | sed -e 's,^%{buildroot},,' | sort -u >> %{kernel_files} find %{buildroot}%{_modulesdir}/%{kver_full} -type d | sed -e 's,^%{buildroot},%dir ,' | sort -u >> %{kernel_files} # We estimate the size of the initramfs because rpm needs to take this size # into consideration when performing disk space calculations (See rhbz#530778) # 65 MiB is a bit more than needed, but let's be more sure that there is enought space. # On my PC, zstd-compressed initrds take 58,5 MiB. # Real size of the RPM package should not increase because RPM compresses the payload. # This file is %%ghost, so the real initrd will be deleted when uninstalling this package. dd if=/dev/zero of=%{buildroot}%{initrd_path} bs=1M count=65 %if %build_debug install -m 644 vmlinux %{buildroot}%{_bootdir}/vmlinux-%{kver_full} find %{buildroot}%{_modulesdir} -type f -name '*.debug' | sed -e 's,^%{buildroot},,' | sort -u >> %{debuginfo_files} %endif pushd %{target_modules} for i in *; do rm -f $i/build $i/source ln -sf /usr/src/linux-$i $i/build ln -sf /usr/src/linux-$i $i/source done # sniff, if we compressed all the modules, we change the stamp :( # we really need the depmod -ae here for i in *; do /sbin/depmod -ae -b %{buildroot} -F %{target_boot}/System.map-$i $i echo $? done # We used to create modules.description files which contained the # description strings for the modules as shown by modinfo. These files # are unlikely to be used right now, so create them (in case some old tool # checks for their existence) but keep them empty. for i in *; do touch $i/modules.description done popd # need to set extraversion to match srpm again to avoid rebuild LC_ALL=C sed -ri "s/^EXTRAVERSION.*/EXTRAVERSION = -%{fullrpmrel}/" Makefile %if %{build_perf} # Perf tool binary and supporting scripts/binaries make -C tools/perf -s V=1 DESTDIR=%{buildroot} WERROR=0 HAVE_CPLUS_DEMANGLE=1 NO_LIBTRACEEVENT=1 prefix=%{_prefix} lib=%{_lib} install # Versionize shebang (#!/usr/bin/env python -> #!/usr/bin/python3) sed -i '1 s,^#!/usr/bin/env python$,#!%{__python3},' \ %{buildroot}%{_libexecdir}/perf-core/scripts/python/exported-sql-viewer.py \ %{buildroot}%{_libexecdir}/perf-core/scripts/python/libxed.py sed -i -e '1s,^#!/usr/bin/python$,#!%{__python3},' \ %{buildroot}%{_libexecdir}/perf-core/tests/shell/lib/perf_json_output_lint.py # Perf man pages (note: implicit rpm magic compresses them later) make -C tools/perf -s V=1 DESTDIR=%{buildroot} WERROR=0 HAVE_CPLUS_DEMANGLE=1 NO_LIBTRACEEVENT=1 prefix=%{_prefix} install-man %endif %if %{build_cpupower} make -C tools/power/cpupower DESTDIR=%{buildroot} libdir=%{_libdir} mandir=%{_mandir} CPUFREQ_BENCH=false install rm -f %{buildroot}%{_libdir}/*.{a,la} %find_lang cpupower mv cpupower.lang ../ chmod 0755 %{buildroot}%{_libdir}/libcpupower.so* mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig install -m644 %{SOURCE50} %{buildroot}%{_unitdir}/cpupower.service install -m644 %{SOURCE53} %{buildroot}%{_unitdir}/cpupower.path install -m644 %{SOURCE51} %{buildroot}%{_sysconfdir}/sysconfig/cpupower install -m755 %{SOURCE52} %{buildroot}%{_bindir}/cpupower-start.sh %endif # delete junk rm -fr %{buildroot}%{_usr}/src/*/kernel-source-* %if %{with flow_abi} # Prefix with "zzz" to put this directory into the end of search list # and avoid tricks with depmod configs mkdir -p %{buildroot}/lib/modules/%{kernelversion}.%{patchlevel}-rosa-flow-abi ln -s /lib/modules/%{kernelversion}.%{patchlevel}-rosa-flow-abi %{buildroot}%{_modulesdir}/%{kver_full}/kernel/zzz-%{kernelversion}.%{patchlevel}-rosa-flow-abi %endif