Merge branch 'master' of ssh://hummus/home/git/pub/git-tools
[git-tools-moved-to-github.git] / id-deb-build / mkdist.sh
index 4fbee88..1506220 100755 (executable)
@@ -3,6 +3,11 @@ die () {
   exit 1
 }
 
+if [ "x$1" = x-l ]; then
+  localFiles=t
+  shift
+fi
+
 if test -f IDMETA; then
   . ./IDMETA
 else
@@ -10,13 +15,14 @@ else
 fi
 
 #we will keep this to get the project name
-DEBCHANGELOG=debian/changelog
 
 if [ "x$NAME" != x ]; then
   echo "Got name $NAME from IDMETA file"
+elif test -f debian/control; then
+  NAME=`awk '/Source:/ {print $2}' debian/control`
+  echo "Warning: assuming name $NAME from debian/control"
 else
-  NAME=`head -1 $DEBCHANGELOG|sed 's/ .*//g'`
-  echo "Warning: assuming name $NAME from $DEBCHANGELOG"
+  die "No debian/control and no NAME in IDMETA"
 fi
 
 if [ "x$2" != x ]; then
@@ -27,9 +33,8 @@ fi
 if [ "x$VERSION" != x ]; then
   echo "Got version $VERSION from IDMETA file"
 else
-  FULLVERSION=`head -1 $DEBCHANGELOG|sed 's/.*(//g'|sed 's/).*//g'`
-  VERSION=`echo $FULLVERSION|sed 's/-.*//g'`
-  echo "Warning: assuming version $VERSION from $DEBCHANGELOG"
+  echo "No VERSION in IDMETA"
+  exit 1
 fi
 
 if [ "x$1" != x ]; then
@@ -38,12 +43,30 @@ if [ "x$1" != x ]; then
 fi
 
 trap 'rm -f tmp.tar' 0
-git archive --format=tar --prefix=$NAME-$VERSION/ v${VERSION} > tmp.tar || die "This version is not tagged in Git";
+
+if [ -n "$localFiles" ]; then
+    echo "WARNING: using local files rather than git tag" >&2
+    echo "This is fine for testing, but should not be used for releases " >&2
+    pwd=`pwd`
+    dir=`basename "$pwd"`
+    cd ..
+    cp -a "$dir" $NAME-$VERSION
+    rm -rf $NAME-$VERSION/.git
+    tar cf "$pwd"/tmp.tar $NAME-$VERSION
+    rm -rf $NAME-$VERSION
+    cd "$dir"
+else
+    echo "from git"
+    git archive --format=tar --prefix=$NAME-$VERSION/ v${VERSION} > tmp.tar || die "This version is not tagged in Git";
+fi
+
 tar xf tmp.tar
 rm tmp.tar
 for file in debian $OMIT_FROM_DIST; do
-  echo "Omitting $file from distribution"
-  rm -r $NAME-$VERSION/$file
+  if [ -e "$file" ]; then
+    echo "Omitting $file from distribution"
+    rm -rf $NAME-$VERSION/$file
+  fi
 done
 tar cfz $NAME-$VERSION.tar.gz $NAME-$VERSION
-rm -r $NAME-$VERSION
+rm -rf $NAME-$VERSION