summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-01 20:59:05 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-05 20:01:05 -0600
commit0cf1f12e623aa27e96f5c2a6f749913197a1a525 (patch)
tree0daf795b1b32f0852c8de9f00da9a5831af42a7b /src
parent8430aec80c4f528d9fb161c801e946d695611f3f (diff)
librerelease: wrap the end bit in `function main {...}; main "$@"`
Diffstat (limited to 'src')
-rwxr-xr-xsrc/abslibre-tools/librerelease106
1 files changed, 55 insertions, 51 deletions
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 "$@"