summaryrefslogtreecommitdiff
path: root/librerelease
diff options
context:
space:
mode:
Diffstat (limited to 'librerelease')
-rwxr-xr-xlibrerelease56
1 files changed, 43 insertions, 13 deletions
diff --git a/librerelease b/librerelease
index 39d3e2d..2359de8 100755
--- a/librerelease
+++ b/librerelease
@@ -24,29 +24,59 @@
source /etc/libretools.conf
custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
-usage () {
- printf "$(gettext "Usage: %s")" "$0"
+function usage {
+ echo "$(gettext "Usage: $0")"
echo
- printf "$(gettext "This script")"
+ echo "$(gettext "This script uploads packages on $WORKDIR/stagging")"
+ echo "$(gettext "to parabola server.")"
+ echo
+ echo "$(gettext "OPTIONS:")"
+ echo "$(gettext " -h this message.")"
+ echo "$(gettext " -l only list packages but not upload them.")"
+ echo "$(gettext " -c clean $WORKDIR/staging.")"
+}
+
+function list_packages {
+ find $WORKDIR/staging/ -type f -print0
+}
+
+function clean_non_packages {
+ find $WORKDIR/staging/ -type -f \! -iname "*.pkg.tar.*" -delete
}
+function clean_packages {
+ find ${WORKDIR}/staging/ -iname "*.pkg.tar.*" -delete
+}
+
+while getopts 'hl' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ l) list_packages; exit 0 ;;
+ c) clean_packages; exit $? ;;
+ esac
+done
+
[[ -e $custom_config ]] && source $custom_config
[[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}"
+clean_non_packages
msg "Uploading packages..."
rsync --recursive \
- --copy-links \
- --hard-links \
- --partial \
- --prune-empty-dirs \
- --human-readable \
- --progress \
- -e "ssh " \
- ${WORKDIR}/staging \
- ${PARABOLAHOST}:${LIBREDESTDIR}/ || exit 1
+ --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 packages from local [staging]"
-find ${WORKDIR}/staging/ -iname "*.pkg.tar.*" -delete
+clean_packages
exit 0