diff options
Diffstat (limited to 'src/abslibre-tools')
-rwxr-xr-x | src/abslibre-tools/createworkdir | 49 | ||||
-rwxr-xr-x | src/abslibre-tools/diff-unfree | 16 | ||||
-rwxr-xr-x | src/abslibre-tools/libreaddiff | 10 | ||||
-rwxr-xr-x | src/abslibre-tools/librerelease | 136 | ||||
-rwxr-xr-x | src/abslibre-tools/librestage | 14 |
5 files changed, 124 insertions, 101 deletions
diff --git a/src/abslibre-tools/createworkdir b/src/abslibre-tools/createworkdir index 99214ab..a251d40 100755 --- a/src/abslibre-tools/createworkdir +++ b/src/abslibre-tools/createworkdir @@ -1,8 +1,10 @@ #!/usr/bin/env bash +set -euE # CreateWorkDir # Creates a dir structure for working with Parabola packages # Copyright 2010 Nicolás Reynolds +# Copyright 2013 Luke Shumaker # ---------- GNU General Public License 3 ---------- @@ -24,41 +26,26 @@ . libremessages . $(librelib conf.sh) load_files libretools -check_vars libretools WORKDIR REPOS ABSLIBREGIT || exit 1 +check_vars libretools WORKDIR REPOS ABSLIBREGIT -[[ ! -d ${WORKDIR} ]] && { # Create the WORKDIR +trap 'error "Aborting..."' EXIT - msg "Creating WORKDIR on ${WORKDIR}" - mkdir -p ${WORKDIR} ||{ - error "Could not create ${WORKDIR}"; exit 1 - } +msg "Creating WORKDIR at %s..." "$WORKDIR" +mkdir -p "$WORKDIR" -} +msg "Creating staging directory in WORKDIR..." +mkdir -p "$WORKDIR/staging" -for _repo in "${REPOS[@]}"; do # Create the staging dirs +cmd=(libregit "$ABSLIBREGIT" master "$WORKDIR/abslibre") +if ! "${cmd[@]}"; then + error "Could not clone ABSLibre" + print "Try running this command:" + echo + print '%s' "${cmd[*]}" + exit 1 +fi - [[ ! -d ${WORKDIR}/staging/${_repo} ]] && { - mkdir -p ${WORKDIR}/staging/${_repo} || { - error "Can't create ${WORKDIR}/staging/${_repo}" - exit 1 - } - } - -done - -[[ ! -d ${WORKDIR}/abslibre/.git ]] && { - msg "Cloning into ABSLibre" - CMD="git clone ${ABSLIBREGIT} ${WORKDIR}/abslibre" - ${CMD} || { - error "Could not clone ABSLibre" - plain "Try running this command:" - echo - plain "${CMD}" - exit 1 - } -} - -msg "Finished, your packaging dir tree looks like this now:" +msg "Finished, your packaging directory tree looks like this now:" ls --color=always ${WORKDIR}/*/* -exit 0 +trap -- EXIT diff --git a/src/abslibre-tools/diff-unfree b/src/abslibre-tools/diff-unfree index 07f2ca2..b3e2327 100755 --- a/src/abslibre-tools/diff-unfree +++ b/src/abslibre-tools/diff-unfree @@ -25,14 +25,12 @@ load_files libretools check_vars libretools DIFFTOOL || exit 1 -cmd=${0##*/} - usage() { - echo "Usage: $cmd [community|packages] [unfree-package] [repo]" - echo "Usage: $cmd --help" - echo "Helps you diff build scripts from ABSLibre against (Unfree) ABS." - echo "" - echo "Package name and repo will we guessed if you don't specify them." + print "Usage: %s [community|packages] [unfree-package] [repo]" "${0##*/}" + print "Usage: %s --help" "${0##*/}" + prose "Helps you diff build scripts from ABSLibre against (Unfree) ABS." + echo + prose "Package name and repo will we guessed if you don't specify them." } main() { @@ -68,7 +66,7 @@ main() { pushd "${tmp_dir}" &>/dev/null - msg "Getting diff from $repo/$package..." + msg "Getting diff from %s..." "$repo/$package" svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo &>/dev/null @@ -81,7 +79,7 @@ main() { msg "Diffing files" for _file in ${unfree_dir}/*; do - msg2 "$(basename "${_file}")" + msg2 "%s" "$(basename "${_file}")" ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" done } diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff index 03d0ad0..9f5ae27 100755 --- a/src/abslibre-tools/libreaddiff +++ b/src/abslibre-tools/libreaddiff @@ -23,10 +23,12 @@ check_vars libretools WORKDIR for arg in "$@" ; do case "$arg" in -h|--h|--he|--hel|--help|-\?) - echo 'Usage: libreaddiff repo [arch] - -This script outputs a diff of package names and versions in repo -between pacman'\''s sync db and abslibre checkout.' >&2 + { + print 'Usage: %s repo [arch]' "${0##*/}" + echo + prose "This script outputs a diff of package names and versions + in repo between pacman's sync db and abslibre checkout." + } >&2 exit 0 ;; esac diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease index 5913670..f0d59e3 100755 --- a/src/abslibre-tools/librerelease +++ b/src/abslibre-tools/librerelease @@ -38,25 +38,22 @@ . libremessages . $(librelib conf.sh) -function usage { - print "Usage: %s [OPTIONS]" "${0##*/}" - echo - print 'This script uploads packages on $WORKDIR/stagging' - print "to parabola server." - echo - print "Options:" - print ' -c Clean packages on $WORKDIR/staging' - print " -l Only list packages but not upload them" - print " -n Dry-run; don't actually do anything" - print " -h Show this message" -} - -function 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}" -type f -printf "%f\n" | sort - done +dryrun="" +readonly rsync_flags=( + --no-group + --no-perms + --copy-links + --hard-links + --partial + --human-readable + --progress + -e ssh +) + +# Functions #################################################################### + +list0_files() { + find "${WORKDIR}/staging" -L -type f -print0 } # This function is taken almost verbatim from makepkg @@ -81,7 +78,7 @@ create_signature() { fi } -function sign_packages { +sign_packages() { if [ -z "${GPG_AGENT_INFO}" ]; then warning "It's better to use gpg-agent to sign packages in batches" fi @@ -104,36 +101,52 @@ function sign_packages { } # Remove everything that's not a package or a signature -function clean_non_packages { +clean_non_packages() { find $WORKDIR/staging/ -type f \ \! -iname "*.pkg.tar.?z" -a \! -iname "*.pkg.tar.?z.sig" \ -delete } # Clean everything if not on dry-run mode -function clean { +clean_files() { + local file_list=$1 + + local rmcmd=(rm -fv) if [[ -n "${dryrun}" ]]; then - : - else - msg "Removing files from local staging directory" - # use '-exec rm' instead of '-delete' to be verbose - find "${WORKDIR}/staging" -type f -exec rm -fv {} + + rmcmd=(printf "$(_ "removed '%s' (dry-run)")\n") fi + + msg "Removing files from local staging directory" + xargs -0 -a "$file_list" "${rmcmd[@]}" } -function main { - if [ -w / ]; then +################################################################################ + +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 error "This program should be run as regular user" return 1 fi # Parse options - local dryrun="" local mode="release_packages" 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 ;; @@ -154,41 +167,64 @@ function main { check_vars makepkg GPGKEY load_files libretools check_vars libretools WORKDIR REPODEST || return 1 - # The following variables are actually optional + REPODEST+='/staging/' + # The following settings are actually optional #check_vars libretools HOOKPRERELEASE HOOKPOSTRELEASE || return 1 - lock 10 "${WORKDIR}/staging.lock" 'Waiting for an exclusive lock on the staging directory' "$mode" } -function release_packages { +# 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..." bash -c "${HOOKPRERELEASE}" fi + lock 10 "${WORKDIR}/staging.lock" \ + 'Waiting for an exclusive lock on the staging directory' + clean_non_packages sign_packages || return 1 # 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 {} \; + find ${WORKDIR}/staging -type f -exec chmod 644 {} + + find ${WORKDIR}/staging -type d -exec chmod 755 {} + + + local file_list="$(mktemp -t ${0##*/}.XXXXXXXXXX)" + trap "$(printf 'rm -f -- %q' "$file_list")" EXIT + list0_files > "$file_list" + + lock_close 10 - msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1) + msg "%s to upload" "$(du -hc --files0-from="$file_list" | sed -n '$s/\t.*//p')" msg "Uploading packages..." - if ! rsync --recursive \ - ${dryrun} \ - --no-group \ - --no-perms \ - --copy-links \ - --hard-links \ - --partial \ - --prune-empty-dirs \ - --human-readable \ - --progress \ - -e "ssh " \ + if ! rsync ${dryrun} "${rsync_flags[@]}" \ + -0 --files-from="$file_list" ${WORKDIR}/staging \ ${REPODEST}/ then @@ -196,10 +232,10 @@ function release_packages { return 1 fi - clean + clean_files "$file_list" msg "Running db-update on repos" - ssh ${REPODEST%%:*} dbscripts/db-update + ssh ${REPODEST%%:*} "$(printf 'STAGING=%q dbscripts/db-update' "${REPODEST#*:}")" if [[ -n $HOOKPOSTRELEASE ]]; then msg "Running HOOKPOSTRELEASE..." diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage index 57846fc..6bbe80e 100755 --- a/src/abslibre-tools/librestage +++ b/src/abslibre-tools/librestage @@ -23,14 +23,13 @@ . libremessages . $(librelib conf.sh) -cmd=${0##*/} usage() { - print "Usage: %s REPO [REPO2 REPO3...]" "$cmd" + print "Usage: %s REPO [REPO2 REPO3...]" "${0##*/}" print "Stages the package(s) build by ./PKGBUILD for upload." echo - print "The package(s) are staged for the named repositories." - print "It is in general a bad idea to stage a package on multiple" - print "repositories, but it supported by this tool." + prose "The package(s) are staged for the named repositories. + It is in general a bad idea to stage a package on multiple + repositories, but it supported by this tool." } main() { @@ -67,7 +66,8 @@ main() { # Now for the main routine. staged=false - slock 10 "${WORKDIR}/staging.lock" 'Waiting for a shared lock on the staging directory' + slock 10 "${WORKDIR}/staging.lock" \ + 'Waiting for a shared lock on the staging directory' for CARCH in "${ARCHES[@]}" any; do for _pkgname in "${pkgname[@]}"; do pkgfile=${_pkgname}-$(get_full_version $_pkgname)-${CARCH}${PKGEXT} @@ -79,7 +79,7 @@ main() { pkgpath="$(readlink -f "$pkgpath")" fi - msg "Found ${pkgfile}" + msg 'Found %s' "${pkgfile}" canonical="" # is empty for the first iteration, set after that for repo in "${repos[@]}"; do |