~elementary-os/elementaryos/packaging-scripts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

# adds a package with debugging symbols to simple debian packages (i.e. without
# custom "install" file).
# requires Debhelper v7.0.50 or later
# written by Sergey "Shnatsel" Davidoff

if [ $(basename $(pwd) ) = debian ] && [ -e control ]; then
    : # we're in debian folder, all fine
elif [ -e debian/control ]; then
    cd debian
else
    echo 'cannot find readable debian/control anywhere!
Are you in the source code tree?' > /dev/stderr
    exit 1
fi

if [ -e 'install' ]; then
    echo "This package has a custom debian/install file.
You will have to add the debugging symbols package manually.
Documentation on doing so is available at:
http://wiki.debian.org/DebugPackage" > /dev/stderr
    exit 1
fi

pkgname=$(grep --max-count=1 'Package:' control | cut -d ' ' -f 2)

description=$(grep -m 1 '^Description:' control)
long_description=$( ( grep -m 1 '^Description:' > /dev/null; cat) <control )
pre_depends=$( grep -m 1 '^Pre-Depends:' control )

# add the -dbg package to control
echo '
Package: '"$pkgname"'-dbg' >> control
echo 'Architecture: any
Section: debug
Priority: extra' >> control
echo 'Depends: '"$pkgname"' (= ${binary:Version}), ${misc:Depends}' >> control
[ "$pre_depends" != "" ] && echo "$pre_depends" >> control
echo 'Enhances: '"$pkgname" >> control
echo "$description"' (debugging symbols)' >> control
echo "$long_description" >> control
echo " .
 This package contains debugging symbols for $pkgname." >> control

# add required entries to rules
echo '
override_dh_strip:
	dh_strip --dbg-package='"$pkgname"'-dbg' >> rules

echo '
override_dh_auto_install:
	dh_auto_install --destdir=debian/'"$pkgname" >> rules