52ef1e9a318e4f1aaaabeaca635f5aa05bbbea0f
[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 DEBCHANGELOG=debian/changelog
19
20 if [ "x$NAME" != x ]; then
21   echo "Got name $NAME from IDMETA file"
22 elif test -f $DEBCHANGELOG; then
23   NAME=`head -1 $DEBCHANGELOG|sed 's/ .*//g'`
24   echo "Warning: assuming name $NAME from $DEBCHANGELOG"
25 else
26   die "No $DEBCHANGELOG and no NAME in IDMETA"
27 fi
28
29 if [ "x$2" != x ]; then
30   echo "Overriding name $NAME with $2"
31   NAME=$2
32 fi
33
34 if [ "x$VERSION" != x ]; then
35   echo "Got version $VERSION from IDMETA file"
36 else
37   FULLVERSION=`head -1 $DEBCHANGELOG|sed 's/.*(//g'|sed 's/).*//g'`
38   VERSION=`echo $FULLVERSION|sed 's/-.*//g'`
39   echo "Warning: assuming version $VERSION from $DEBCHANGELOG"
40 fi
41
42 if [ "x$1" != x ]; then
43   echo "Overriding version $VERSION with $1"
44   VERSION=$1
45 fi
46
47 trap 'rm -f tmp.tar' 0
48
49 if [ -n "$localFiles" ]; then
50     echo "WARNING: using local files rather than git tag" >&2
51     echo "This is fine for testing, but should not be used for releases " >&2
52     pwd=`pwd`
53     dir=`basename "$pwd"`
54     cd ..
55     cp -a "$dir" $NAME-$VERSION
56     rm -rf $NAME-$VERSION/.git
57     tar cf "$pwd"/tmp.tar $NAME-$VERSION
58     rm -rf $NAME-$VERSION
59     cd "$dir"
60 else
61     echo "from git"
62     git archive --format=tar --prefix=$NAME-$VERSION/ v${VERSION} > tmp.tar || die "This version is not tagged in Git";
63 fi
64
65 tar xf tmp.tar
66 rm tmp.tar
67 for file in debian $OMIT_FROM_DIST; do
68   if [ -e "$file" ]; then
69     echo "Omitting $file from distribution"
70     rm -rf $NAME-$VERSION/$file
71   fi
72 done
73 tar cfz $NAME-$VERSION.tar.gz $NAME-$VERSION
74 rm -rf $NAME-$VERSION