From 0cf1f12e623aa27e96f5c2a6f749913197a1a525 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 1 Jun 2013 20:59:05 -0600 Subject: librerelease: wrap the end bit in `function main {...}; main "$@"` --- src/abslibre-tools/librerelease | 106 +++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 51 deletions(-) (limited to 'src/abslibre-tools/librerelease') diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease index 09f2119..38fa0ac 100755 --- a/src/abslibre-tools/librerelease +++ b/src/abslibre-tools/librerelease @@ -97,57 +97,61 @@ function clean { rm -f $@ } -if [ -w / ]; then - error "Run $0 as normal user" - exit 1 -fi - -while getopts 'hlcn' arg; do - case $arg in - h) usage; exit 0 ;; - l) list_packages; exit 0 ;; - c) clean; exit $? ;; - n) dryrun="--dry-run" ;; - esac -done - -[[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}" - -clean_non_packages -sign_packages - -# Make the permissions of the packages 644 otherwise the user will get access -# denied error when they try to download (rsync --no-perms doesn't seem to -# work). -find ${WORKDIR}/staging -type f -exec chmod 644 {} \; -find ${WORKDIR}/staging -type d -exec chmod 755 {} \; - -# Get the synced files -SYNCED_FILES=($(find ${WORKDIR}/staging -type f)) - -msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) -msg "Uploading packages..." -rsync --recursive \ - ${dryrun} \ - --no-group \ - --no-perms \ - --copy-links \ - --hard-links \ - --partial \ - --prune-empty-dirs \ - --human-readable \ - --progress \ - -e "ssh " \ - ${WORKDIR}/staging \ - ${PARABOLAHOST}:${LIBREDESTDIR}/ || { - error "Sync failed, try again" - exit 1 -} +function main { + if [ -w / ]; then + error "Run $0 as normal user" + exit 1 + fi -msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" -clean ${SYNCED_FILES[@]} + while getopts 'hlcn' arg; do + case $arg in + h) usage; exit 0 ;; + l) list_packages; exit 0 ;; + c) clean; exit $? ;; + n) dryrun="--dry-run" ;; + esac + done -msg "Running db-update on repos" -ssh ${PARABOLAHOST} dbscripts/db-update + [[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}" + + clean_non_packages + sign_packages + + # Make the permissions of the packages 644 otherwise the user will get access + # denied error when they try to download (rsync --no-perms doesn't seem to + # work). + find ${WORKDIR}/staging -type f -exec chmod 644 {} \; + find ${WORKDIR}/staging -type d -exec chmod 755 {} \; + + # Get the synced files + SYNCED_FILES=($(find ${WORKDIR}/staging -type f)) + + msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) + msg "Uploading packages..." + rsync --recursive \ + ${dryrun} \ + --no-group \ + --no-perms \ + --copy-links \ + --hard-links \ + --partial \ + --prune-empty-dirs \ + --human-readable \ + --progress \ + -e "ssh " \ + ${WORKDIR}/staging \ + ${PARABOLAHOST}:${LIBREDESTDIR}/ || { + error "Sync failed, try again" + exit 1 + } + + msg "Removing ${#SYNCED_FILES[@]} files from local [staging]" + clean ${SYNCED_FILES[@]} + + msg "Running db-update on repos" + ssh ${PARABOLAHOST} dbscripts/db-update + + exit 0 +} -exit 0 +main "$@" -- cgit v1.2.3