author | Pierre-Yves David <pierre-yves.david@fb.com> |
Wed, 13 May 2015 11:49:38 -0700 | |
changeset 25030 | 33298a8b472f |
parent 24972 | 56c64c91b429 |
child 26090 | e5f2a2a095cb |
permissions | -rwxr-xr-x |
24971
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 |
|
24972
56c64c91b429
packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents:
24971
diff
changeset
|
7 |
. $(dirname $0)/packagelib.sh |
56c64c91b429
packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents:
24971
diff
changeset
|
8 |
|
24971
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
BUILD=1 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
DEBBUILDDIR="$PWD/debbuild" |
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 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
--prepare ) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
shift |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 |
BUILD= |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 |
;; |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 |
--debbuilddir ) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
shift |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
DEBBUILDDIR="$1" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
shift |
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 |
* ) |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
echo "Invalid parameter $1!" 1>&2 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 |
exit 1 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 |
;; |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
esac |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 |
done |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 |
|
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 |
set -u |
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 |
rm -rf $DEBBUILDDIR |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
mkdir -p $DEBBUILDDIR |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
|
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
if [ ! -d .hg ]; then |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 |
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
|
36 |
exit 1 |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
fi |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 |
|
24972
56c64c91b429
packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents:
24971
diff
changeset
|
39 |
gethgversion |
24971
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 |
cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 |
chmod -R 0755 $DEBBUILDDIR/DEBIAN |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 |
|
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
44 |
control=$DEBBUILDDIR/DEBIAN/control |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 |
|
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 |
# 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
|
47 |
# 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
|
48 |
sed "s/__VERSION__/$version/" < $control > $control.tmp |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
mv $control.tmp $control |
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 |
if [ "$BUILD" ]; then |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
dpkg-deb --build $DEBBUILDDIR |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 |
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
|
54 |
if [ $? = 0 ]; then |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 |
echo |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 |
echo "Built packages for $version-$release:" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 |
find $DEBBUILDDIR/ -type f -newer $control |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 |
fi |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 |
else |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 |
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
|
61 |
echo "dpkg-deb --build $DEBBUILDDIR" |
ab75baaf81d5
builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 |
fi |