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