##// END OF EJS Templates
packaging: fix path where .deb files are looked for...
Denis Laxalde -
r43617:734407c4 stable
parent child Browse files
Show More
@@ -1,115 +1,115 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 "$ROOTDIR/debian";
19 rm -r "$ROOTDIR/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 cd "$ROOTDIR"
54 cd "$ROOTDIR"
55
55
56 trap 'cleanup' EXIT
56 trap 'cleanup' EXIT
57
57
58 set -u
58 set -u
59
59
60 if [ ! -d .hg ]; then
60 if [ ! -d .hg ]; then
61 printf "You are inside %s, which is not the root of a Mercurial repository\n" $(pwd) 1>&2
61 printf "You are inside %s, which is not the root of a Mercurial repository\n" $(pwd) 1>&2
62 exit 1
62 exit 1
63 fi
63 fi
64
64
65 gethgversion
65 gethgversion
66 debver="$version"
66 debver="$version"
67 if [ -n "$type" ] ; then
67 if [ -n "$type" ] ; then
68 debver="$debver~$type"
68 debver="$debver~$type"
69 fi
69 fi
70 if [ -n "$distance" ] ; then
70 if [ -n "$distance" ] ; then
71 debver="$debver+$distance-$CODENAME-$node"
71 debver="$debver+$distance-$CODENAME-$node"
72 elif [ "$DEBFLAGS" = "-S" ] ; then
72 elif [ "$DEBFLAGS" = "-S" ] ; then
73 # for building a ppa (--source-only) for a release (distance == 0), we need
73 # for building a ppa (--source-only) for a release (distance == 0), we need
74 # to version the distroseries so that we can upload to launchpad
74 # to version the distroseries so that we can upload to launchpad
75 debver="$debver~${CODENAME}1"
75 debver="$debver~${CODENAME}1"
76 fi
76 fi
77
77
78 control=debian/control
78 control=debian/control
79 changelog=debian/changelog
79 changelog=debian/changelog
80
80
81 if [ "$BUILD" ]; then
81 if [ "$BUILD" ]; then
82 if [ -d debian ] ; then
82 if [ -d debian ] ; then
83 printf "Error! debian control directory already exists at %s/debian\n" $(pwd)
83 printf "Error! debian control directory already exists at %s/debian\n" $(pwd)
84 exit 1
84 exit 1
85 fi
85 fi
86
86
87 cp -r "$ROOTDIR"/contrib/packaging/debian debian
87 cp -r "$ROOTDIR"/contrib/packaging/debian debian
88
88
89 sed -i.tmp "s/__VERSION__/$debver/" $changelog
89 sed -i.tmp "s/__VERSION__/$debver/" $changelog
90 sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
90 sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
91 sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog
91 sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog
92 rm $changelog.tmp
92 rm $changelog.tmp
93
93
94 # remove the node from the version string
94 # remove the node from the version string
95 SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz"
95 SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz"
96 "$ROOTDIR/hg" archive $SRCFILE
96 "$ROOTDIR/hg" archive $SRCFILE
97 mv $SRCFILE ..
97 mv $SRCFILE ..
98 debuild -us -uc -i -I $DEBFLAGS
98 debuild -us -uc -i -I $DEBFLAGS
99 if [ $? != 0 ]; then
99 if [ $? != 0 ]; then
100 echo 'debuild failed!'
100 echo 'debuild failed!'
101 exit 1
101 exit 1
102 fi
102 fi
103
103
104 fi
104 fi
105 if [ "$CLEANUP" ] ; then
105 if [ "$CLEANUP" ] ; then
106 echo
106 echo
107 OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME}
107 OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME}
108 mkdir -p "$OUTPUTDIR"
108 mkdir -p "$OUTPUTDIR"
109 find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \
109 find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \
110 ../mercurial*.dsc ../mercurial*.gz \
110 ../mercurial*.dsc ../mercurial*.gz \
111 -type f -newer $control -print0 2>/dev/null | \
111 -type f -newer $control -print0 2>/dev/null | \
112 xargs -Inarf -0 mv narf "$OUTPUTDIR"
112 xargs -Inarf -0 mv narf "$OUTPUTDIR"
113 echo "Built packages for $debver:"
113 echo "Built packages for $debver:"
114 find "$PWD"/"$OUTPUTDIR" -type f -newer $control -name '*.deb'
114 find "$OUTPUTDIR" -type f -newer $control -name '*.deb'
115 fi
115 fi
General Comments 0
You need to be logged in to leave comments. Login now