kiss-repo(rev)depends: same utility to search in repositories instead

This commit is contained in:
wael 2022-10-01 12:51:52 +03:00 committed by sewn
parent 7740c929a3
commit b9a8f9fc28
No known key found for this signature in database
2 changed files with 35 additions and 0 deletions

16
contrib/kiss-repodepends Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh -ef
# Display a package's dependencies in repositories
pkg=${1:-"${PWD##*/}"}
kiss search "$pkg" >/dev/null || {
printf 'usage: kiss-depends [pkg]\n' >&2
exit 1
}
kiss search "$pkg" | while read -r pkgpath; do
printf '=> %s\n' "$pkgpath"
while read -r dep mak || [ "$dep" ]; do
printf '%s%s\n' "$dep" "${mak:+ "$mak"}"
done 2>/dev/null < "$pkgpath/depends"
done

19
contrib/kiss-reporevdepends Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Display packages in all repositories which depend on a package
[ "$1" ] || set -- "${PWD##*/}"
suffix () {
case "$1" in *"$2") return 0; esac; return 1
}
IFS=:
for repo in $KISS_PATH; do
# remove trailing slashes
while suffix "$repo" /; do repo="${repo%/}"; done
gitdir="$(git -C "$repo" rev-parse --show-toplevel 2>/dev/null || echo "$repo")"
case "$gitdir" in "$repo") unset prefix ;; *) prefix="${repo##*/}/" ;; esac
cd "$gitdir/.." || continue
grep -E "^$1([[:space:]]|$)" -- "${gitdir##*/}/$prefix"*/depends 2>/dev/null ||:
done