Installing Software on BSD

From Etel

Jump to: navigation, search

Contents

Title

Installing Software on FreeBSD, NetBSD or OpenBSD

Problem

Most of the Asterisk documentation is couched in terms of a Linux installation, but you prefer to run a true UNIX descendant such as FreeBSD, NetBSD or OpenBSD, so terms like rpm, apt and yum are not in your vocabulary.

Solution

Use the ports/packages or pkgsrc/packages mechanism.

Discussion

The original 'ports' mechanism was developed on FreeBSD by Jordan Hubbard. It has since gone on to evolve into slightly variant versions on FreeBSD, NetBSD and OpenBSD. The basic idea is to provide a standard means for installing, upgrading and removing software beyond what ships with the OS - third party software such as Asterisk, for example. The ports mechanism (or pkgsrc as NetBSD renamed their version) provides a standard format to store all the information needed to download a program in source form, verify the MD5 or other checksum, extract the source, patch it for the version of BSD, run the configure script (if any) with the correct arguments, build the program, create an installable package from it, install it, run the regression tests if any, and more. The packages mechanism looks after downloading, installing, upgrading, listing, and removing packages built by ports.

Most users therefore do not need to use ports, but can run the binary packages. Ports are for you if you prefer to look at the actual source code of the programs you use, or at least ensure that the source is available - one of the great promises of the open source movement! Ports are also for you if the particular piece of software you want isn't available as a package, either because it's just been added or upgraded in ports and you can't wait for the package, or because the package is not available due to licensing, or if you want to change the compiler options, or ... You get the picture.

One thing to note is that, while Asterisk and some of the channels are supported on BSD, there is no driver support for most telephony cards yet. It works nicely with SIP and IAX and ATAs, but not yet with locally-connected lines.

Suppose I have an OpenBSD system and I want to install Asterisk. If I prefer to build it from source, I can, on a vanilla system, just run this:

cd /usr/ports/telephony/asterisk
sudo make install

Some time later, I will have Asterisk installed (if /usr/ports is not installed, you need to get it from the distribution DVD or CD, or download it as described in the See Also section below). That is literally all I have to do, and I can start configuring Asterisk.

If I want to use binary packages, I have to find a download mirror, and I can use pkg_add, either directly:

sudo pkg_add -v ftp://rt.fm/pub/OpenBSD/snapshots/packages/i386/asterisk-1.2.3p4

The trick is knowing the exact version number to install - you might have to visit your mirror site to get a listing first. To optimize this, set the environment variable PKG_PATH to include the mirror directory:

export PKG_PATH="./:ftp://rt.fm/pub/OpenBSD/snapshots/packages/i386/"

(note the trailing '/' on each entry). Now to get the latest version installed you can again type

cd /usr/ports/telephony/asterisk
sudo make install

But this time, instead of downloading, it will fetch the package and install it.

To add a copy of the O'Reilly book Asterisk: The Future of Telephony to your Asterisk documentation, do this:

cd /usr/ports/books/AsteriskTFOT
sudo make install

See Also

  • FreeBSD Handbook, porting section
  • NetBSD pkgsrc
  • OpenBSD ports

Metadata

  • By: IanDarwin
  • Outline reference: Preparation
Personal tools