diff options
author | Anisse Astier <anisse@astier.eu> | 2013-07-03 10:02:04 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2013-07-24 09:50:23 -0400 |
commit | 810e843746b7297819b0a76b6c105b9bda01fd9c (patch) | |
tree | ded4b8f7000d34d32ab2672750d85718efac878d /scripts/package | |
parent | d20917670ee1fd4b090555e551faea04b014ca97 (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/builddeb | 50 |
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" | |||
78 | fwdir="$objtree/debian/fwtmp" | 78 | fwdir="$objtree/debian/fwtmp" |
79 | kernel_headers_dir="$objtree/debian/hdrtmp" | 79 | kernel_headers_dir="$objtree/debian/hdrtmp" |
80 | libc_headers_dir="$objtree/debian/headertmp" | 80 | libc_headers_dir="$objtree/debian/headertmp" |
81 | dbg_dir="$objtree/debian/dbgtmp" | ||
81 | packagename=linux-image-$version | 82 | packagename=linux-image-$version |
82 | fwpackagename=linux-firmware-image | 83 | fwpackagename=linux-firmware-image |
83 | kernel_headers_packagename=linux-headers-$version | 84 | kernel_headers_packagename=linux-headers-$version |
84 | libc_headers_packagename=linux-libc-dev | 85 | libc_headers_packagename=linux-libc-dev |
86 | dbg_packagename=$packagename-dbg | ||
85 | 87 | ||
86 | if [ "$ARCH" = "um" ] ; then | 88 | if [ "$ARCH" = "um" ] ; then |
87 | packagename=user-mode-linux-$version | 89 | packagename=user-mode-linux-$version |
88 | fi | 90 | fi |
89 | 91 | ||
92 | BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" | ||
93 | |||
90 | # Setup the directory structure | 94 | # Setup the directory structure |
91 | rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" | 95 | rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" |
92 | mkdir -m 755 -p "$tmpdir/DEBIAN" | 96 | mkdir -m 755 -p "$tmpdir/DEBIAN" |
93 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" | 97 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" |
94 | mkdir -m 755 -p "$fwdir/DEBIAN" | 98 | mkdir -m 755 -p "$fwdir/DEBIAN" |
@@ -101,6 +105,10 @@ mkdir -p "$kernel_headers_dir/lib/modules/$version/" | |||
101 | if [ "$ARCH" = "um" ] ; then | 105 | if [ "$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" |
103 | fi | 107 | fi |
108 | if [ -n "$BUILD_DEBUG" ] ; then | ||
109 | mkdir -p "$dbg_dir/usr/share/doc/$dbg_packagename" | ||
110 | mkdir -m 755 -p "$dbg_dir/DEBIAN" | ||
111 | fi | ||
104 | 112 | ||
105 | # Build and install the kernel | 113 | # Build and install the kernel |
106 | if [ "$ARCH" = "um" ] ; then | 114 | if [ "$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 | ||
131 | fi | 153 | fi |
132 | 154 | ||
133 | if [ "$ARCH" != "um" ]; then | 155 | if [ "$ARCH" != "um" ]; then |
@@ -300,4 +322,30 @@ fi | |||
300 | 322 | ||
301 | create_package "$packagename" "$tmpdir" | 323 | create_package "$packagename" "$tmpdir" |
302 | 324 | ||
325 | if [ -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 | |||
339 | Package: $dbg_packagename | ||
340 | Section: debug | ||
341 | Provides: linux-debug, linux-debug-$version | ||
342 | Architecture: any | ||
343 | Description: 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. | ||
346 | EOF | ||
347 | |||
348 | create_package "$dbg_packagename" "$dbg_dir" | ||
349 | fi | ||
350 | |||
303 | exit 0 | 351 | exit 0 |