Do not try to rm OMIT_FROM_DIST files if they don't exist.
[git-tools-moved-to-github.git] / id-deb-build / mkdist.sh
index 925d249..473013e 100755 (executable)
@@ -11,13 +11,12 @@ fi
 
 #we will keep this to get the project name
 DEBCHANGELOG=debian/changelog
-l=`head -1 $DEBCHANGELOG`
 
 if [ "x$NAME" != x ]; then
   echo "Got name $NAME from IDMETA file"
 else
-  NAME=`echo $l|sed 's/ .*//g'`
-  echo "Warning: assuming name $NAME from debian/changelog"
+  NAME=`head -1 $DEBCHANGELOG|sed 's/ .*//g'`
+  echo "Warning: assuming name $NAME from $DEBCHANGELOG"
 fi
 
 if [ "x$2" != x ]; then
@@ -28,9 +27,9 @@ fi
 if [ "x$VERSION" != x ]; then
   echo "Got version $VERSION from IDMETA file"
 else
-  FULLVERSION=`echo $l|sed 's/.*(//g'|sed 's/).*//g'`
+  FULLVERSION=`head -1 $DEBCHANGELOG|sed 's/.*(//g'|sed 's/).*//g'`
   VERSION=`echo $FULLVERSION|sed 's/-.*//g'`
-  echo "Warning: assuming version $VERSION from debian/changelog"
+  echo "Warning: assuming version $VERSION from $DEBCHANGELOG"
 fi
 
 if [ "x$1" != x ]; then
@@ -38,12 +37,15 @@ if [ "x$1" != x ]; then
   VERSION=$1
 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";
 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 -r $NAME-$VERSION/$file
+  fi
 done
 tar cfz $NAME-$VERSION.tar.gz $NAME-$VERSION
 rm -r $NAME-$VERSION