925d24997de17185148e5792ffc3102fde0af3a4
[git-tools-moved-to-github.git] / id-deb-build / mkdist.sh
1 die () {
2   echo >&2 "$@"
3   exit 1
4 }
5
6 if test -f IDMETA; then
7   . ./IDMETA
8 else
9   echo "Warning: no IDMETA file.  Limping along anyway" >&2
10 fi
11
12 #we will keep this to get the project name
13 DEBCHANGELOG=debian/changelog
14 l=`head -1 $DEBCHANGELOG`
15
16 if [ "x$NAME" != x ]; then
17   echo "Got name $NAME from IDMETA file"
18 else
19   NAME=`echo $l|sed 's/ .*//g'`
20   echo "Warning: assuming name $NAME from debian/changelog"
21 fi
22
23 if [ "x$2" != x ]; then
24   echo "Overriding name $NAME with $2"
25   NAME=$2
26 fi
27
28 if [ "x$VERSION" != x ]; then
29   echo "Got version $VERSION from IDMETA file"
30 else
31   FULLVERSION=`echo $l|sed 's/.*(//g'|sed 's/).*//g'`
32   VERSION=`echo $FULLVERSION|sed 's/-.*//g'`
33   echo "Warning: assuming version $VERSION from debian/changelog"
34 fi
35
36 if [ "x$1" != x ]; then
37   echo "Overriding version $VERSION with $1"
38   VERSION=$1
39 fi
40
41 git archive --format=tar --prefix=$NAME-$VERSION/ v${VERSION} > tmp.tar || die "This version is not tagged in Git";
42 tar xf tmp.tar
43 rm tmp.tar
44 for file in debian $OMIT_FROM_DIST; do
45   echo "Omitting $file from distribution"
46   rm -r $NAME-$VERSION/$file
47 done
48 tar cfz $NAME-$VERSION.tar.gz $NAME-$VERSION
49 rm -r $NAME-$VERSION