Cleaning MacPorts Dependencies
Sometimes MacPorts gets a little carried away with dependencies. I recently tried installing mercurial on 10.6, and found MacPorts yak shaving various X11 libraries. After deciding that this yak didn't need to be shaved, I cancelled the install and downloaded the Mac OS X mercurial installer (index).
Unfortunately, canceling a port install leaves behind extra packages. Which packages? Good question. I knew that I had asked for some packages (libidl, graphviz, bash-completion), but I didn't know which packages were only installed as dependencies of my half completed mercurial request. Given a package,
Given a map of package names to a list of packages dependent on that package:
Unfortunately, canceling a port install leaves behind extra packages. Which packages? Good question. I knew that I had asked for some packages (libidl, graphviz, bash-completion), but I didn't know which packages were only installed as dependencies of my half completed mercurial request. Given a package,
port can find the packages that are dependent on it. Hmm, this sounds like some programming homework...Given a map of package names to a list of packages dependent on that package:
- find packages with no dependencies, which were not explicitly installed by the user
- if there are none, you are done
- add them to a list of packages to remove
- remove their map entry
- remove them wherever they appear as dependent on another package
- recurse!
