From 2ae5371f347603d34a7ccc33681e612db338d11e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 May 2017 17:46:32 -0400 Subject: Have everything use a main() function, where it isn't too tricky to convert "Ignore space change" is essential to making sense of this patch. --- src/abslibre-tools/createworkdir | 43 ++++++++------- src/abslibre-tools/libreaddiff | 114 +++++++++++++++++++++------------------ 2 files changed, 86 insertions(+), 71 deletions(-) (limited to 'src/abslibre-tools') diff --git a/src/abslibre-tools/createworkdir b/src/abslibre-tools/createworkdir index 80b2d5e..e3e4143 100755 --- a/src/abslibre-tools/createworkdir +++ b/src/abslibre-tools/createworkdir @@ -27,28 +27,33 @@ set -euE . "$(librelib messages)" . "$(librelib conf)" -load_files libretools -check_vars libretools WORKDIR ABSLIBRERECV ABSLIBRESEND # these are asked for by `xbs download` -trap 'error "Aborting..."' EXIT +main() { + load_files libretools + check_vars libretools WORKDIR ABSLIBRERECV ABSLIBRESEND # these are asked for by `xbs download` -msg "Creating WORKDIR at %s..." "$WORKDIR" -mkdir -p "$WORKDIR" + trap 'error "Aborting..."' EXIT -msg "Creating staging directory in WORKDIR..." -mkdir -p "$WORKDIR/staging" + msg "Creating WORKDIR at %s..." "$WORKDIR" + mkdir -p "$WORKDIR" -cmd=(xbs -b abslibre download) -if ! "${cmd[@]}"; then - error "Could not clone ABSLibre" - plain "Try running this command:" - echo - printf '%q ' "${cmd[@]}" - echo - exit 1 -fi + msg "Creating staging directory in WORKDIR..." + mkdir -p "$WORKDIR/staging" -msg "Finished, your packaging directory tree looks like this now:" -ls --color=auto "${WORKDIR}"/* + cmd=(xbs -b abslibre download) + if ! "${cmd[@]}"; then + error "Could not clone ABSLibre" + plain "Try running this command:" + echo + printf '%q ' "${cmd[@]}" + echo + exit 1 + fi -trap -- EXIT + msg "Finished, your packaging directory tree looks like this now:" + ls --color=auto "${WORKDIR}"/* + + trap -- EXIT +} + +main "$@" diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff index 17e808b..010c7b9 100755 --- a/src/abslibre-tools/libreaddiff +++ b/src/abslibre-tools/libreaddiff @@ -24,35 +24,42 @@ set -e . "$(librelib messages)" . "$(librelib conf)" -load_files libretools -check_vars libretools WORKDIR -for arg in "$@" ; do - case "$arg" in - -h|--h|--he|--hel|--help|-\?) - { - 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 -done +main() { + load_files libretools + check_vars libretools WORKDIR -# The repo to find missing packages in. -repo=$1 -# The arch to check in Arch repos, other will have all arches checked. -arch=${2:-mips64el} -# A Python tuple of repos which don't have arch=any packages. -archrepos='("core", "extra", "community")' + for arg in "$@" ; do + case "$arg" in + -h|--h|--he|--hel|--help|-\?) + { + 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 + done -diff -U0 \ - <( ( - cd /var/lib/pacman/sync - for f in $repo.db ; do - tar xOf $f | python -c 'import sys + # The repo to find missing packages in. + repo=$1 + # The arch to check in Arch repos, other will have all arches checked. + arch=${2:-mips64el} + # A Python tuple of repos which don't have arch=any packages. + archrepos='("core", "extra", "community")' + + diff -U0 \ + <(pacman_list_packages | sort ) \ + <(abslibre_list_packages | sort ) \ + | sed -rn 's/^[+-][^+-].+$/&/p' +} + +pacman_list_packages() { + cd /var/lib/pacman/sync + for f in $repo.db ; do + tar xOf $f | python -c 'import sys arch = None name = None version = None @@ -71,29 +78,32 @@ try: except StopIteration: pass ' - done - ) | sort ) \ - <( ( - cd "${WORKDIR}/abslibre" - # Needed to not include pkgnames specific to other arches. - CARCH=$arch - for f in $repo/* ; do - load_PKGBUILD "$f/PKGBUILD" || continue - is_here=false - for arc in ${arch[@]} ; do - if [[ "$arc" == "any" ]] || [[ "$arc" == "$CARCH" ]] ; then - is_here=true - break - fi - done - if [[ "$is_here" == "true" ]] ; then - for name in "${pkgname[@]}" ; do - if [[ -z "$epoch" ]] ; then - echo $name-$pkgver-$pkgrel - else - echo $name-$epoch:$pkgver-$pkgrel - fi - done - fi - done - ) | sort ) | sed -rn 's/^[+-][^+-].+$/&/p' + done +} + +abslibre_list_packages() { + cd "${WORKDIR}/abslibre" + # Needed to not include pkgnames specific to other arches. + CARCH=$arch + for f in $repo/* ; do + load_PKGBUILD "$f/PKGBUILD" || continue + is_here=false + for arc in ${arch[@]} ; do + if [[ "$arc" == "any" ]] || [[ "$arc" == "$CARCH" ]] ; then + is_here=true + break + fi + done + if [[ "$is_here" == "true" ]] ; then + for name in "${pkgname[@]}" ; do + if [[ -z "$epoch" ]] ; then + echo $name-$pkgver-$pkgrel + else + echo $name-$epoch:$pkgver-$pkgrel + fi + done + fi + done +} + +main "$@" -- cgit v1.2.2