Mac Ports Cheat Sheet

It’s worth reading the mac ports guide here, but here is my cut down cheat sheet of commands I actually use.

To install a port, e.g opencv

sudo port install opencv

To update ports definition list

sudo port selfupdate

Once, that’s finished you can update the outdated ports (this might take sometime depending on the number of updates)

sudo port upgrade outdated

or you can get a list of the outdated ports

port outdated

and upgraded them manually

sudo port upgrade opencv

This should also upgrade dependencies.

To get a list of installed ports

port installed

To search for a port, eg, PHP you could try

port search php

This will give you hundreds of port that mention PHP in their description. You can filter this, for example

port search --name --glob 'php*'

will return only the ports that start with php.

port info opencv

returns information about the opencv port (the lastest version, so watch out if your ports are out of date). A list of variants can be obtained with

port variants opencv

A port variant can be installed using the syntax:

sudo port install opencv +java

This installs the variant of opencv with java bindings. To see which variant is installed type:

port installed opencv

this lists the variant installed, plus the inactive versions of the library.

If a port fails to build it might be worth cleaning up first by running

sudo port clean opencv

and trying again.

To find out what and where port has installed files run

port contents opencv

To remove a port you use either of

sudo port uninstall opencv
sudo port uninstall --follow-dependents opencv

The second option removes the installed dependents as long as no other port is using them. If you don’t use the latter there will be a number of ports left on your system that you didn’t manually install. These are known as leaves and you can list or remove them with

port echo leaves
sudo port uninstall leaves

You might need to repeat the process since uninstalling leaves may create new leaves!

Port will also leave the outdated ports on your system. To remove them use

sudo port uninstall inactive

 

Leave a Reply

Your email address will not be published. Required fields are marked *