Ports and Packages are the ways in which you install software onto a FreeBSD system. The third way is simply to obtain the source code and build from that - perfectly possible but slow, sometimes untidy, and lots of hard work, so only to be endured for certain vital components!
Packages - the command 'pkg_add -r mypackage' will download a pre-compiled version of mypackage and install it on the system. It really is that simple.
Ports are more interesting. The ports directory for your package, /usr/ports/allsortsofstuff/mypackage, contains everything you need to build the software from source except the source code itself. The routine is this:-
cd /usr/ports/allsortsofstuff/mypackage
make WITH_GTK2=yes install clean
The system will then download the source, compile it, install the necessary files in the right places, and clean out the working directory.
While we are on ports, here are some useful commands for port administration.
portsnap fetch update
pkgdb -F
portversion is even better for this purpose.
pkg_version -L =
portupgrade emacs
portupgrade -akOP
Be warned - this can take a LONG time, more than a day, if you haven't kept the system up to date.
Because of FreeBSD's very clear distinction between the base system and the added ports, it is easy (though avery slow process) to wipe off all user application and re-build. Portmaster is the tool to use.
From 'man portmaster'
Now look at the list you generated in the first step and install the root and leaf ports that you want to have again. The trunk and branch ports are dependencies, and will automatically be installed as needed. You probably want to use the -D option for the installations and then run —clean-distfiles[-all] again when you are done. You might also want to consider using the —force-config option when installing the new ports.