For Ubuntu Linux (and Mint), we have a powerful package manager called apt-get, which makes the installation, uninstallation and management of packages much easier. Sadly, for MacOS users, we don’t have that powerful tool. The appearance of MacPorts, an open source package manager for MacOS, has changed the way we install and manage our packages. With the help of MacPorts, MacOS users can now quickly install, keep track of the changes, update and maintain many open-source applications. You can even export all your installed packages and then let MacPorts automatically reinstall them for you when you have your computer reinstalled or when you migrate to another system.
The easiest way to install MacPorts is to download the .pkg installer here. Select the installer corresponding to your current OS. Alternatively, you can build it from source. For more detail, please visit this link.
After finishing the installation, you should consider updating MacPorts. Fortunately, MacPorts has the built-in feature for selfupdating. Everything you need to do is to execute this command
Now you can enjoy one of the most powerful package manager on MacOS. :)
To list all available ports, type this command (it takes a few minutes to load)
To search for a port, type:
To get info of a port, type:
To install a port, execute this command. The installed apps are usually put in /Application/MacPorts
To delete an installed package, type
To upgrade an installed port, type
To upgrade all outdated ports, type:
To list all installed packages, type:
So those are some basic commands for MacPorts. Actually, the most inportant ones are install, uninstall and upgrade. Now you can use MacPorts to install many open source application like VLC, Emacs, Handbrake, iTerm, VirtualBox, Qt,…
Since Macports is a package manager, it has the built-in support to make the migration process become easier. You don’t have to remember which packages you’ve installed. Everything you need is to export the installed packages list and bring it to the destination system where you want them to be reinstalled.
To export the list of installed ports, type:
The command above will write all the ports that you’ve have installed to myports.txt.
On the destination computer, you need to uninstall all packages to avoid conflict.
and then clean any partially-completed builds
After that run this command for MacPorts to automatically reinstalled all packages
It’s possible to have conflict during the installation process. If it happens, just delete the conflicting ports from myports.txt and run the script again. You may have to do this several times.