You are not logged in.
Hi all,
Imo there is no good way to manage installed optdepends yet in pacman.
Currently you can:
- install optdeps explicitly: they will become undetected 'orphans' if you remove the package that you installed it for.
(because they are not installed as 'dependencies', if you delete the 'parent' package the installed optdepends are not cleaned up)
- install them --asdeps: they appear to be orphans because you probably don't have a package that 'really' depends on it. Over time you might want to clean up your orphans and accidentially delete the wrong package if you don't exactly remember if/why you needed the package
This issue has been discussed a while ago ( http://www.nabble.com/%22explicit-depen … 40889.html ) but afaik there is no real solution yet in pacman/libalpm
Luckily, this is very easy to solve yourself, DIY style!
(Maybe someday, if I brush up my C skills I would send a patch for pacman, but for now this bash trick does the job just fine for me)
How? install --asdeps but keep track of the package and it's install reason/"parent" package separately,
use some convenient scripts that know about this to avoid mistakes.
~/.optdeps
#!/bin/bash
# specify the installed optdepends here, optdepend_${packagename/-/_}="<parent package>: install reason"
# example: optdepend_gtk2_perl='rxvt-unicode: to use the urxvt-tabbed'
2 bash functions:
#!/bin/bash
install_optdepend () {
if [ -z "$2" ]
then
echo "\$1: package name to install as optdep, \$2: 'parent' package" >&2
return 2
fi
optdep=$1
parent=$2
if ! data=`pacman -Qi $parent`
then
echo "Seems like you don't have parent package $parent installed" >&2
return 3
elif ! data=`grep " $optdep: " <<< "$data"`
then
echo "Seems like $parent does not have $optdep as an optdep" >&2
return 4
fi
str=`sed "s/.* $optdep: //" <<< "$data"`
[ "$optdep" = gtk-perl ] && optdep=gtk2-perl #fix for bad field in rxvt-unicode
entry=optdepend_${optdep/-/_}"='$parent: $str'"
echo "Installing optdep $optdep for parent $parent ..."
if ! sudo pacman -S $optdep --asdeps
then
echo "Could not install $optdep. aborting."
return 5
fi
# example: optdepend_gtk2_perl="rxvt-unicode: used for tabs"
echo "Adding entry '$entry' to ~/.optdeps ..."
if echo "$entry" >> ~/.optdeps
then
echo "All done!"
return 0
else
echo "Something went wrong" >&2
return 6
fi
}
clean_orphans () {
source ~/.optdeps
for i in `pacman -Qdt | awk '{print $1}'`
do
var=optdepend_${i/-/_}
[ -n "${!var}" ] && echo "***** WARNING: 'orphan $i' is probably on OPTDEPEND: ${!var} ******"
[ -z "${!var}" ] && echo "-- orphan $1. Not registered as on optdepend --"
pacman -Qi $i
[ -n "${!var}" ] && echo "Remove this likely installed optdepend?"
[ -z "${!var}" ] && echo "Remove this likely real orphan?"
REPLY=
read && [ "$REPLY" == y ] && sudo pacman -R $i
done
}
So, all optdepends that you install this way are stored in ~/.optdeps along with their 'parent' and install reason taken from the optdepend entry from the parent. You can do this manually or use the install_optdepend function to do it automatically.
If you then go through your orhans with pacman -Qdt you can see which ones are installed optdeps by using the ~/.optdeps file.
clean_orphans is a function to go through each orphan, tells you what it knows, and asks you if you want to remove it.
Currently automatic cleanup of ~/.optdeps is not implemented (eg when you remove an optdep), but I don't mind doing that manually for now (or just keeping the entry for reference sake). Also, a function could be implemented so that when you remove a package, it checks for optdeps, checks the ~/.optdeps and asks you if you want to remove it or not. But that's not really needed Imo, the interactive orphan cleanup function does the job for me
What do you guys think?
Last edited by Dieter@be (2008-11-21 08:32:04)
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
I didn't really have a problem with this so far, but I really don't understand the way pacman handles optdepends either, so I'll probably give this a try. Thanks for this script!!
Offline