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