diff options
author | classabbyamp <void@placeviolette.net> | 2022-09-02 16:55:43 -0400 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-09-04 09:11:11 +0200 |
commit | 426ecc27ed49218e2d98f0448dff78fb6f23c17a (patch) | |
tree | 26d0ff0fa31fbef0a3c637766e257e4b51071d50 /xpkgdiff | |
parent | 8f5e62949a7ee88b85cf45a62617026549e3040a (diff) | |
download | xtools-426ecc27ed49218e2d98f0448dff78fb6f23c17a.tar.gz xtools-426ecc27ed49218e2d98f0448dff78fb6f23c17a.tar.xz xtools-426ecc27ed49218e2d98f0448dff78fb6f23c17a.zip |
xpkgdiff: improve cross functionality
adds `-R` and `-a` to make it easier to handle cross, but still support setting XBPS_TARGET_ARCH directly.
Diffstat (limited to 'xpkgdiff')
-rwxr-xr-x | xpkgdiff | 40 |
1 files changed, 35 insertions, 5 deletions
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 |