Sunday, May 15, 2011

Using FreeBSD ports effectively.

When I first started with FreeBSD I wasted a lot of time.  I knew where I wanted to go, but not exactly how I wanted to get there.  One thing I did know was using the FreeBSD Ports Collection was definitely the way to go to install most software as it handled dependencies and lots of other issues automatically.

Occasionally, I would find myself installing programs with a huge list of dependencies; if any of these programs required configuration, the whole process would stop and ask you to configure it.  If you have a long list of dependencies, it might not be viable to sit and watch the console during the compilation of all of the ports as this could take hours depending on how much software is to be installed.  A switch for 'make' takes this problem into consideration and pre-configures nearly all dependencies before starting anything.

For example, if you were to install the 'www/apache22' web server and wanted to increase the possibility of an automated install, use the 'config-recursive' switch, like this:
# whereis apache22
apache22: /usr/ports/www/apache22
# cd /usr/ports/www/apache22
# make config-recursive install clean
This will go through the list of dependencies and bring up the 'make config' page for any that require tuning.  This can save a lot of time.

After you install anything via ports, run 'rehash' to make FreeBSD re-read the the files in the path so it knows that your new program is available.

A similar switch for the 'portupgrade' command is '-c'.  If you're updating the whole system and you want to pre-configure the updates try this:
# portupgrade -c -a
If you find that you no longer need a program installed and you want to ensure that no extraneous ports are left over in the system, remove it with 'pkg_deinstall' using the '-R' switch, like this:
# pkg_deinstall -R audio/amarok
It will uninstall 'amarok' and every dependent port for it that is not being used by another port.  If another program requires the same dependency 'pkg_deinstall' will not remove that dependency.

If you have a port that is affected by a security problem but you absolutely must install the port anyway, you can force it with the 'DISABLE_VULNERABILITIES=true' switch, like this:
# make DISABLE_VULNERABILITIES=true config-recursive install clean
Now the port affected by the security problem will not be blocked from install.

No comments:

Post a Comment