Show More
@@ -1,101 +1,100 b'' | |||
|
1 | 1 | #!/bin/sh -e |
|
2 | 2 | # |
|
3 | 3 | # Build a Mercurial debian package from the current repo |
|
4 | 4 | # |
|
5 | 5 | # Tested on Jessie (stable as of original script authoring.) |
|
6 | 6 | |
|
7 | 7 | . $(dirname $0)/packagelib.sh |
|
8 | 8 | |
|
9 | 9 | BUILD=1 |
|
10 | 10 | CLEANUP=1 |
|
11 | 11 | DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian` |
|
12 | 12 | CODENAME=`lsb_release -cs 2> /dev/null || echo unknown` |
|
13 | 13 | DEBFLAGS=-b |
|
14 | 14 | while [ "$1" ]; do |
|
15 | 15 | case "$1" in |
|
16 | 16 | --distid ) |
|
17 | 17 | shift |
|
18 | 18 | DISTID="$1" |
|
19 | 19 | shift |
|
20 | 20 | ;; |
|
21 | 21 | --codename ) |
|
22 | 22 | shift |
|
23 | 23 | CODENAME="$1" |
|
24 | 24 | shift |
|
25 | 25 | ;; |
|
26 | 26 | --cleanup ) |
|
27 | 27 | shift |
|
28 | 28 | BUILD= |
|
29 | 29 | ;; |
|
30 | 30 | --build ) |
|
31 | 31 | shift |
|
32 | 32 | CLEANUP= |
|
33 | 33 | ;; |
|
34 | 34 | --source-only ) |
|
35 | 35 | shift |
|
36 | 36 | DEBFLAGS=-S |
|
37 | 37 | ;; |
|
38 | 38 | * ) |
|
39 | 39 | echo "Invalid parameter $1!" 1>&2 |
|
40 | 40 | exit 1 |
|
41 | 41 | ;; |
|
42 | 42 | esac |
|
43 | 43 | done |
|
44 | 44 | |
|
45 | 45 | trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT |
|
46 | 46 | |
|
47 | 47 | set -u |
|
48 | 48 | |
|
49 | 49 | if [ ! -d .hg ]; then |
|
50 | 50 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
51 | 51 | exit 1 |
|
52 | 52 | fi |
|
53 | 53 | |
|
54 | 54 | gethgversion |
|
55 | 55 | debver="$version" |
|
56 | 56 | if [ -n "$type" ] ; then |
|
57 | 57 | debver="$debver~$type" |
|
58 | 58 | fi |
|
59 | 59 | if [ -n "$distance" ] ; then |
|
60 | 60 | debver="$debver+$distance-$CODENAME-$node" |
|
61 | 61 | fi |
|
62 | 62 | |
|
63 | 63 | control=debian/control |
|
64 | 64 | changelog=debian/changelog |
|
65 | 65 | |
|
66 | 66 | if [ "$BUILD" ]; then |
|
67 | 67 | if [ -d debian ] ; then |
|
68 | 68 | echo "Error! debian control directory already exists!" |
|
69 | 69 | exit 1 |
|
70 | 70 | fi |
|
71 | 71 | |
|
72 | 72 | cp -r $PWD/contrib/debian debian |
|
73 | chmod -R 0755 debian | |
|
74 | 73 | |
|
75 | 74 | sed -i.tmp "s/__VERSION__/$debver/" $changelog |
|
76 | 75 | sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog |
|
77 | 76 | sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog |
|
78 | 77 | rm $changelog.tmp |
|
79 | 78 | |
|
80 | 79 | # remove the node from the version string |
|
81 | 80 | SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz" |
|
82 | 81 | "$PWD/hg" archive $SRCFILE |
|
83 | 82 | mv $SRCFILE .. |
|
84 | 83 | debuild -us -uc -i -I $DEBFLAGS |
|
85 | 84 | if [ $? != 0 ]; then |
|
86 | 85 | echo 'debuild failed!' |
|
87 | 86 | exit 1 |
|
88 | 87 | fi |
|
89 | 88 | |
|
90 | 89 | fi |
|
91 | 90 | if [ "$CLEANUP" ] ; then |
|
92 | 91 | echo |
|
93 | 92 | OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME} |
|
94 | 93 | mkdir -p "$OUTPUTDIR" |
|
95 | 94 | find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \ |
|
96 | 95 | ../mercurial*.dsc ../mercurial*.gz \ |
|
97 | 96 | -type f -newer $control -print0 2>/dev/null | \ |
|
98 | 97 | xargs -Inarf -0 mv narf "$OUTPUTDIR" |
|
99 | 98 | echo "Built packages for $debver:" |
|
100 | 99 | find "$OUTPUTDIR" -type f -newer $control -name '*.deb' |
|
101 | 100 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now