Force macports to upgrade all outdated ports

if you are a macports user you probably upgrade the ports you have in your machine with the command

port upgrade outdated

but sometimes some packages gets broken and can not be installed, leaving other macports packages that could be upgraded stuck at old versions. The only solution is to manually upgrade each one of them with port upgrade. The way I force the upgrade of all macports packages is just to list all outdated packages and then try to upgrade one by one with:

for l in `port outdated | awk '{print $1}'`  
do  
port upgrade $l  
done

this doesn’t stop packages from failing, but at least allows you to upgrade all macport packages that can be upgraded. The process will take time, and is a bit crude because it doesn’t take into consideration things like dependencies, but works and in the end I’ve found that sometimes it even solves some of the problems of broken packages. Give it a try.

Extra: After successful upgrades—and only if you don’t need the old versions that are still installed but not activated—you can just uninstall the unactivated macports with

port uninstall inactive

(All commands should be issued under superuser permissions either with sudo prefixed or using sudo -i)