Blob Blame History Raw
# Much of this is borrowed from the original kernel.spec
# It needs a bunch of the macros for rawhide vs. not-rawhide builds.

# this should go away soon
%define _legacy_common_support 1

# For a stable, released kernel, released_kernel should be 1. For rawhide
# and/or a kernel built from an rc or git snapshot, released_kernel should
# be 0.
%global released_kernel 0
%global baserelease 1
%global fedora_build %{baserelease}

# base_sublevel is the kernel version we're starting with and patching
# on top of -- for example, 3.1-rc7-git1 starts with a 3.0 base,
# which yields a base_sublevel of 0.
%global base_sublevel 14

## If this is a released kernel ##
%if 0%{?released_kernel}

# Do we have a -stable update to apply?
%global stable_update 0
# Set rpm version accordingly
%if 0%{?stable_update}
%global stablerev %{stable_update}
%global stable_base %{stable_update}
%global rpmversion 5.%{base_sublevel}.%{stable_update}

## The not-released-kernel case ##
# The next upstream release sublevel (base_sublevel+1)
%global upstream_sublevel %(echo $((%{base_sublevel} + 1)))

# The rc snapshot level
%global rcrev 2
# Set rpm version accordingly
%global rpmversion 5.%{upstream_sublevel}.0
# Nb: The above rcrev values automagically define Patch00 and Patch01 below.

# pkg_release is what we'll fill in for the rpm Release: field
%if 0%{?released_kernel}

%global pkg_release %{fedora_build}%{?buildid}%{?dist}


# non-released_kernel
%if 0%{?rcrev}
%global rctag .rc%rcrev
%global rctag .rc0
%global gittag .git0
%global pkg_release 0%{?rctag}%{?gittag}.%{fedora_build}%{?buildid}%{?dist}


# The kernel tarball/base version
%global kversion 5.%{base_sublevel}
%global KVERREL %{version}-%{release}.%{_target_cpu}

# perf needs this
%undefine _strict_symbol_defs_build

BuildRequires: kmod, patch, bash, tar, git-core
BuildRequires: bzip2, xz, findutils, gzip, m4, perl-interpreter, perl(Carp), perl-devel, perl-generators, make, diffutils, gawk
BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc
BuildRequires: net-tools, hostname, bc, elfutils-devel
BuildRequires: zlib-devel binutils-devel newt-devel python3-docutils perl(ExtUtils::Embed) bison flex xz-devel
BuildRequires: audit-libs-devel glibc-devel glibc-headers glibc-static python3-devel java-devel
BuildRequires: asciidoc xmlto libcap-devel
BuildRequires: opencsd-devel openssl-devel libbabeltrace-devel libtraceevent-devel
BuildRequires: libbpf-devel
BuildRequires: clang llvm
# Used to mangle unversioned shebangs to be Python 3
BuildRequires: /usr/bin/
%ifnarch s390x %{arm}
BuildRequires: numactl-devel
BuildRequires: pciutils-devel gettext ncurses-devel
BuildConflicts: rhbuildsys(DiskFree) < 500Mb
BuildRequires: rpm-build, elfutils
BuildRequires: systemd


# Sources for kernel-tools
Source2000: cpupower.service
Source2001: cpupower.config

# Here should be only the patches up to the upstream canonical Linus tree.

# For a stable release kernel
%if 0%{?stable_base}
Source5000: patch-5.%{base_sublevel}.%{stable_base}.xz
# non-released_kernel case
# These are automagically defined by the rcrev value set up
# near the top of this spec file.
%if 0%{?rcrev}
Source5000: patch-5.%{upstream_sublevel}-rc%{rcrev}.xz

# ongoing complaint, full discussion delayed until ksummit/plumbers
Patch0: 0001-iio-Use-event-header-from-kernel-tree.patch

# rpmlint cleanup
Patch6: 0002-perf-Don-t-make-sourced-script-executable.patch

Name: kernel-tools
Summary: Assortment of tools for the Linux kernel
License: GPLv2
Version: %{rpmversion}
Release: %{pkg_release}
Provides:  cpupowerutils = 1:009-0.6.p1
Obsoletes: cpupowerutils < 1:009-0.6.p1
Provides:  cpufreq-utils = 1:009-0.6.p1
Provides:  cpufrequtils = 1:009-0.6.p1
Obsoletes: cpufreq-utils < 1:009-0.6.p1
Obsoletes: cpufrequtils < 1:009-0.6.p1
Obsoletes: cpuspeed < 1:1.5-16
Requires: kernel-tools-libs = %{version}-%{release}
%description -n kernel-tools
This package contains the tools/ directory from the kernel source
and the supporting documentation.

