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