When I changed the manual require from libdwarf to elfutils-libs
because the perf tool upstream changed, I got nervous about a few
things. Firstly, having this growingly complex userland binary
packaged without automatic requires so changes like that are
necessary. That change wasn't even really right, since it needs to
be an arch-sensitive require to really win. So Fedora kernel
weenies dimly following the wild upstream perf development actually
managing to hand-maintain that perfectly is manifestly laughable.
Second, sheesh, so now a new/old kernel rpm I only wanted to try
booting might refuse to install because of the wrong version of some
DWARF library? And/or all that gets installed just because I wanted
to boot the kernel? You hear maniacal laughter in the distance.
So I did the following spec hack (not really tested yet). This puts
the perf tool into its own subpackage, i.e. kernel-perf. Now that
subpackage gets normal autorequires and we don't have to worry about
that. You don't have to install kernel-perf to install
kernel{,-variant}. Two notes:
1. There is only one kernel-perf subpackage for all the kernel and
kernel-variant subpackages enabled. I went with one perf binary
and symlinks instead of separate binaries. The upstream code is
really supposed to be a sane userland interface, if not a stable
one. So new kernel sources will change it 8 ways from Sunday.
But unless they've gone even more insane up there, kconfig
differences should not change the kernel-user API that perf is
built to.
2. Not to be confused with the existing perf package, i.e. the
wrapper script (and docs). You still get to have only one of
those installed, with a separate kernel-perf for each kernel
build version you are using.
3. I thought about calling it kernel-tools or something, in case of
future things from tools/ worth installing. But I shied away
from any general name because they all seem misleadingly like a
first-class thing a user would want to install, rather than some
arcane bowels as this really is. I guess if there were more such
things one day, there would be front-end multiplexor scripts as
for perf and then we'd change that package's name too.
(Yes, I know that was 3 out of 2. It's a bonus tangent.)
Is this idea good, bad, or indifferent?
It's really only the hand-maintenance of the rpm deps for the perf binary
that make me want to run and hide. The "you want me to install *what* so I
can rescue this damn lossage with an additional kernel rpm install?"
scenario is only hypothetical off hand (and having some compatible
elfutils-libs installed is already the normal situation anyway)--I just
figure when it bites someone, it will happen to them at the fringes of
their wits' end, so they will be especially peeved.
Thanks,
Roland
Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.2039
diff -u -b -p -r1.2039 kernel.spec
--- kernel.spec 22 Jun 2010 23:11:06 -0000 1.2039
+++ kernel.spec 23 Jun 2010 00:14:50 -0000
@@ -454,9 +454,6 @@ Requires(pre): %{initrd_prereq}\
Requires(pre): kernel-firmware >= %{rpmversion}-%{pkg_release}\
%else\
Requires(pre): linux-firmware\
-%if %{with_perftool}\
-Requires(pre): elfutils-libs\
-%endif\
%endif\
Requires(post): /sbin/new-kernel-pkg\
Requires(preun): /sbin/new-kernel-pkg\
@@ -768,13 +765,26 @@ Group: Development/Debug
This package is required by %{name}-debuginfo subpackages.
It provides the kernel source files common to all builds.
+%if %{with_perftool}
+%package perf
+Summary: Performance monitoring for the Linux kernel
+Group: Development/System
+License: GPLv2
+%description perf
+This package provides the perf tool to match this kernel package.
+Install the perf package to get the %{_sbindir}/perf front-end script.
+%endif
+
%package -n perf
Summary: Performance monitoring for the Linux kernel
Group: Development/System
License: GPLv2
+%if %{with_perftool}
+Requires: kernel-perf(%{_arch}) >= %{version}-%{release}
+%endif
%description -n perf
This package provides the supporting documentation for the perf tool
-shipped in each kernel image subpackage.
+found in the %{name}-perf subpackage.
#
# This macro creates a kernel-<subpackage>-debuginfo package.
@@ -1387,16 +1397,6 @@ BuildKernel() {
make -s ARCH=$Arch V=1 %{?_smp_mflags} $MakeTarget %{?sparse_mflags}
make -s ARCH=$Arch V=1 %{?_smp_mflags} modules %{?sparse_mflags} || exit 1
-%if %{with_perftool}
- pushd tools/perf
-# make sure the scripts are executable... won't be in tarball until 2.6.31 :/
- chmod +x util/generate-cmdlist.sh util/PERF-VERSION-GEN
- make -s V=1 NO_DEMANGLE=1 %{?_smp_mflags} perf
- mkdir -p $RPM_BUILD_ROOT/usr/libexec/
- install -m 755 perf $RPM_BUILD_ROOT/usr/libexec/perf.$KernelVer
- popd
-%endif
-
# Start installing the results
%if %{with_debuginfo}
mkdir -p $RPM_BUILD_ROOT%{debuginfodir}/boot
@@ -1545,6 +1545,11 @@ BuildKernel() {
mkdir -p $RPM_BUILD_ROOT/usr/src/kernels
mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir
ln -sf ../../..$DevelDir $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+
+%if %{with_perftool}
+ [ -z "$Flavour" ] ||
+ ln -snf perf.%{KVERREL} $RPM_BUILD_ROOT%{_libexecdir}/perf.$KernelVer
+%endif
}
###
@@ -1554,6 +1559,7 @@ BuildKernel() {
# prepare directories
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/boot
+mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
cd linux-%{kversion}.%{_target_cpu}
@@ -1577,6 +1583,10 @@ BuildKernel %make_target %kernel_image
BuildKernel %make_target %kernel_image smp
%endif
+%if %{with_perftool}
+make -C tools/perf -s V=1 NO_DEMANGLE=1 %{?_smp_mflags} perf
+%endif
+
%if %{with_doc}
# Make the HTML and man pages.
make %{?_smp_mflags} htmldocs mandocs || %{doc_build_fail}
@@ -1651,12 +1661,16 @@ done
popd
%endif # with_perf
+# perf tool binary
+%if %{with_perftool}
+mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
+install -m 755 tools/perf/perf $RPM_BUILD_ROOT%{_libexecdir}/perf.%{KVERREL}
+%endif
+
# perf shell wrapper
%if %{with_perf}
-mkdir -p $RPM_BUILD_ROOT/usr/sbin/
-cp $RPM_SOURCE_DIR/perf $RPM_BUILD_ROOT/usr/sbin/perf
-chmod 0755 $RPM_BUILD_ROOT/usr/sbin/perf
-mkdir -p $RPM_BUILD_ROOT%{_datadir}/doc/perf
+mkdir -p $RPM_BUILD_ROOT%{_sbindir} $RPM_BUILD_ROOT%{_datadir}/doc/perf
+install -m 755 $RPM_SOURCE_DIR/perf $RPM_BUILD_ROOT%{_sbindir}/perf
%endif
%if %{with_headers}
@@ -1826,10 +1840,16 @@ fi
%files -n perf
%defattr(-,root,root)
%{_datadir}/doc/perf
-/usr/sbin/perf
+%{_sbindir}/perf
%{_datadir}/man/man1/*
%endif
+%if %{with_perftool}
+%files perf
+%defattr(-,root,root)
+%{_libexecdir}/perf.%{KVERREL}*
+%endif
+
# This is %{image_install_path} on an arch where that includes ELF files,
# or empty otherwise.
%define elf_image_install_path %{?kernel_image_elf:%{image_install_path}}
@@ -1845,9 +1865,6 @@ fi
%defattr(-,root,root)\
/%{image_install_path}/%{?-k:%{-k*}}%{!?-k:vmlinuz}-%{KVERREL}%{?2:.%{2}}\
/boot/System.map-%{KVERREL}%{?2:.%{2}}\
-%if %{with_perftool}\
-/usr/libexec/perf.%{KVERREL}%{?2:.%{2}}\
-%endif\
#/boot/symvers-%{KVERREL}%{?2:.%{2}}.gz\
/boot/config-%{KVERREL}%{?2:.%{2}}\
%dir /lib/modules/%{KVERREL}%{?2:.%{2}}\