Mercurial > hg > mercurial-source
annotate contrib/builddeb @ 26695:05306b9359d3
builddeb: rework how output dir and platform are specified
This makes it possible to write tests for both builddeb and dockerdeb
that actually build .debs and then sanity check the contents.
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 25 Aug 2015 00:02:44 -0400 |
parents | e5f2a2a095cb |
children | 7f49efcaa9b4 |
rev | line source |
---|---|
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 #!/bin/sh -e |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 # |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 # Build a Mercurial debian package from the current repo |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 # |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 # Tested on Jessie (stable as of original script authoring.) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
25363
56c64c91b429
packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents:
25362
diff
changeset
|
7 . $(dirname $0)/packagelib.sh |
56c64c91b429
packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents:
25362
diff
changeset
|
8 |
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 BUILD=1 |
26695
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
10 DEBVERSION=jessie |
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 while [ "$1" ]; do |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 case "$1" in |
26695
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
13 --release ) |
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
14 shift |
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
15 DEBVERSION="$1" |
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
16 shift |
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
17 ;; |
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 --prepare ) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 shift |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 BUILD= |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 ;; |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 --debbuilddir ) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 shift |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 DEBBUILDDIR="$1" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 shift |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 ;; |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 * ) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 echo "Invalid parameter $1!" 1>&2 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 exit 1 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 ;; |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 esac |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 done |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
26695
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
34 DEBBUILDDIR=${OUTPUTDIR:="$PWD/debbuild"} |
05306b9359d3
builddeb: rework how output dir and platform are specified
Augie Fackler <augie@google.com>
parents:
26677
diff
changeset
|
35 |
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 set -u |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 rm -rf $DEBBUILDDIR |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 mkdir -p $DEBBUILDDIR |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 if [ ! -d .hg ]; then |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 echo 'You are not inside a Mercurial repository!' 1>&2 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 exit 1 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
44 fi |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 |
25363
56c64c91b429
packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents:
25362
diff
changeset
|
46 gethgversion |
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 chmod -R 0755 $DEBBUILDDIR/DEBIAN |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 control=$DEBBUILDDIR/DEBIAN/control |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 # This looks like sed -i, but sed -i behaves just differently enough |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 # between BSD and GNU sed that I gave up and did the dumb thing. |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 sed "s/__VERSION__/$version/" < $control > $control.tmp |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 mv $control.tmp $control |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 if [ "$BUILD" ]; then |
26677
e5f2a2a095cb
builddeb: actually run make when building the deb (issue4778)
Augie Fackler <augie@google.com>
parents:
25363
diff
changeset
|
59 make PREFIX=$DEBBUILDDIR/usr install |
25362
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 dpkg-deb --build $DEBBUILDDIR |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 mv $DEBBUILDDIR.deb $DEBBUILDDIR/mercurial-$version-$release.deb |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 if [ $? = 0 ]; then |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 echo |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 echo "Built packages for $version-$release:" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 find $DEBBUILDDIR/ -type f -newer $control |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
66 fi |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 else |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 echo "Prepared sources for $version-$release $control are in $DEBBUILDDIR - use like:" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 echo "dpkg-deb --build $DEBBUILDDIR" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 fi |