Script to either show a full dependency tree of a package or find the closest link between two dependencies.
#!/bin/sh
base=$(mktemp -d "/tmp/xdeplink.XXXXXX") || exit 1
trap "rm -rf \"${base}\"" EXIT TERM
tree="${base}/tree"; store="${base}/store"
test "$#" -ge 1 || exit
mkdir "${tree}" "${store}"
cd "${tree}" || exit
handle() {
deps=$(xbps-query -Rx "${1}")
test -n "${deps}" || return
for d in ${deps}; do
d=$(xbps-uhelper getpkgdepname "${d}")
test -n "${d}" || continue
if ! test -e "${store}/${d}"; then
mkdir "${d}"
ln -s "${PWD}/${d}" "${store}/${d}"
( cd "${d}"; handle "${d}"; )
else
ln -s "${store}/${d}" "${d}"
fi
done
}
handle "${1}"
if test -n "${2}"; then
find -name "${2}" -printf '%d %P\n' | sort -n | sed -E 's|^[0-9]+ ||g'
else
find -mindepth 1 -printf '%P\n' | sort
fi
Example:
$ xdeptree mesa-dri ncurses-libs
libllvm15/ncurses-libs
libllvm15/libedit/ncurses-libs
libllvm15/libxml2/libreadline8/ncurses-libs
This shows that ncurses-libs gets pulled in by libllvm15 and that's why it's a dependency of mesa-dri.
Another Example:
$ xdeptree ffmpeg wayland
ffplay/SDL2/wayland
ffplay/SDL2/libdecor/wayland
A third one (print the whole tree)
$ xdeptree wayland
glibc
libffi
libffi/glib
Script to either show a full dependency tree of a package or find the closest link between two dependencies.
Example:
This shows that ncurses-libs gets pulled in by libllvm15 and that's why it's a dependency of mesa-dri.
Another Example:
A third one (print the whole tree)