Mercurial > hg
annotate contrib/builddeb @ 25732:b94df10cc3b5
hghave: allow adding customized features at runtime
Before this patch, there is no way to add customized features to
`hghave` without changing `hghave` and `hghave.py` themselves.
This decreases reusability of `run-tests.py` framework for third party
tools, because they may want to examine custom features at runtime
(e.g. existence of some external tools).
To allow adding customized features at runtime, this patch makes
`hghave` import `hghaveaddon` module, only when `hghaveaddon.py` file
can be found in directories below:
- `TESTDIR` for invocation via `run-tests.py`
- `.` for invocation via command line
The path to the directory where `hghaveaddon.py` should be placed is
added to `sys.path` only while importing `hghaveaddon`, because:
- `.` may not be added to `PYTHONPATH`
- adding additional path to `sys.path` may change behavior of
subsequent `import` for other features
`hghave` is terminated with exit code '2' at failure of `import
hghaveaddon`, because exit code '2' terminates `run-tests.py`
immediately.
This is a one of preparations for issue4677.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 03 Jul 2015 06:56:03 +0900 |
parents | 56c64c91b429 |
children | e5f2a2a095cb |
rev | line source |
---|---|
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 |