-
Notifications
You must be signed in to change notification settings - Fork 2
/
debbuild-sh
executable file
·86 lines (67 loc) · 1.43 KB
/
debbuild-sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
CMD='dpkg-buildpackage -rfakeroot -b'
PROG="libkrisp"
usage() {
echo "Usage: $0"
exit 1
}
do_patch() {
echo "* Apply debian patches"
plist=$(ls debian/patches/*.patch 2> /dev/null)
for i in $plist
do
patch -p1 < $i || true
done;
}
do_unpatch() {
echo "* Apply debian unpatches"
plist=$(ls debian/patches/*.patch 2> /dev/null)
for i in $plist
do
patch -suRf -p1 < $i || true
done
}
graceful_stop() {
echo "**** graceful stop ****"
pwd | grep 'debian$'
[ $? -eq 0 ] && cd ..
[ -f "debian/changelog.debbuild" ] && \
echo " * Rollback debian/changelog" && \
mv -f debian/changelog.debbuild debian/changelog
[ -f "Makefile" ] && \
echo " * Source cleaning" && \
debian/rules clean
[ -n "$PROG" -a -d "debian/$PROG" ] && rm -rf debian/$PROG
exit 1
}
trap 'graceful_stop' INT
echo "* $PROG debian package build script"
echo
[ "$1" = "-h" -o "$1" = "--help" ] && usage
if [ -f "/etc/lsb-release" ]; then
source /etc/lsb-release
distname="${DISTRIB_CODENAME}"
else
distname="stable"
fi
if [ $# -eq 0 ]; then
echo -n " Distribution Name [default: ${distname}]: "
read _distname
[ -n "$_distname" ] && distname="${_distname}"
else
distname=$1
fi
cd debian
cp -af changelog changelog.debbuild
perl -pi -e "s/\) (un)*stable; /\) ${distname}; /g" changelog
cd -
do_patch
$CMD
[ $? -ne 0 ] && graceful_stop
do_unpatch
cd debian
mv -f changelog.debbuild changelog
cd -
debian/rules clean
#make distclean
exit 0