From patchwork Fri Jun 14 09:46:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anisse Astier X-Patchwork-Id: 2721011 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3036EC0AB2 for ; Fri, 14 Jun 2013 09:47:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1005F2023B for ; Fri, 14 Jun 2013 09:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B820E20240 for ; Fri, 14 Jun 2013 09:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751598Ab3FNJrQ (ORCPT ); Fri, 14 Jun 2013 05:47:16 -0400 Received: from mail-we0-f177.google.com ([74.125.82.177]:40775 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268Ab3FNJrP (ORCPT ); Fri, 14 Jun 2013 05:47:15 -0400 Received: by mail-we0-f177.google.com with SMTP id m19so287229wev.8 for ; Fri, 14 Jun 2013 02:47:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=j/uHyiKbx3MzH/W8VI7laGdyEWqJ3DO1VEGqCIeIfjI=; b=cjkF4hFj+8E1PpGT1WKYexerGnYa59QZyTE1joHtdxTlOKhf1REN9RqIUOySLBAQ/M EEXpTA96L+QQImT9qUk1T2ZWqYd7e2DPjgE26ZZwuQyrT8Jz5tZah+76RBU6Re4OjrMd dbp2gx9nN1UaWERcSI/vVB1mIC4RS+/mpBrthmUsLdM+GKWRzuKu4226QqGMVdRBfCP7 RNGbUsnfV7y30FWcb98sld5MHJwAnFP5vqXH4hLIyz55B9vKD+zw3gAJ8o7ag4R4TQdj 4R7ap9oCKf50VgfbCaT/sW/8/5Smw/UKnUZts3pCOcgeupLYCM69ZjUUrm1z5xdL48Cy JMow== X-Received: by 10.194.20.97 with SMTP id m1mr900137wje.31.1371203234222; Fri, 14 Jun 2013 02:47:14 -0700 (PDT) Received: from serenity.substantiel.local (mar92-17-78-228-214-160.fbx.proxad.net. [78.228.214.160]) by mx.google.com with ESMTPSA id b19sm1906568wik.10.2013.06.14.02.47.12 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Jun 2013 02:47:13 -0700 (PDT) From: Anisse Astier To: linux-kbuild@vger.kernel.org Cc: debian-kernel@lists.debian.org, kernel-team@lists.ubuntu.com, Ben Hutchings , Michal Marek , maximilian attems , Anisse Astier Subject: [PATCH v5 2/4] deb-pkg: split debug symbols in their own package Date: Fri, 14 Jun 2013 11:46:55 +0200 Message-Id: <1371203217-19572-3-git-send-email-anisse@astier.eu> X-Mailer: git-send-email 1.8.3.rc1 In-Reply-To: <1371203217-19572-1-git-send-email-anisse@astier.eu> References: <1371203217-19572-1-git-send-email-anisse@astier.eu> X-Gm-Message-State: ALoCoQk93/ygKij7tQyhZP0ZjtHWZzCYKdH8SBAt91ZsQS6H12AbXYb+GuL69V2uH+o38FoxJPWx Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This can reduce almost 3 times the size of the linux-image package, while keeping the debug symbols available for this particular build, in their own package. This mimics the way kernels are built in debian, ubuntu, or with make-kpkg, and comes at the price of a small slowdown in the building of packages. Signed-off-by: Anisse Astier Cc: Ben Hutchings Acked-by: maximilian attems --- scripts/package/builddeb | 50 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 6f21ad8..7c5703a 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -78,17 +78,21 @@ tmpdir="$objtree/debian/tmp" fwdir="$objtree/debian/fwtmp" kernel_headers_dir="$objtree/debian/hdrtmp" libc_headers_dir="$objtree/debian/headertmp" +dbg_dir="$objtree/debian/dbgtmp" packagename=linux-image-$version fwpackagename=linux-firmware-image kernel_headers_packagename=linux-headers-$version libc_headers_packagename=linux-libc-dev +dbg_packagename=$packagename-dbg if [ "$ARCH" = "um" ] ; then packagename=user-mode-linux-$version fi +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" +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" @@ -101,6 +105,10 @@ 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 @@ -128,6 +136,20 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" rmdir "$tmpdir/lib/modules/$version" fi + if [ -n "$BUILD_DEBUG" ] ; then + ( + cd $tmpdir + for module in $(find lib/modules/ -name *.ko); do + mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) + # only keep debug symbols in the debug file + objcopy --only-keep-debug $module $dbg_dir/usr/lib/debug/$module + # strip original module from debug symbols + objcopy --strip-debug $module + # then add a link to those + objcopy --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module + done + ) + fi fi if [ "$ARCH" != "um" ]; then @@ -299,4 +321,30 @@ fi create_package "$packagename" "$tmpdir" +if [ -n "$BUILD_DEBUG" ] ; then + # Build debug package + # Different tools want the image in different locations + # perf + mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/ + cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/ + # systemtap + mkdir -p $dbg_dir/usr/lib/debug/boot/ + ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version + # kdump-tools + ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version + + cat <> debian/control + +Package: $dbg_packagename +Section: debug +Provides: linux-debug, linux-debug-$version +Architecture: any +Description: Linux kernel debugging symbols for $version + This package will come in handy if you need to debug the kernel. It provides + all the necessary debug symbols for the kernel and its modules. +EOF + + create_package "$dbg_packagename" "$dbg_dir" +fi + exit 0