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