make deb-pkg linux-kernel源码支持构建perf工具

  1. 编辑源码中 scripts/package/builddeb 文件,变动如下:
bash 复制代码
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 36185d6..2d6d547 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -92,11 +92,13 @@ 
 fwdir="$objtree/debian/fwtmp"
 kernel_headers_dir="$objtree/debian/hdrtmp"
 libc_headers_dir="$objtree/debian/headertmp"
 dbg_dir="$objtree/debian/dbgtmp"
+tools_dir="$objtree/debian/toolstmp"
 packagename=linux-image-$version
 fwpackagename=linux-firmware-image-$version
 kernel_headers_packagename=linux-headers-$version
 libc_headers_packagename=linux-libc-dev
 dbg_packagename=$packagename-dbg
+tools_packagename=linux-tools-$version
 
 if [ "$ARCH" = "um" ] ; then
 	packagename=user-mode-linux-$version
@@ -119,7 +121,7 @@ 
 esac
 BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)"
+BUILD_TOOLS="$(grep -s '^CONFIG_PERF_EVENTS=y' $KCONFIG_CONFIG || true)"

 # Setup the directory structure
-rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir"
+rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" "$tools_dir"
 mkdir -p "$tmpdir/lib" "$tmpdir/boot"
 mkdir -p "$fwdir/lib/firmware/$version/"
 mkdir -p "$kernel_headers_dir/lib/modules/$version/"
@@ -387,4 +389,31 @@ 
 EOF
 	create_package "$dbg_packagename" "$dbg_dir"
 fi
 
+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= 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
+
+	dpkg-shlibdeps $tools_dest/usr/bin/* $tools_dest/usr/lib/traceevent/plugins/*
+	create_package "$tools_packagename" "$tools_dir"
+fi
+
 exit 0
  1. 添加defconfig文件选项
bash 复制代码
CONFIG_PERF_EVENTS=y
CONFIG_PERF_COUNTERS=y
  1. 执行编译
bash 复制代码
make deb-pkg -j$(nproc)

源码目录上级会生成 linux-tools-xxxx.deb

相关推荐
什么想法都无5 分钟前
stream
java·java stream
m0_748233646 分钟前
WebService简介
java
love静思冥想7 分钟前
Stream `Collectors.toList()` 和 `Stream.toList()` 的区别(Java)
java·stream
dntktop15 分钟前
解锁自动化新高度,zTasker v2.0全方位提升效率
运维·windows
Ch.yang26 分钟前
【Spring】 Bean 注入 HttpServletRequest 能保证线程安全的原理
java·spring·代理模式
web1508509664127 分钟前
基于Mysql、JavaScript、PHP、ajax开发的MBTI性格测试网站(前端+后端)
java
昙鱼35 分钟前
springboot创建web项目
java·前端·spring boot·后端·spring·maven
eternal__day35 分钟前
数据结构(哈希表(中)纯概念版)
java·数据结构·算法·哈希算法·推荐算法
天之涯上上39 分钟前
JAVA开发 在 Spring Boot 中集成 Swagger
java·开发语言·spring boot
2402_8575834941 分钟前
“协同过滤技术实战”:网上书城系统的设计与实现
java·开发语言·vue.js·科技·mfc