FreeBSD packages vs ports
This post is aimed at bringing a practical understanding into the usage and difference between ports and packages. Sometimes big descriptive definitions make things sound so much more complex.
Source vs Binary
Source (source code) is human readable files telling the application and computer how to interact with each other and what to do. Binary on the other hand is the same application that has been compiled, so it is computer readable but not human readable.
See it as a cake
Source is the ingredients and you can still decide what you want to add or remove. Binary is an already baked cake.
- ports = source (ingredients)
- packages = binary (pre-baked cake)
Lets look at how it install firefox
Installing a port
cd /usr/ports/www/firefox3; \make config; \make install clean; \rehash; \cd -
Installing a binary
pkg_add -r firefox3
So why configure, compile and install an application when you can just add the binary? Here we get back to the cake example. Take for instance lighttpd (a web server like apache / IIS). To enable mysql support on it you need to compile it with mysql (this is where the make config comes in). Whereas with firefox, chances are very slim that you need to compile it with specific parameters and you would rather package install it. As you go along you will find what works and does not work for you and your environment.
More on the structure
The FreeBSD ports directory is located in /usr/ports/ and well structured
The ports directory contains all the applications that has been ported (adapted to work with) to FreeBSD.
What is the package name for the port?
Rule of thumb: the same as the package name.
- port: /usr/ports/net/samba3
- package: samba3
When in doubt refer for www.freshports.org
This is not a detailed in-depth analysis of packages and ports, this is a basic on how to get a working example and to grasp the concept of how it works. Refer to the relevant man pages and documentations for a more detailed insight