aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/package
diff options
context:
space:
mode:
authorAnisse Astier <anisse@astier.eu>2013-07-03 10:02:04 -0400
committerMichal Marek <mmarek@suse.cz>2013-07-24 09:50:23 -0400
commit810e843746b7297819b0a76b6c105b9bda01fd9c (patch)
treeded4b8f7000d34d32ab2672750d85718efac878d /scripts/package
parentd20917670ee1fd4b090555e551faea04b014ca97 (diff)
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. Signed-off-by: Anisse Astier <anisse@astier.eu> Cc: Ben Hutchings <ben@decadent.org.uk> Acked-by: maximilian attems <max@stro.at> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/package')
-rw-r--r--scripts/package/builddeb50
1 files changed, 49 insertions, 1 deletions
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index a8662ef3ccee..541a1cfa9a6b 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -78,17 +78,21 @@ tmpdir="$objtree/debian/tmp"
78fwdir="$objtree/debian/fwtmp" 78fwdir="$objtree/debian/fwtmp"
79kernel_headers_dir="$objtree/debian/hdrtmp" 79kernel_headers_dir="$objtree/debian/hdrtmp"
80libc_headers_dir="$objtree/debian/headertmp" 80libc_headers_dir="$objtree/debian/headertmp"
81dbg_dir="$objtree/debian/dbgtmp"
81packagename=linux-image-$version 82packagename=linux-image-$version
82fwpackagename=linux-firmware-image 83fwpackagename=linux-firmware-image
83kernel_headers_packagename=linux-headers-$version 84kernel_headers_packagename=linux-headers-$version
84libc_headers_packagename=linux-libc-dev 85libc_headers_packagename=linux-libc-dev
86dbg_packagename=$packagename-dbg
85 87
86if [ "$ARCH" = "um" ] ; then 88if [ "$ARCH" = "um" ] ; then
87 packagename=user-mode-linux-$version 89 packagename=user-mode-linux-$version
88fi 90fi
89 91
92BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)"
93
90# Setup the directory structure 94# Setup the directory structure
91rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" 95rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir"
92mkdir -m 755 -p "$tmpdir/DEBIAN" 96mkdir -m 755 -p "$tmpdir/DEBIAN"
93mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" 97mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
94mkdir -m 755 -p "$fwdir/DEBIAN" 98mkdir -m 755 -p "$fwdir/DEBIAN"
@@ -101,6 +105,10 @@ mkdir -p "$kernel_headers_dir/lib/modules/$version/"
101if [ "$ARCH" = "um" ] ; then 105if [ "$ARCH" = "um" ] ; then
102 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" 106 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin"
103fi 107fi
108if [ -n "$BUILD_DEBUG" ] ; then
109 mkdir -p "$dbg_dir/usr/share/doc/$dbg_packagename"
110 mkdir -m 755 -p "$dbg_dir/DEBIAN"
111fi
104 112
105# Build and install the kernel 113# Build and install the kernel
106if [ "$ARCH" = "um" ] ; then 114if [ "$ARCH" = "um" ] ; then
@@ -128,6 +136,20 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
128 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" 136 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
129 rmdir "$tmpdir/lib/modules/$version" 137 rmdir "$tmpdir/lib/modules/$version"
130 fi 138 fi
139 if [ -n "$BUILD_DEBUG" ] ; then
140 (
141 cd $tmpdir
142 for module in $(find lib/modules/ -name *.ko); do
143 mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module)
144 # only keep debug symbols in the debug file
145 objcopy --only-keep-debug $module $dbg_dir/usr/lib/debug/$module
146 # strip original module from debug symbols
147 objcopy --strip-debug $module
148 # then add a link to those
149 objcopy --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module
150 done
151 )
152 fi
131fi 153fi
132 154
133if [ "$ARCH" != "um" ]; then 155if [ "$ARCH" != "um" ]; then
@@ -300,4 +322,30 @@ fi
300 322
301create_package "$packagename" "$tmpdir" 323create_package "$packagename" "$tmpdir"
302 324
325if [ -n "$BUILD_DEBUG" ] ; then
326 # Build debug package
327 # Different tools want the image in different locations
328 # perf
329 mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/
330 cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/
331 # systemtap
332 mkdir -p $dbg_dir/usr/lib/debug/boot/
333 ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version
334 # kdump-tools
335 ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version
336
337 cat <<EOF >> debian/control
338
339Package: $dbg_packagename
340Section: debug
341Provides: linux-debug, linux-debug-$version
342Architecture: any
343Description: Linux kernel debugging symbols for $version
344 This package will come in handy if you need to debug the kernel. It provides
345 all the necessary debug symbols for the kernel and its modules.
346EOF
347
348 create_package "$dbg_packagename" "$dbg_dir"
349fi
350
303exit 0 351exit 0