summaryrefslogtreecommitdiff
path: root/src/abslibre-tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/abslibre-tools')
-rwxr-xr-xsrc/abslibre-tools/librerelease72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease
index 2d2a480..64d5004 100755
--- a/src/abslibre-tools/librerelease
+++ b/src/abslibre-tools/librerelease
@@ -50,31 +50,12 @@ readonly rsync_flags=(
-e ssh
)
-usage() {
- print "Usage: %s [OPTIONS]" "${0##*/}"
- echo
- prose 'This script uploads packages on $WORKDIR/stagging
- to parabola server.'
- echo
- print "Options:"
- flag '-c' 'Clean packages on $WORKDIR/staging'
- flag '-l' "Only list packages but not upload them"
- flag '-n' "Dry-run; don't actually do anything"
- flag '-h' "Show this message"
-}
+# Functions ####################################################################
list0_files() {
find "${WORKDIR}/staging" -L -type f -print0
}
-list_packages() {
- find "$WORKDIR/staging/" -mindepth 1 -type d -not -empty -printf '%f\n' | sort |
- while read -r repo; do
- msg2 "$repo"
- find "${WORKDIR}/staging/${repo}" -L -type f -printf "%f\n" | sort
- done
-}
-
# This function is taken almost verbatim from makepkg
create_signature() {
local ret=0
@@ -139,21 +120,23 @@ clean_files() {
xargs -0 -a "$file_list" "${rmcmd[@]}"
}
-clean() {
- lock 10 "${WORKDIR}/staging.lock" \
- 'Waiting for an exclusive lock on the staging directory'
+################################################################################
- local file_list="$(mktemp -t ${0##*/}.XXXXXXXXXX)"
- trap "$(printf 'rm -f -- %q' "$file_list")" EXIT
- list0_files > "$file_list"
-
- lock_close 10
-
- clean_files "$file_list"
+usage() {
+ print "Usage: %s [OPTIONS]" "${0##*/}"
+ echo
+ prose 'This script uploads packages on $WORKDIR/stagging
+ to parabola server.'
+ echo
+ print "Options:"
+ flag '-c' 'Clean packages on $WORKDIR/staging'
+ flag '-l' "Only list packages but not upload them"
+ flag '-n' "Dry-run; don't actually do anything"
+ flag '-h' "Show this message"
}
main() {
- if [ -w / ]; then
+ if [[ -w / ]]; then
error "This program should be run as regular user"
return 1
fi
@@ -163,7 +146,7 @@ main() {
while getopts 'clnh' arg; do
case $arg in
c) mode=clean ;;
- l) mode=list_packages ;;
+ l) mode=pretty_print_packages ;;
n) dryrun="--dry-run" ;;
h) mode=usage ;;
*) usage >/dev/stderr; return 1 ;;
@@ -185,12 +168,35 @@ main() {
load_files libretools
check_vars libretools WORKDIR REPODEST || return 1
REPODEST+='/staging/'
- # The following variables are actually optional
+ # The following settings are actually optional
#check_vars libretools HOOKPRERELEASE HOOKPOSTRELEASE || return 1
"$mode"
}
+# The different modes (sans 'usage') ###########################################
+
+pretty_print_packages() {
+ find "$WORKDIR/staging/" -mindepth 1 -type d -not -empty -printf '%f\n' | sort |
+ while read -r repo; do
+ msg2 "$repo"
+ find "${WORKDIR}/staging/${repo}" -L -type f -printf "%f\n" | sort
+ done
+}
+
+clean() {
+ lock 10 "${WORKDIR}/staging.lock" \
+ 'Waiting for an exclusive lock on the staging directory'
+
+ local file_list="$(mktemp -t ${0##*/}.XXXXXXXXXX)"
+ trap "$(printf 'rm -f -- %q' "$file_list")" EXIT
+ list0_files > "$file_list"
+
+ lock_close 10
+
+ clean_files "$file_list"
+}
+
release_packages() {
if [[ -n $HOOKPRERELEASE ]]; then
msg "Running HOOKPRERELEASE..."