You are not logged in.
Sorry for the newbie question, but who is the syntax to have pacman show me what installed packages are needing a particular package? I know I can go and attempt to remove the package in question, but I'm sure there's a better way ![]()
Offline
Here are some functions from my .bashrc. The earlier ones depend on the later ones. You could of course simplify; I'll leave that to you. If I left any dependencies out, left me know.
pac-requiredby ()
{
if [[ $# -eq 0 ]]; then
echo -e "Usage: $FUNCNAME [-r] PKG\n\tlist other installed packages that depend on PKG\n\toption -r makes the list recursive" 1>&2;
return 1;
fi;
local RECURSIVE;
if [[ "$1" == -r ]]; then
RECURSIVE=1;
shift;
fi;
if [[ $# -ne 1 ]]; then
echo "$FUNCNAME only works on single package" 1>&2;
return 1;
fi;
local next i j;
if pac-installed "$@"; then
_pac_first=($(pacman -Qi "$@" 2>/dev/null | sed -nr -e '/^Required By\s*: / {s///; /^None$/q; h; :a; n; /:/!{H; ba}; g; s/\s*\n\s*/ /g; p}'));
if [[ RECURSIVE -eq 1 ]]; then
function lambda ()
{
_pac_next=($(pac-requiredby "${1%>*}"));
if [[ ${#_pac_next[@]} -gt 0 ]]; then
_pac_first=($(arrayunion _pac_first _pac_next));
fi
};
arrayall _pac_first lambda;
fi;
arrayecho _pac_first;
else
if pacman -Si "$*" > /dev/null 2>&1; then
echo "error: package '$*' is not installed" 1>&2;
return 1;
else
echo "error: package '$*' was not found" 1>&2;
return 1;
fi;
fi
}
pac-installed ()
{
if [[ $# -eq 0 ]]; then
echo -e "Usage: $FUNCNAME PKGS\n\ttest whether packages are installed" 1>&2;
return 1;
fi;
pacman -Q "$@" > /dev/null 2>&1
}
arrayunion ()
{
local full line=0;
full=$(arrayecho -d'
' "$@");
echo "$full" | while read first; do
((line++));
echo "$full" | for ((j=0; j<line-1; j++))
do
read second;
if [[ "$first" == "$second" ]]; then
return 1;
fi;
done;
if [[ $? -eq 0 ]]; then
echo "$first";
fi;
done
}
arrayecho ()
{
OPTIND=1;
local DELIM=" " opt delim f i;
while getopts "d:" opt; do
case "$opt" in
d)
DELIM="$OPTARG"
;;
esac;
done;
shift $((OPTIND-1));
for f in "$@";
do
for ((i=0; i<$(arraylen "$f"); i++))
do
eval echo -n "\"${delim}\${$f[$i]}\"";
delim="$DELIM";
done;
done;
echo
}
arraylen ()
{
[[ $# -eq 1 ]] || {
echo "$FUNCNAME: requires one argument" 1>&2;
return 2
};
eval echo "\"\${#$1[@]}\""
}Offline
The easier, by-hand, way is to do "pacman -Qi PACKAGE_NAME" and inspect the "Required By:" field. :-)
Offline
Thank, Profjim.
Offline
There is also the "whoneeds" script that was sucked into the pkgtools package, it works quite well.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
It's in git right now, but I was actually working on it the other day to see if I can get it ready with a new release.
[git] | [AURpkgs] | [arch-games]
Offline