##// END OF EJS Templates
builddeb: create source archive for ubuntu
Sean Farley -
r28993:837119bf stable
parent child Browse files
Show More
@@ -1,92 +1,96 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 while [ "$1" ]; do
14 14 case "$1" in
15 15 --distid )
16 16 shift
17 17 DISTID="$1"
18 18 shift
19 19 ;;
20 20 --codename )
21 21 shift
22 22 CODENAME="$1"
23 23 shift
24 24 ;;
25 25 --cleanup )
26 26 shift
27 27 BUILD=
28 28 ;;
29 29 --build )
30 30 shift
31 31 CLEANUP=
32 32 ;;
33 33 * )
34 34 echo "Invalid parameter $1!" 1>&2
35 35 exit 1
36 36 ;;
37 37 esac
38 38 done
39 39
40 40 trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT
41 41
42 42 set -u
43 43
44 44 if [ ! -d .hg ]; then
45 45 echo 'You are not inside a Mercurial repository!' 1>&2
46 46 exit 1
47 47 fi
48 48
49 49 gethgversion
50 50 debver="$version"
51 51 if [ -n "$type" ] ; then
52 52 debver="$debver~$type"
53 53 fi
54 54 if [ -n "$distance" ] ; then
55 55 debver="$debver+$distance-$node"
56 56 fi
57 57
58 58 control=debian/control
59 59 changelog=debian/changelog
60 60
61 61 if [ "$BUILD" ]; then
62 62 if [ -d debian ] ; then
63 63 echo "Error! debian control directory already exists!"
64 64 exit 1
65 65 fi
66 66
67 67 cp -r $PWD/contrib/debian debian
68 68 chmod -R 0755 debian
69 69
70 70 sed -i.tmp "s/__VERSION__/$debver/" $changelog
71 71 sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
72 72 sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog
73 73 rm $changelog.tmp
74 74
75 # remove the node from the version string
76 SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz"
77 "$PWD/hg" archive $SRCFILE
78 mv $SRCFILE ..
75 79 debuild -us -uc -i -I -b
76 80 if [ $? != 0 ]; then
77 81 echo 'debuild failed!'
78 82 exit 1
79 83 fi
80 84
81 85 fi
82 86 if [ "$CLEANUP" ] ; then
83 87 echo
84 88 OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME}
85 89 mkdir -p "$OUTPUTDIR"
86 90 find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \
87 91 ../mercurial*.dsc ../mercurial*.gz \
88 92 -type f -newer $control -print0 2>/dev/null | \
89 93 xargs -Inarf -0 mv narf "$OUTPUTDIR"
90 94 echo "Built packages for $debver:"
91 95 find "$OUTPUTDIR" -type f -newer $control -name '*.deb'
92 96 fi
General Comments 0
You need to be logged in to leave comments. Login now