diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-01 17:46:32 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-04 14:28:08 -0400 |
commit | 2ae5371f347603d34a7ccc33681e612db338d11e (patch) | |
tree | 2ecb5b05dcb1ffc2defb31c7f64d6720435f13e5 /src/abslibre-tools/libreaddiff | |
parent | bb97cfc85d9b711b517985abbd9832bff9c4b37a (diff) |
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.
Diffstat (limited to 'src/abslibre-tools/libreaddiff')
-rwxr-xr-x | src/abslibre-tools/libreaddiff | 114 |
1 files changed, 62 insertions, 52 deletions
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 "$@" |