Fix test for directory
[git-tools-moved-to-github.git] / id-deb-build / mkdist.sh
1 die () {
2   echo >&2 "$@"
3   exit 1
4 }
5
6 if [ "x$1" = x-l ]; then
7   localFiles=t
8   shift
9 fi
10
11 if test -f IDMETA; then
12   . ./IDMETA
13 else
14   echo "Warning: no IDMETA file.  Limping along anyway" >&2
15 fi
16
17 #we will keep this to get the project name
18
19 if [ "x$NAME" != x ]; then
20   echo "Got name $NAME from IDMETA file"
21 elif test -f debian/control; then
22   NAME=`awk '/Source:/ {print $2}' debian/control`
23   echo "Warning: assuming name $NAME from debian/control"
24 else
25   die "No debian/control and no NAME in IDMETA"
26 fi
27
28 if [ "x$2" != x ]; then
29   echo "Overriding name $NAME with $2"
30   NAME=$2
31 fi
32
33 if [ "x$VERSION" != x ]; then
34   echo "Got version $VERSION from IDMETA file"
35 else
36   echo "No VERSION in IDMETA"
37   exit 1
38 fi
39
40 if [ "x$1" != x ]; then
41   echo "Overriding version $VERSION with $1"
42   VERSION=$1
43 fi
44
45 trap 'rm -f tmp.tar' 0
46
47 if [ -n "$localFiles" ]; then
48     echo "WARNING: using local files rather than git tag" >&2
49     echo "This is fine for testing, but should not be used for releases " >&2
50     pwd=`pwd`
51     dir=`basename "$pwd"`
52     cd ..
53     cp -a "$dir" $NAME-$VERSION
54     rm -rf $NAME-$VERSION/.git
55     tar cf "$pwd"/tmp.tar $NAME-$VERSION
56     rm -rf $NAME-$VERSION
57     cd "$dir"
58 else
59     echo "from git"
60     git archive --format=tar --prefix=$NAME-$VERSION/ v${VERSION} > tmp.tar || die "This version is not tagged in Git";
61 fi
62
63 tar xf tmp.tar
64 rm tmp.tar
65 for file in debian $OMIT_FROM_DIST; do
66   if [ -e "$file" ]; then
67     echo "Omitting $file from distribution"
68     rm -rf $NAME-$VERSION/$file
69   fi
70 done
71 tar cfz $NAME-$VERSION.tar.gz $NAME-$VERSION
72 rm -rf $NAME-$VERSION