From 426ecc27ed49218e2d98f0448dff78fb6f23c17a Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 2 Sep 2022 16:55:43 -0400 Subject: xpkgdiff: improve cross functionality adds `-R` and `-a` to make it easier to handle cross, but still support setting XBPS_TARGET_ARCH directly. --- xpkgdiff | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'xpkgdiff') diff --git a/xpkgdiff b/xpkgdiff index 581366e..1dd1287 100755 --- a/xpkgdiff +++ b/xpkgdiff @@ -1,21 +1,23 @@ #!/bin/sh -# xpkgdiff [-r] [-f|-x [-t]|-S|-c FILE|-p PROP[,...]] PKG - compare PKG between remote to local repositories +# xpkgdiff [-r] [-R URL] [-a ARCH] [-f|-x [-t]|-S|-c FILE|-p PROP[,...]] PKG - compare PKG between remote to local repositories usage() { - echo "Usage: xpkgdiff [-r] [-f|-x [-t]|-S|-c FILE|-p PROP[,...]] PKG" + echo "Usage: xpkgdiff [-r] [-R URL] [-a ARCH] [-f|-x [-t]|-S|-c FILE|-p PROP[,...]] PKG" exit 1 } cleanup() { rm -rf $TMPDIR + exit 0 } : ${DIFF:="diff -u --color"} +: ${ARCH:=$XBPS_TARGET_ARCH} # by default, don't sort SORT='cat' -while getopts Sc:fhp:rtx flag; do +while getopts Sc:fhp:rtxa:R: flag; do case $flag in S) QUERY='--show' ;; c) QUERY="--cat=$OPTARG" ;; @@ -24,6 +26,8 @@ while getopts Sc:fhp:rtx flag; do r) REVERSE=1 ;; t) FULLTREE=1 ;; x) QUERY='--deps'; SORT='sort' ;; + a) ARCH="$OPTARG" ;; + R) REMOTE_BASEURL="$OPTARG" ;; h|?) usage ;; esac done @@ -33,6 +37,32 @@ shift $(($OPTIND - 1)) [ "$#" -eq 0 ] && usage [ -z "$QUERY" ] && usage +if [ -z "$ARCH" ]; then + # if arch is not set, just add the value of -R to the list + REMOTE_REPOS=" --repository=$REMOTE_BASEURL " +else + [ "$ARCH" != "$XBPS_TARGET_ARCH" ] && export XBPS_TARGET_ARCH="$ARCH" + : ${REMOTE_BASEURL:="https://repo-default.voidlinux.org/current"} + case "$ARCH" in + aarch64*) + REMOTE_BASEURL=${REMOTE_BASEURL%/}/aarch64;; + *-musl) + REMOTE_BASEURL=${REMOTE_BASEURL%/}/musl;; + *) + REMOTE_BASEURL=${REMOTE_BASEURL%/};; + esac + + # if arch is set, add all the standard repos for that arch, and ignore conf repos + REMOTE_REPOS=" + -i + --repository=$REMOTE_BASEURL + --repository=$REMOTE_BASEURL/nonfree + --repository=$REMOTE_BASEURL/multilib + --repository=$REMOTE_BASEURL/multilib/nonfree + --repository=$REMOTE_BASEURL/debug + " +fi + TMPDIR=$(mktemp --tmpdir -d "xpkgdiff.XXXXX") trap cleanup EXIT INT TERM @@ -63,8 +93,8 @@ REPO=" pkg="$1" -if xbps-query -MR $pkg >/dev/null; then - xbps-query -MR $QUERY $pkg | $SORT > "$TMPDIR/${pkg}.repo" +if xbps-query -MR $REMOTE_REPOS $pkg >/dev/null; then + xbps-query -MR $REMOTE_REPOS $QUERY $pkg | $SORT > "$TMPDIR/${pkg}.repo" else echo "Package '$pkg' not found in repositories" > "$TMPDIR/${pkg}.repo" fi -- cgit 1.4.1