Packages and Ports
When we need to install some new software in FreeBSD , most always we use the previously discussed pkg_add -r package command.
The pkg_add -r part, means that FreeBSD will look at the FreeBSD servers for the package you are looking for and install it along with all the dependencies (required packages). A package is basically pre-compiled software that has been sufficiently tested and is considered safe and ready to be used by everyday users. 'Pre-compiled' simply means that somebody has taken the source of the software, compiled it in their computer, put it together nicely ('packaged') and published it online. At the time of compilation, the most widely accepted 'default' options were chosen. Those are good for most people but there come times when you need something more customized to fit your needs.
This is where the Ports section comes in.
Ports are simply put, software in source form (i.e. 'NOT' compiled) that FreeBSD downloads for you AND compiles along with any options you have provided. The disadvantages? It takes a lot more time in comparison to the package system, specially when you need to compile something in a Virtual Machine where the speed of the system is relatively slower than an installation on real hardware due to the Virtualization required. Also, in my experience I have found that ports can be broken from time to time, and it's no fun waiting 15 minutes for something to install only to come up with an obscure error explaining how xyz library is missing etc.
To summarize:
Packages – Advantages:
- Fast Installation
- No special knowledge required
Packages - Disadvantages:
- May contain malicious content
- Harder to customize (depending on what you need this may a good or bad thing)
Ports – Advantages:
- You can compile software to meet your needs (customize, or compile for your processor architecture)
Ports - Disadvantages:
- Slow. If you need to install Apache from source for example, depending on your hardware it might take you anything up to 15 minutes.
Conclusion:
As long as you don't download packages from obscure websites (read: warez/illegal/hacking etc) you should be fine. Use ports only when you know for a fact that you do need customization, or something that simply doesn't exist in package form.
Links of interest:
FreeBSD Handbook - Using Packages
FreeBSD Handbook - Using Ports
In a future article we'll see how much fun Ports can be!