Generate debian/changelog from IDMETA SA-616
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 2 Jul 2014 12:51:19 +0000 (14:51 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 2 Jul 2014 12:51:19 +0000 (14:51 +0200)
id-deb-build/id-pbuild.sh
id-deb-build/mkdist.sh

index a8206a1..0f3441e 100755 (executable)
@@ -13,7 +13,6 @@ Options:
        [--centos=distros]
        [--upload]
        [--concurrency=N]
-       [--product=X]
 EOF
     exit $1
 }
@@ -48,9 +47,6 @@ while test $# -gt 0; do
         --concurrency=*)
            concurrency=$optarg
            ;;
-        --product=*)
-           PRODUCT=$optarg
-           ;;
        -*)
            do_help=yes
            ;;
@@ -82,14 +78,38 @@ if test ! -x $PBUILDROOT; then
     exit 1
 fi
 
-MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
-if test ! -x $MKDEBSRC; then
-    echo "$MKDEBSRC not found"
-    exit 1
+if test "$CENTOS_DIST"; then
+    RNAME=`rpm -q --specfile *.spec --queryformat "%{NAME};" | cut -d ";" -f1`
+    echo "RNAME=$RNAME"
+    if test "$NAME" -a "$NAME" != "$RNAME"; then
+       echo "NAME in IDMETA ($NAME) does not match RPM spec NAME ($RNAME)"
+       exit 1
+    fi
+    PRODUCT=$RNAME
 fi
-
-if ! $upload; then
-    if $debian; then
+if $debian; then
+    DNAME=`awk '/Source:/ {print $2}' debian/control`
+    if test "$NAME" -a "$NAME" != "$DNAME"; then
+       echo "NAME in IDMETA ($NAME) does not match debian/control ($DNAME)"
+       exit 1
+    fi
+    PRODUCT=$DNAME
+    if ! $upload; then
+       MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
+       if test ! -x $MKDEBSRC; then
+           echo "$MKDEBSRC not found"
+           exit 1
+       fi
+       DCH=debian/changelog
+       if ! git ls-files $DCH --error-unmatch >/dev/null 2>&1; then
+           rm -f $DCH
+           echo "${DNAME} (${VERSION}-1.indexdata) unstable; urgency=medium" >$DCH
+           echo '' >>$DCH
+           echo '  * Upstream.' >>$DCH
+           echo '' >>$DCH
+           echo " -- `git config --get user.name` <`git config --get user.email`>  `date -R`" >>$DCH
+           echo '' >>$DCH
+       fi
        if test "${SUDO_USER}"; then
            if test ! -d deb-src; then
                $MKDEBSRC
@@ -104,9 +124,9 @@ if ! $upload; then
            fi
            $MKDEBSRC
        fi
-    else
-       mkdir -p deb-src
     fi
+else
+    mkdir -p deb-src
 fi
 
 cd deb-src
@@ -132,17 +152,7 @@ if $debian; then
     fi
 fi
 
-if test -z "$PRODUCT"; then
-    PRODUCT=$NAME
-fi
-if test -z "$PRODUCT"; then
-    if $debian; then
-       PRODUCT=`echo *.dsc|sed 's/_.*//g'`
-    else
-       PRODUCT=`cd ..;rpm -q --specfile *.spec --queryformat "%{NAME};" | cut -d ";" -f1`
-    fi
-fi
-echo "Dsc $PKG . Product $PRODUCT"
+echo "Product: $PRODUCT"
 echo "Ubuntu distros: $UBUNTU_DIST"
 echo "Debian distros: $DEBIAN_DIST"
 echo "Centos distros: $CENTOS_DIST"
index 52ef1e9..40a99ca 100755 (executable)
@@ -15,15 +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 $DEBCHANGELOG; then
-  NAME=`head -1 $DEBCHANGELOG|sed 's/ .*//g'`
-  echo "Warning: assuming name $NAME from $DEBCHANGELOG"
+elif test -f debian/control; then
+  NAME=`awk '/Source:/ {print $2}' debian/control`
+  echo "Warning: assuming name $NAME from debian/control"
 else
-  die "No $DEBCHANGELOG and no NAME in IDMETA"
+  die "No debian/control and no NAME in IDMETA"
 fi
 
 if [ "x$2" != x ]; then