summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/abslibre-tools/libreaddiff69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff
index 010c7b9..b0e2c1d 100755
--- a/src/abslibre-tools/libreaddiff
+++ b/src/abslibre-tools/libreaddiff
@@ -25,41 +25,48 @@ set -e
. "$(librelib messages)"
. "$(librelib conf)"
+usage() {
+ 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."
+}
+
main() {
load_files libretools
check_vars libretools WORKDIR
- for arg in "$@" ; do
+ while getopts 'h' arg; 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
- ;;
+ h) usage; exit 0 ;;
+ *) usage >&2; exit 2 ;;
esac
done
+ if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
+ usage >&2
+ exit 2
+ fi
# The repo to find missing packages in.
- repo=$1
+ local 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")'
+ local arch=${2:-mips64el}
diff -U0 \
- <(pacman_list_packages | sort ) \
- <(abslibre_list_packages | sort ) \
+ <(pacman_list_packages "$repo" "$arch" | sort) \
+ <(abslibre_list_packages "$repo" "$arch" | 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
+ local repo=$1
+ local arch=$2
+
+ # A Python tuple of repos which don't have arch=any packages.
+ local archrepos='("core", "extra", "community")'
+
+ tar xOf "/var/lib/pacman/sync/$repo.db" | python -c '
+import sys
arch = None
name = None
version = None
@@ -78,28 +85,22 @@ try:
except StopIteration:
pass
'
- done
}
abslibre_list_packages() {
- cd "${WORKDIR}/abslibre"
- # Needed to not include pkgnames specific to other arches.
- CARCH=$arch
- for f in $repo/* ; do
+ local repo=$1
+ local arch=$2
+
+ local CARCH=$arch
+ local f name
+ for f in "${WORKDIR}/abslibre/$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
+ if in_array 'any' "${arch[@]}" || in_array "$CARCH" "${arch[@]}" ; then
for name in "${pkgname[@]}" ; do
if [[ -z "$epoch" ]] ; then
- echo $name-$pkgver-$pkgrel
+ echo "$name-$pkgver-$pkgrel"
else
- echo $name-$epoch:$pkgver-$pkgrel
+ echo "$name-$epoch:$pkgver-$pkgrel"
fi
done
fi