Skip to content

Commit

Permalink
builddeb: Add linux-tools package with perf
Browse files Browse the repository at this point in the history
Original Author: Riku Voipio <riku.voipio@linaro.org>

Perf is shipped in debian in linux-tools-$version package. Extend
the existing to builddeb script to build perf if BUILD_TOOLS=y
is added the make deb-pkg line

Some features of this patch I'm uncomfortable with:

1. Relative paths are resoved to absolute ones
   Especially with separate O= buildd, perf build from tools/perf dir
   fail.

2. Unsetting LDFLAGS
   make -> shell (builddeb) -> make expands variables. The LDFLAGS as
   set by toplevel makefile are for kernel, so we just unset the flag
   here.

3. Replaces ubuntu/debian packages instead attempting to fit to
   the linux-base/linux-tools-common frameworks. I think people who
   want to run "make deb-pkg" for their kernels would rather keep this
   simple.

4. More tools than just perf could be built - unfortunately most
   tools fail to have a working "install" target and/or else have
   build process inconsistent with other tools. A topic for another
   patch series.

Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
xanmod committed Nov 2, 2020
1 parent 209cae6 commit aaf08d2
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion scripts/package/builddeb
Expand Up @@ -101,8 +101,10 @@ deploy_libc_headers () {

version=$KERNELRELEASE
tmpdir=debian/linux-image
tools_dir=debian/linux-tools
dbg_dir=debian/linux-image-dbg
packagename=linux-image-$version
tools_packagename=linux-tools-$version
dbg_packagename=$packagename-dbg

if [ "$ARCH" = "um" ] ; then
Expand All @@ -126,7 +128,7 @@ esac
BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes)

# Setup the directory structure
rm -rf "$tmpdir" "$dbg_dir" debian/files
rm -rf "$tmpdir" "$dbg_dir" "$tools_dir" debian/files
mkdir -m 755 -p "$tmpdir/DEBIAN"
mkdir -p "$tmpdir/lib" "$tmpdir/boot"

Expand Down Expand Up @@ -213,6 +215,35 @@ fi

create_package "$packagename" "$tmpdir"

if [ -n "$BUILD_TOOLS" ] ; then
# HACK - change output dir from relative to absolute
mkdir -p $tools_dir
tools_dest=`readlink -f $tools_dir`
if [ -n "$O" ] ; then
output=`readlink -f $objtree`
mkdir -p $output/tools/perf
output="O=$output/tools/perf"
fi
$MAKE -C $srctree/tools/perf $output LDFLAGS=-static srctree=$KBUILD_SRC prefix=$tools_dest/usr install
cat <<EOF >> debian/control
Package: $tools_packagename
Architecture: any
Replaces: linux-base, linux-tools-common
Depends: \${shlibs:Depends}
Description: Performance analysis tools for Linux $version
This package contains the 'perf' performance analysis tools for Linux
kernel version $version .
EOF

if [ -d "$tools_dest/usr/lib64" ] ; then
mv $tools_dest/usr/lib64/* $tools_dest/usr/lib && rm -rf $tools_dest/usr/lib64
fi

dpkg-shlibdeps $tools_dest/usr/bin/* $tools_dest/usr/lib/traceevent/plugins/*
create_package "$tools_packagename" "$tools_dir"
fi

if [ -n "$BUILD_DEBUG" ] ; then
# Build debug package
# Different tools want the image in different locations
Expand Down

0 comments on commit aaf08d2

Please sign in to comment.