Skip to content

Commit

Permalink
kiss-repo(rev)depends: same utility to search in repositories instead
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Dec 23, 2023
1 parent 7740c92 commit b9a8f9f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contrib/kiss-repodepends
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions contrib/kiss-reporevdepends
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b9a8f9f

Please sign in to comment.