%package -n perf
Summary: Performance monitoring for the Linux kernel
Requires: bzip2
License: GPLv2
%description -n perf
This package contains the perf tool, which enables performance monitoring
of the Linux kernel.

%global pythonperfsum Python bindings for apps which will manipulate perf events
%global pythonperfdesc A Python module that permits applications \
written in the Python programming language to use the interface \
to manipulate perf events.

%package -n python3-perf
Summary: %{pythonperfsum}
%{?python_provide:%python_provide python3-perf}
%description -n python3-perf

%package -n kernel-tools-libs
Summary: Libraries for the kernels-tools
License: GPLv2
%description -n kernel-tools-libs
This package contains the libraries built from the tools/ directory
from the kernel source.

%package -n kernel-tools-libs-devel
Summary: Assortment of tools for the Linux kernel
License: GPLv2
Requires: kernel-tools = %{version}-%{release}
Provides:  cpupowerutils-devel = 1:009-0.6.p1
Obsoletes: cpupowerutils-devel < 1:009-0.6.p1
Requires: kernel-tools-libs = %{version}-%{release}
Provides: kernel-tools-devel
%description -n kernel-tools-libs-devel
This package contains the development files for the tools/ directory from
the kernel source.

%package -n bpftool
Summary: Inspection and simple manipulation of eBPF programs and maps
License: GPLv2
%description -n bpftool
This package contains the bpftool, which allows inspection and simple
manipulation of eBPF programs and maps.

%package -n libperf
Summary: The perf library from kernel source
License: GPLv2
%description -n libperf
This package contains the kernel source perf library.

%package -n libperf-devel
Summary: Developement files for the perf library from kernel source
License: GPLv2
%description -n libperf-devel
This package includes libraries and header files needed for development
of applications which use perf library from kernel source.

%setup -q -n kernel-%{kversion}%{?dist} -c

cd linux-%{kversion}

# This is for patching either an -rc or stable
%if 0%{?rcrev}
    xzcat %{SOURCE5000} | patch -p1 -F1 -s

%if 0%{?stable_base}
    xzcat %{SOURCE5000} | patch -p1 -F1 -s

%patch0 -p1
%patch6 -p1


# Mangle /usr/bin/python shebangs to /usr/bin/python3
# -p preserves timestamps
# -n prevents creating ~backup files
# -i specifies the interpreter for the shebang -pni "%{__python3} %{py3_shbang_opts}" tools/ tools/perf/scripts/python/*.py scripts/clang-tools

### build
# The kernel tools build with -ggdb3 which seems to interact badly with LTO
# causing various errors with references to discarded sections and symbol
# type errors from the LTO plugin.  Until those issues are addressed
# disable LTO
%define _lto_cflags %{nil}

cd linux-%{kversion}

%global perf_make \
%global perf_python3 -C tools/perf PYTHON=%{__python3}
# perf
# make sure is executable
chmod +x tools/perf/
%{perf_make} %{perf_python3} all

%global tools_make \
  make CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" V=1

# cpupower
# make sure is executable.
chmod +x tools/power/cpupower/utils/
%{tools_make} %{?_smp_mflags} -C tools/power/cpupower CPUFREQ_BENCH=false
%ifarch %{ix86}
    pushd tools/power/cpupower/debug/i386
    %{tools_make} %{?_smp_mflags} centrino-decode powernow-k8-decode
%ifarch x86_64
    pushd tools/power/cpupower/debug/x86_64
    %{tools_make} %{?_smp_mflags} centrino-decode powernow-k8-decode
%ifarch %{ix86} x86_64
   pushd tools/power/x86/x86_energy_perf_policy/
   pushd tools/power/x86/turbostat
   pushd tools/power/x86/intel-speed-select
   %{tools_make} CFLAGS+="-D_GNU_SOURCE -Iinclude"
%endif #turbostat/x86_energy_perf_policy
pushd tools/thermal/tmon/
pushd tools/iio/
pushd tools/gpio/

%global bpftool_make \

pushd tools/bpf/bpftool
pushd tools/lib/perf
make V=1

# Build the docs
pushd tools/kvm/kvm_stat/
%make_build man
pushd tools/perf/Documentation/
%make_build man

### install


cd linux-%{kversion}

