Shell script to uninstall ports with dependents

Before we begin, I seem to be getting a lot of people visiting this post when searching for “uninstall macports”. Read 2.5 Uninstall from the MacPorts Guide you want to uninstall MacPorts itself.

EDIT: steve k wrote in and opened my eyes to:

sudo port uninstall --follow-dependents portname

So use that instead, and read on only if you like bash.

(I have another script that does the inverseā€”traverses up the dependency chain removing ‘leaf’ nodesā€”that is, ports with no further dependencies. Maybe I’ll make a new post on that oneā€”after making sure it’s also not already available as some hidden option. :p )
Continue reading