Provide 'successful' message if upload succeeds GA-12
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 12 Mar 2014 13:44:38 +0000 (14:44 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 12 Mar 2014 13:44:38 +0000 (14:44 +0100)
And also add checks for a few of the upload stages. The script
should return exit 0 only on success.

id-deb-build/id-pbuild.sh

index 037b8ca..a8206a1 100755 (executable)
@@ -88,9 +88,7 @@ if test ! -x $MKDEBSRC; then
     exit 1
 fi
 
-if $upload; then
-    :
-else
+if ! $upload; then
     if $debian; then
        if test "${SUDO_USER}"; then
            if test ! -d deb-src; then
@@ -169,9 +167,7 @@ if $upload; then
     for dist in ${CENTOS_DIST}; do
        arch=amd64
        prodver=${PRODUCT}-${VERSION}
-       if scp ${ID_DEB_BUILD}/../id-rpm-build/upload-rpms.sh ${dist}:rpmbuild/SOURCES/${prodver}/; then
-           :
-       else
+       if ! scp ${ID_DEB_BUILD}/../id-rpm-build/upload-rpms.sh ${dist}:rpmbuild/SOURCES/${prodver}/; then
            echo "Copy of upload-rpms.sh to $dist failed"
            exit 1
        fi
@@ -183,17 +179,32 @@ if $upload; then
        fi
     done
     for dist in ${UBUNTU_DIST}; do
-       scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
+       ssh ftp.indexdata.dk "mkdir -p /home/ftp/pub/${PRODUCT}/ubuntu/${dist}"
+       if ! scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}; then
+            echo "Upload failed for $dist"
+            exit 1
+        fi
     done
     for dist in ${DEBIAN_DIST}; do
-       scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
+       ssh ftp.indexdata.dk "mkdir -p /home/ftp/pub/${PRODUCT}/debian/${dist}"
+       if ! scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}; then
+            echo "Upload failed for $dist"
+           exit 1
+        fi
     done
     if test "${CENTOS_DIST}"; then
-       ssh ftp.indexdata.dk "sudo -n /home/indexdata/proj/git-tools/update-archive/update-yum-archive.sh"
+       if ! ssh ftp.indexdata.dk "sudo -n /home/indexdata/proj/git-tools/update-archive/update-yum-archive.sh"; then
+            echo "update-yum-archive.sh failed"
+            exit 1
+        fi
     fi
     if test "${UBUNTU_DIST}" -o "${DEBIAN_DIST}"; then
-       ssh ftp.indexdata.dk "sudo -n /home/indexdata/proj/git-tools/update-archive/update-archive.sh --ubuntu=\"${UBUNTU_DIST}\" --debian=\"${DEBIAN_DIST}\""
+       if ! ssh ftp.indexdata.dk "sudo -n /home/indexdata/proj/git-tools/update-archive/update-archive.sh --ubuntu=\"${UBUNTU_DIST}\" --debian=\"${DEBIAN_DIST}\""; then
+            echo "update-archive.sh failed"
+            exit 1
+        fi
     fi
+    echo "Upload successful - we hope"
     exit 0
 fi