# perf tool binary and supporting scripts/binaries
%{perf_make} %{perf_python3} DESTDIR=%{buildroot} lib=%{_lib} install-bin
# remove the 'trace' symlink.
rm -f %{buildroot}%{_bindir}/trace

# For both of the below, yes, this should be using a macro but right now
# it's hard coded and we don't actually want it anyway right now.
# Whoever wants examples can fix it up!

# remove examples
rm -rf %{buildroot}/usr/lib/perf/examples
# remove the stray header file that somehow got packaged in examples
rm -rf %{buildroot}/usr/lib/perf/include/bpf/

# python-perf extension
%{perf_make} %{perf_python3} DESTDIR=%{buildroot} install-python_ext

# perf man pages (note: implicit rpm magic compresses them later)
install -d %{buildroot}/%{_mandir}/man1
install -pm0644 tools/kvm/kvm_stat/kvm_stat.1 %{buildroot}/%{_mandir}/man1/
install -pm0644 tools/perf/Documentation/*.1 %{buildroot}/%{_mandir}/man1/

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 ../
%ifarch %{ix86}
    pushd tools/power/cpupower/debug/i386
    install -m755 centrino-decode %{buildroot}%{_bindir}/centrino-decode
    install -m755 powernow-k8-decode %{buildroot}%{_bindir}/powernow-k8-decode
%ifarch x86_64
    pushd tools/power/cpupower/debug/x86_64
    install -m755 centrino-decode %{buildroot}%{_bindir}/centrino-decode
    install -m755 powernow-k8-decode %{buildroot}%{_bindir}/powernow-k8-decode
chmod 0755 %{buildroot}%{_libdir}/*
mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig
install -m644 %{SOURCE2000} %{buildroot}%{_unitdir}/cpupower.service
install -m644 %{SOURCE2001} %{buildroot}%{_sysconfdir}/sysconfig/cpupower
%ifarch %{ix86} x86_64
   mkdir -p %{buildroot}%{_mandir}/man8
   pushd tools/power/x86/x86_energy_perf_policy
   %{tools_make} DESTDIR=%{buildroot} install
   pushd tools/power/x86/turbostat
   %{tools_make} DESTDIR=%{buildroot} install
   pushd tools/power/x86/intel-speed-select
   %{tools_make} CFLAGS+="-D_GNU_SOURCE -Iinclude" DESTDIR=%{buildroot} install
%endif #turbostat/x86_energy_perf_policy
pushd tools/thermal/tmon
%{tools_make} INSTALL_ROOT=%{buildroot} install
pushd tools/iio
%{tools_make} DESTDIR=%{buildroot} install
pushd tools/gpio
%{tools_make} DESTDIR=%{buildroot} install
pushd tools/kvm/kvm_stat
%{tools_make} INSTALL_ROOT=%{buildroot} install-tools
pushd tools/bpf/bpftool
%{bpftool_make} prefix=%{_prefix} bash_compdir=%{_sysconfdir}/bash_completion.d/ mandir=%{_mandir} install doc-install
pushd tools/lib/perf
make DESTDIR=%{buildroot} prefix=%{_prefix} libdir=%{_libdir} V=1 install install_headers

### scripts

%ldconfig_scriptlets -n kernel-tools-libs

%post -n kernel-tools
%systemd_post cpupower.service

%preun -n kernel-tools
%systemd_preun cpupower.service

%systemd_postun cpupower.service

%files -n perf
%exclude %{_libdir}/traceevent
%doc linux-%{kversion}/tools/perf/Documentation/examples.txt
%license linux-%{kversion}/COPYING

%files -n python3-perf
%license linux-%{kversion}/COPYING

%files -n kernel-tools -f cpupower.lang
%ifarch %{ix86} x86_64
%config(noreplace) %{_sysconfdir}/sysconfig/cpupower
%ifarch %{ix86} x86_64
%license linux-%{kversion}/COPYING

%files -n kernel-tools-libs
%license linux-%{kversion}/COPYING

%files -n kernel-tools-libs-devel

%files -n bpftool
%license linux-%{kversion}/COPYING

%files -n libperf
%license linux-%{kversion}/COPYING

%files -n libperf-devel
%license linux-%{kversion}/COPYING

* Mon Sep 20 2021 Justin M. Forbes <> - 5.15.0-0.rc2.git0.1
- Linux v5.15-rc2

* Mon Sep 13 2021 Justin M. Forbes <> - 5.15.0-0.rc1.git0.1
- Linux v5.15-rc1

* Mon Aug 30 2021 Justin M. Forbes <> - 5.14.0-1
- Linux v5.14.0

* Mon Aug 23 2021 Justin M. Forbes <> - 5.14.0-0.rc7.git0.1
- Linux v5.14-rc7

* Mon Aug 16 2021 Justin M. Forbes <> - 5.14.0-0.rc6.git0.1
- Linux v5.14-rc6

* Mon Aug 09 2021 Justin M. Forbes <> - 5.14.0-0.rc5.git0.1
- Linux v5.14-rc5

* Mon Aug 02 2021 Justin M. Forbes <> - 5.14.0-0.rc4.git0.1
- Linux v5.14-rc4

* Mon Jul 26 2021 Justin M. Forbes <> - 5.14.0-0.rc3.git0.1
- Linux v5.14-rc3

* Thu Jul 22 2021 Fedora Release Engineering <> - 5.14.0-0.rc2.git0.2
- Rebuilt for

* Tue Jul 20 2021 Justin M. Forbes <> - 5.14.0-0.rc2.git0.1
- Linux v5.14-rc2

* Mon Jul 12 2021 Justin M. Forbes <> - 5.14.0-0.rc1.git0.1
- Linux v5.14-rc1

* Mon Jun 28 2021 Justin M. Forbes <> - 5.13.0-1
- Linux v5.13

* Mon Jun 21 2021 Justin M. Forbes <> - 5.13.0-0.rc7.git0.1
- Linux v5.13-rc7

* Tue Jun 15 2021 Justin M. Forbes <> - 5.13.0-0.rc6.git0.1
- Linux v5.13-rc6

* Mon Jun 07 2021 Justin M. Forbes <> - 5.13.0-0.rc5.git0.1
- Linux v5.13-rc5

* Fri Jun 04 2021 Python Maint <> - 5.13.0-0.rc4.git0.2
- Rebuilt for Python 3.10

* Tue Jun 01 2021 Justin M. Forbes <> - 5.13.0-0.rc4.git0.1
- Linux v5.13-rc4

* Tue May 25 2021 Jitka Plesnikova <> - 5.13.0-0.rc3.git0.2
- Perl 5.34 re-rebuild updated packages

* Mon May 24 2021 Justin M. Forbes <> - 5.13.0-0.rc3.git0.1
- Linux v5.13-rc3

* Sat May 22 2021 Jitka Plesnikova <> - 5.13.0-0.rc2.git0.2
- Perl 5.34 rebuild

* Mon May 17 2021 Justin M. Forbes <> - 5.13.0-0.rc2.git0.1
- Linux v5.13-rc2

* Mon May 10 2021 Justin M. Forbes <>
- perf: enable dynamic linking of libbpf

* Mon May 10 2021 Justin M. Forbes <> - 5.13.0-0.rc1.git0.1
- Linux v5.13-rc1

* Thu May 06 2021 Jiri Olsa <>
- Remove libbpf package

* Thu May 06 2021 Justin M. Forbes <>
- Build and package intel-speed-select (rhbz 1882427)

* Tue Apr 27 2021 Justin M. Forbes <> - 5.12.0-1
- Linux v5.12

* Mon Apr 19 2021 Justin M. Forbes <> - 5.12.0-0.rc8.git0.1
- Linux v5.12-rc8

* Mon Apr 12 2021 Justin M. Forbes <> - 5.12.0-0.rc7.git0.1
- Linux v5.12-rc7

* Mon Apr 05 2021 Justin M. Forbes <> - 5.12.0-0.rc6.git0.1
- Linux v5.12-rc6

* Mon Mar 29 2021 Justin M. Forbes <> - 5.12.0-0.rc5.git0.1
- Linux v5.12-rc5

* Mon Mar 22 2021 Justin M. Forbes <> - 5.12.0-0.rc4.git0.1
- Linux v5.12-rc4

* Mon Mar 15 2021 Justin M. Forbes <> - 5.12.0-0.rc3.git0.1
- Linux v5.12-rc3

* Sat Mar 06 2021 Justin M. Forbes <> - 5.12.0-0.rc2.git0.1
- Linux v5.12-rc2

* Mon Mar 01 2021 Justin M. Forbes <> - 5.12.0-0.rc1.git0.1
- Linux v5.12-rc1

* Mon Feb 15 2021 Justin M. Forbes <> - 5.11.0-1
- Linux v5.11.0