Commit 381f91c3 authored by Evangelos Foutras's avatar Evangelos Foutras Committed by Aaron Griffin
Browse files

commitpkg: introduce abort function for errors

parent fa47bd1a
Loading
Loading
Loading
Loading
+13 −29
Original line number Diff line number Diff line
#!/bin/bash

abort() {
    echo ${1:-"Cancelled"}
    exit 1
}

# Source makepkg.conf; fail if it is not found
if [ -r "/etc/makepkg.conf" ]; then
    source "/etc/makepkg.conf"
else
    echo "/etc/makepkg.conf not found!"
    exit 1
    abort "/etc/makepkg.conf not found!"
fi

# Source user-specific makepkg.conf overrides
@@ -16,8 +20,7 @@ fi
cmd=$(basename $0)

if [ ! -f PKGBUILD ]; then
    echo "No PKGBUILD file"
    exit 1
    abort "No PKGBUILD file"
fi

source PKGBUILD
@@ -39,8 +42,7 @@ elif [ "$cmd" == "community-testingpkg" ]; then
    server="aur.archlinux.org"
else
    if [ $# -eq 0 ]; then
        echo "usage: commitpkg <reponame> [-l limit] [commit message]"
        exit 1
        abort "usage: commitpkg <reponame> [-l limit] [commit message]"
    fi
    repo="$1"
    shift
@@ -70,46 +72,28 @@ for CARCH in ${arch[@]}; do
        uploadto="staging/${repo}/$(basename ${pkgfile})"
        # don't re-upload the same package (useful for -any sub packages)
        if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then
            scp ${scpopts} "${pkgfile}" "${server}:${uploadto}"
            scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" || abort
        fi
        if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then
            echo "File got corrupted during upload, cancelled."
            exit 1
            abort "File got corrupted during upload, cancelled."
        else
            echo "File integrity okay."
        fi

        if [ $? -ne 0 ]; then
            echo "Cancelled"
            exit 1
        fi
        echo "===> Uploaded $pkgfile"
    done

    if [ "$1" != "" ]; then
        svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel
    $1" > /dev/null
        if [ $? -ne 0 ]; then
            echo "Cancelled"
            exit 1
        fi
    $1" > /dev/null || abort
        echo "===> Commited with message:
  upgpkg: $pkgbase $pkgver-$pkgrel
      $1"
    else
        svn commit
        if [ $? -ne 0 ]; then
            echo "Cancelled"
            exit 1
        fi
        svn commit || abort
        echo "===> Commited"
    fi

    archrelease $repo-$CARCH
    if [ $? -ne 0 ]; then
        echo "Cancelled"
        exit 1
    fi
    archrelease $repo-$CARCH || abort
    echo "===> Tagged for $repo-$CARCH"
done