builddeb improvements
cover builddeb improvements
From: Riku Voipio <[email protected]>
A collection of patches to improve the make deb-pkg target first three patches should be quite straight-forward changes, but the last one is more complicated.
Ben Hutchings (1):
deb-pkg: Add automatic support for armhf architecture
Riku Voipio (3):
builddeb: install dtbs
builddeb: simplify directory creation
RFC: builddeb: add linux-tools package with perf
scripts/package/builddeb | 67 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 17 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/4 deb-pkg: Add automatic support for armhf architecture
From: Ben Hutchings <[email protected]>
The Debian armhf architecture uses the ARM EABI hard-float variant, whereas armel uses the soft-float variant. If the compiler used to compile the kernel uses the __ARM_PCS_VFP ABI, the compiler targets armhf architecture.
v3 by Riku: Use gcc define instead of CONFIG_VFP
--- scripts/package/builddeb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/builddeb +10 -1
@@ -45,7 +45,16 @@ create_package() { arm64) debarch=arm64 ;; arm*) - debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;; + if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then + if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then + debarch=armhf + else + debarch=armel + fi + else + debarch=arm + fi + ;; *) echo "" >&2 echo "** ** ** WARNING ** ** **" >&2
Signature · 1 line
2.1.4
Re: [PATCH 1/4] deb-pkg: Add automatic support for armhf architecture
Quoted 21 lines · [email protected] writes:
From: Ben Hutchings <[email protected]>
The Debian armhf architecture uses the ARM EABI hard-float variant, whereas armel uses the soft-float variant. If the compiler used to compile the kernel uses the
__ARM_PCS_VFPABI, the compiler targets armhf architecture.v3 by Riku: Use gcc define instead of
CONFIG_VFPSigned-off-by Ben Hutchings <[email protected]>Signed-off-by Riku Voipio <[email protected]>--- scripts/package/builddeb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)scripts/package/builddeb +0
-0
scripts/package/builddeb create_package() { · line 49
Quoted 6 lines
scripts/package/builddeb +2
-1@@ -45,7 +45,16 @@ create_package() { arm64) debarch=arm64 ;; arm*) - debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;; + if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then + if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then
Actually, I guess there's nothing preventing you building a armhf kernel with a compiler not having __ARM_PCS_VFP defined by default, but I'm not sure we should take care of this case. One can always use KBUILD_DEBARCH=armhf.
Arnaud
Re: [PATCH 1/4] deb-pkg: Add automatic support for armhf architecture
Quoted 14 lines · Arnaud Patard
scripts/package/builddeb create_package() { · line 49
Quoted 9 lines · [email protected] writes:
scripts/package/builddeb +2
-1@@ -45,7 +45,16 @@ create_package() { arm64) debarch=arm64 ;; arm*) - debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;; + if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then + if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; thenActually, I guess there's nothing preventing you building a armhf kernel with a compiler not having
__ARM_PCS_VFPdefined by default, but I'm not sure we should take care of this case. One can always use KBUILD_DEBARCH=armhf.
I think the common use cases would be a) native compilers or b) cross-compiler targeting the same debian architecture as the rootfs. This patch provides automatic detection for both cases. For corner cases, one will have to manually specify KBUILD_DEBARCH - which one already had to do if one was targeting armhf.
Riku
Re: [PATCH 1/4] deb-pkg: Add automatic support for armhf architecture
Quoted 16 lines · Riku Voipio
Quoted 14 lines · Arnaud Patard
scripts/package/builddeb create_package() { · line 49
Quoted 9 lines · [email protected] writes:
scripts/package/builddeb +2
-1@@ -45,7 +45,16 @@ create_package() { arm64) debarch=arm64 ;; arm*) - debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;; + if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then + if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; thenActually, I guess there's nothing preventing you building a armhf kernel with a compiler not having
__ARM_PCS_VFPdefined by default, but I'm not sure we should take care of this case. One can always use KBUILD_DEBARCH=armhf.
Quoted 3 lines
I think the common use cases would be a) native compilers or b) cross-compiler targeting the same debian architecture as the rootfs. This patch provides automatic detection for both cases.
$CC should be used together with $KBUILD_CFLAGS to behave the same as when building the kernel.
Michal
Re: [PATCH 1/4] deb-pkg: Add automatic support for armhf architecture
Quoted 17 lines · Michal Marek
Quoted 16 lines · Riku Voipio
Quoted 14 lines · Arnaud Patard
scripts/package/builddeb create_package() { · line 49
Quoted 9 lines · [email protected] writes:
scripts/package/builddeb +2
-1@@ -45,7 +45,16 @@ create_package() { arm64) debarch=arm64 ;; arm*) - debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;; + if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then + if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; thenActually, I guess there's nothing preventing you building a armhf kernel with a compiler not having
__ARM_PCS_VFPdefined by default, but I'm not sure we should take care of this case. One can always use KBUILD_DEBARCH=armhf.
Quoted 6 lines
Quoted 3 lines
I think the common use cases would be a) native compilers or b) cross-compiler targeting the same debian architecture as the rootfs. This patch provides automatic detection for both cases.
$CC should be used together with $KBUILD_CFLAGS to behave the same as when building the kernel.
I just tested and it won't work. $KBUILD_CFLAGS has -msoft-float so __ARM_PCS_VFP wont be set. Which makes sense - we wouldn't want kernel to pass anything in float registers. Given the constraint, would you prefer Ben's original patch that checks CONFIG_VFP[1], or my version using CC without KBUILD_CFLAGS?
[1] https://lists.debian.org/debian-arm/2014/06/msg00016.html
Riku
PATCH 2/4 builddeb: install dtbs
In reply to [email protected]From: Riku Voipio <[email protected]>
When kernel is built with CONFIG_OF, install all built device tree files built. The installation location used is same as toplevel INSTALL_DTBS_PATH.
--- scripts/package/builddeb | 4 ++++ 1 file changed, 4 insertions(+)
scripts/package/builddeb +4 -0
@@ -174,6 +174,10 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then fi fi +if grep -q '^CONFIG_OF=y' $KCONFIG_CONFIG ; then + $MAKE dtbs_install KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/boot/dtbs/$version/" +fi + if [ "$ARCH" != "um" ]; then $MAKE headers_check KBUILD_SRC= $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr"
Signature · 1 line
2.1.4
Re: [PATCH 2/4] builddeb: install dtbs
[email protected] writes:
Hi,
Quoted 5 lines
From: Riku Voipio <[email protected]>
When kernel is built with
CONFIG_OF, install all built device tree files built. The installation location used is same as toplevelINSTALL_DTBS_PATH.
Already sent a "better" patch for that (your patch is not handling system with CONFIG_OF and without dtbs_install):
http://www.spinics.net/lists/linux-kbuild/msg10794.html
but looks like not yet merged.
Arnaud
Re: [PATCH 2/4] builddeb: install dtbs
Arnaud Patard (Rtp) <[email protected]> writes:
(replying to self)
Quoted 6 lines
[email protected] writes:
Hi,
Quoted 2 lines
From: Riku Voipio <[email protected]>
Quoted 7 lines
Quoted 3 lines
When kernel is built with
CONFIG_OF, install all built device tree files built. The installation location used is same as toplevelINSTALL_DTBS_PATH.Already sent a "better" patch for that (your patch is not handling system with
CONFIG_OFand withoutdtbs_install):
http://www.spinics.net/lists/linux-kbuild/msg10794.html
Oops. Wrong version. The right one is v4:
http://www.spinics.net/lists/linux-kbuild/msg10832.html
Arnaud
Re: [PATCH 2/4] builddeb: install dtbs
Quoted 7 lines · Arnaud Patard
Quoted 3 lines · Arnaud Patard (Rtp)
Already sent a "better" patch for that (your patch is not handling system with
CONFIG_OFand withoutdtbs_install):
http://www.spinics.net/lists/linux-kbuild/msg10794.htmlOops. Wrong version. The right one is v4:
http://www.spinics.net/lists/linux-kbuild/msg10832.html
Your version looks good. What needs to happen for it to get merged?
Riku
Re: [PATCH 2/4] builddeb: install dtbs
Quoted 10 lines · Riku Voipio
Quoted 7 lines · Arnaud Patard
Quoted 3 lines · Arnaud Patard (Rtp)
Already sent a "better" patch for that (your patch is not handling system with
CONFIG_OFand withoutdtbs_install):
http://www.spinics.net/lists/linux-kbuild/msg10794.htmlOops. Wrong version. The right one is v4:
http://www.spinics.net/lists/linux-kbuild/msg10832.htmlYour version looks good. What needs to happen for it to get merged?
No idea. I was hoping that someone would take it.
Arnaud
PATCH 3/4 builddeb: simplify directory creation
In reply to [email protected]From: Riku Voipio <[email protected]>
Every package needs /usr/share/doc/$package_name and DEBIAN directory, so create them as part of create_package function.
--- scripts/package/builddeb | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
scripts/package/builddeb +6 -15
@@ -15,6 +15,8 @@ set -e create_package() { local pname="$1" pdir="$2" + mkdir -m 755 -p "$pdir/DEBIAN" + mkdir -p "$pdir/usr/share/doc/$pname" cp debian/copyright "$pdir/usr/share/doc/$pname/" cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian" gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
@@ -118,25 +120,13 @@ BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" # Setup the directory structure rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" -mkdir -m 755 -p "$tmpdir/DEBIAN" -mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" -mkdir -m 755 -p "$fwdir/DEBIAN" -mkdir -p "$fwdir/lib/firmware/$version/" "$fwdir/usr/share/doc/$fwpackagename" -mkdir -m 755 -p "$libc_headers_dir/DEBIAN" -mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename" -mkdir -m 755 -p "$kernel_headers_dir/DEBIAN" -mkdir -p "$kernel_headers_dir/usr/share/doc/$kernel_headers_packagename" +mkdir -p "$tmpdir/lib" "$tmpdir/boot" +mkdir -p "$fwdir/lib/firmware/$version/" mkdir -p "$kernel_headers_dir/lib/modules/$version/" -if [ "$ARCH" = "um" ] ; then - mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" -fi -if [ -n "$BUILD_DEBUG" ] ; then - mkdir -p "$dbg_dir/usr/share/doc/$dbg_packagename" - mkdir -m 755 -p "$dbg_dir/DEBIAN" -fi # Build and install the kernel if [ "$ARCH" = "um" ] ; then + mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename" $MAKE linux cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config"
@@ -194,6 +184,7 @@ if grep -q '^CONFIG_BLK_DEV_INITRD=y' $KCONFIG_CONFIG; then else want_initrd=No fi +mkdir -m 755 -p "$tmpdir/DEBIAN" for script in postinst postrm preinst prerm ; do mkdir -p "$tmpdir$debhookdir/$script.d" cat <<EOF > "$tmpdir/DEBIAN/$script"
Signature · 1 line
2.1.4
PATCH 4/4 RFC: builddeb: add linux-tools package with perf
In reply to [email protected]From: Riku Voipio <[email protected]>
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.
--- scripts/package/builddeb | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
scripts/package/builddeb +30 -1
@@ -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)" # 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
Signature · 1 line
2.1.4