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