xbps icon indicating copy to clipboard operation
xbps copied to clipboard

search for alternatives providers with xbps-query?

Open classabbyamp opened this issue 2 years ago • 3 comments

xbps-query -Rp alternatives -s vi returns nothing currently (exits 2). perhaps it should search for all packages that provide the vi alternative set.

classabbyamp avatar Jul 19 '22 09:07 classabbyamp

perhaps it should search for all packages that provide the vi alternative set.

Yeah, that would be handy.

anddam avatar Jul 19 '22 09:07 anddam

The way the packages alternatives property is setup and how we print properties would require special handling for this case.

I added a repository mode to xbps-alternatives, which provides the same functionality and fits better imho https://github.com/void-linux/xbps/pull/340.

Duncaen avatar Jul 19 '22 10:07 Duncaen

Lurking around I found this issue, and I remembered I have a patch for that https://github.com/dmarto/xbps/commit/90d28910dc4bd49c147bc6106028192fc166ca13

My use case is the following script (that I use in combo with another one to find files that are not created/managed/owned by a package).

#!/bin/bash
# xalts [STRING]
#  alternatives search, prints results in xbps-query -o compatible way

while read alt; do
    [ -z "${alt}" ] && continue

    alt=${alt% (*)}

    pkg=${alt%%:*}

    real=${alt##*:}

    dir=$(dirname "$real")

    link=${alt#*: }
    link=${link%:*}
    [ "$(dirname "$link")" = "." ] && link="$dir/$link"

    echo "$pkg: $link -> $real (link)"

done <<< $(x xbps-query -R -p alternatives --search="$1")

If it is of intereset, I could open a PR.

dmarto avatar Oct 08 '22 22:10 dmarto