a life of coding

Wednesday, September 02, 2009

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, 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:
  1. find packages with no dependencies, which were not explicitly installed by the user
  2. if there are none, you are done
    1. add them to a list of packages to remove
    2. remove their map entry
    3. remove them wherever they appear as dependent on another package
  3. recurse!


2 Comments:

  • Very nice idea. You could extend it to be a "uninstall and prune" command; grab the graph before, uninstall, grab the graph after and prune away any new leaves.

    By Blogger Ben, At 9/12/09 6:01 PM  

  • I just learned today about the port port_cutleaves . It's designed to take care of this sort of problem...

    By Anonymous sampablokuper, At 2/17/10 9:40 PM  

Post a Comment



<$I18N$LinksToThisPost>:

Create a Link

<< Home