From patchwork Tue Apr 9 10:05:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anisse Astier X-Patchwork-Id: 2414281 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9999E3FC71 for ; Tue, 9 Apr 2013 10:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937397Ab3DIKGO (ORCPT ); Tue, 9 Apr 2013 06:06:14 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:45104 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936498Ab3DIKGN (ORCPT ); Tue, 9 Apr 2013 06:06:13 -0400 Received: by mail-wg0-f53.google.com with SMTP id c11so6608053wgh.8 for ; Tue, 09 Apr 2013 03:06:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=xU/RyjJLpxMzhV7mDL7pIVhG5nGrbwCkSpsyn78Cebc=; b=keFHYBVUhRPZcFMpW6pI8wkxRJEhyI1+oW7vLSSnfbQcl8+CaIQUXjIa+eZ1gj5aLa EfEmiExPUTmpBZGvcK1FPywdLhMgaB618X7byVZzcP3w/Q45xtPdhYbHhOtHonIoLR8f nlHHXE6aJBjph9ai09UpqYwOCr/Atod/e8RFp9het2ffRKaDoTN5Ph0C1ovDdkAgeZur X277emXn1kORE/C37H8p/Wqlfyr0EDf5dBd9RDuEa3gwJyZ68kQriP7LF8Wuyq8lLBwl FnXYrCuxSiVGSpX17/Qbpzgu3cyp4rzKK3SkRzz+QO1jGTjycTuWodaIangOYeA+Vncf m3qg== X-Received: by 10.180.73.229 with SMTP id o5mr6051606wiv.8.1365501971588; Tue, 09 Apr 2013 03:06:11 -0700 (PDT) Received: from serenity (mar92-17-78-228-214-160.fbx.proxad.net. [78.228.214.160]) by mx.google.com with ESMTPS id s2sm27742835wib.4.2013.04.09.03.06.10 (version=SSLv3 cipher=RC4-SHA bits=128/128); Tue, 09 Apr 2013 03:06:11 -0700 (PDT) Date: Tue, 9 Apr 2013 12:05:47 +0200 From: Anisse Astier To: Michal Marek Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, maximilian attems Subject: Re: [PATCH 1/2] deb-pkg: split debug symbols in their own package Message-ID: <20130409120547.64ad0d50@serenity> In-Reply-To: <20130408190645.29570fe5@serenity> References: <1363946761-7449-1-git-send-email-anisse@astier.eu> <51629BFF.1080204@suse.cz> <20130408190645.29570fe5@serenity> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Gm-Message-State: ALoCoQnPZkk0oYp/5kBgKCNJfKWdvbm0KL8av8QyuQB3FT4SaRErWTUIWzARHSHY9odIp7JvluCr Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Anisse Astier Subject: [PATCH v3] deb-pkg: split debug symbols in their own package 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. v2: - only build when CONFIG_DEBUG_INFO=y - build debug package last. - more verbose package description - put package in section debug v3: - remove duplicate code from v2 Signed-off-by: Anisse Astier --- Sorry for the mixup, there were duplicate mkdir declaration due to moving code around. --- scripts/package/builddeb | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index acb8650..65ff0a4 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' .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' .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,23 @@ fi create_package "$packagename" "$tmpdir" +if [ -n "$BUILD_DEBUG" ] ; then + # Build debug package + mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/ + cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$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