Thursday, September 17, 2009

Tip: Introducing the PKGDIR environment variable on FreeBSD

Though I prefer using the ports tree to install applications on FreeBSD, the fact is that packages are way faster especially if your hardware is old or you just want to bring a test install online as fast as possible.

If you want to keep the downloaded packages, you need to set the PKGDIR environment variable pointing to the place where to store the downloaded .tbz files.

Here's how to set PKGDIR with the t/csh shell to /usr/ports/packages/All:
  • % su
  • # setenv PKGDIR /usr/ports/packages/All
  • # mkdir -p /usr/ports/packages/All
To download, store and install a package named foo:
  • # pkg_add -Kr foo
The -K switch informs pkg_add that you want to keep the downloaded package on the directory defined by PKGDIR.

Using packages is all fine and dandy, however not all applications in the ports tree are available as packages due to licensing issues.

I found out that after setting the PKGDIR, every single port that I tried to install failed with the same error: "Missing pkg-descr".

To fix the problem simply unset the PKGDIR environment variable like so:
  • # unsetenv PKGDIR
And voilá! You can now use the best of both worlds.

No comments: