Installing Packages


Now, you need to go out and find some software to install. The first step is to find out what's available. Just about all the software available for Linux is also available for FreeBSDnearly every piece of open-source software in the world has been made into a native FreeBSD port, and even closed-source software distributed in binary form for Linux can be installed as well (because binary compatibility allows you to do anything up to and including playing back audio/video using Linux software).

Installing from Sysinstall

If you have the ports collection installed, you can see a categorized view of all the available software by going to /usr/ports and just looking around at the filesystem. Each subdirectory represents a package category of the same name, and each port directory inside it represents a software package that might be available for installation using the command-line tools. Your old friend Sysinstall, however, offers an even more direct interface.

Note

Not every port has a corresponding package available. If you try to install a package whose name you found in the ports directory, and it's not available in Sysinstall's menus, you'll want to build it from the ports instead. Skip ahead to "The FreeBSD Ports Tree" for more information.


From the main menu of the Sysinstall program, choose Configure and then select Packages. The Packages menu is shown in Figure 16.1.

Figure 16.1. The Packages menu in the Sysinstall program.


From there, choose CD/DVD as the installation media if you have your FreeBSD DVD handy; if not, and you're on the Net, choose FTP.

After you get the package list from whichever medium you choose, you are presented with a menu like the one shown in Figure 16.2. Scroll up and down to see the various categories, and press Enter to go into each one.

Figure 16.2. Browsing a category in the Packages menu.


A Note on Version Branches

We won't be covering FreeBSD's version-branching system until Chapter 19, "Keeping Up to Date with FreeBSD." For now, however, you should become familiar with at least a few important bits of terminology that are crucial to the proper operation of the packages and ports.

In the Options section of the Sysinstall program is a field to set the release name you'll be working with. Chances are you will be running a "release" version of FreeBSD (these are the versions that come on CDs). If so, the Release Name field will be set correctly for the version you're running (for example, 6.1-RELEASE for the version supplied with this book). However, if you've upgraded your system to an interim point on either the -STABLE or the -CURRENT branch, this field may be set to #.#-STABLE, where the hash marks (#) stand for major and minor version numbers. That value won't work when you try to open the Packages menu because it tries to access a directory on the server whose name is based on the version number pulled in directly from the output of the uname command, which reports information on the kernel version. The corresponding directory for the packages that match your system's version doesn't necessarily have the same name as what's specified in the Release Name field.

Go to ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/ (and then into your appropriate platform subdirectory) to see the available release directories. If your version is 6.1-RELEASE, the release directory you want is i386/6.1-RELEASE. If your system has been rebuilt from STABLE sources, choose the most recent RELEASE directory.


At the bottom of the screen shown in Figure 16.2, you'll see the one-line "short description" of each package. When you see the package you want, press the spacebar to mark it with an x. Select Cancel (press the right arrow) to exit from the category. You can browse through all the available categories this way until you've selected a long list of the packages you want; when you're done, tab to the Install button at the bottom of the screen to install them all in one fell swoop.

Note

Note that selecting Install is the only way to exit from the Package menus. If you don't select any packages for installation, you still need to select Install (and accept its dialog about there being nothing to install) in order to exit to the main Sysinstall menu.


The program now goes through the list and downloads each package, one by one, unpacking it into /usr/tmp and installing it using the pkg_add program, the commandline element to this phase of the FreeBSD package manager (which you can also use independently of Sysinstall). If a package has any dependencies, Sysinstall first finds and installs them and then returns to installing the packages you selected.

Exit from Sysinstall using the Exit Install option at the bottom of the screen. Your new packages are now installedthat's really all there is to it. The documentation (man pages) is all ready to use, config files are in /usr/local/etc, and the binaries are in /usr/local/bin. Type rehash to refresh the available programs that your current shell knows about (or log out and back in), and you'll be able to use the software.

As you learned in Chapter 14, some programs need to be configured before they can be used. Go into /usr/local/etc and check for a config file (usually of the style program_name.conf or program_name.cfg, or at least containing the program name). If the file has .sample at the end, you need to copy the sample file to a real, "live" config file (without the .sample extension) and perform some additional modifications before the program can use it. Open the file with your favorite text editor and do what needs to be done, as described in comments in the file itself or in the man page for the program. After you have configured the first file, check inside the rc.d subdirectory for similarly named startup files and deal with them in the same way if necessary.

Using pkg_add

Few options are available for the actual installation process in FreeBSD. Because executables, config files, and libraries are all kept in a standard centralized location, no dialog asks where you want to install a program or offers you any of the custom installation options you get in the desktop OS world. These installation limitations are perfect examples of both the more "closed-box" approach of FreeBSD, as compared to that of Linux, and the centralized distribution model for all the open-source software available for the platform.

However, there are times when you need more control over a package than you can get within Sysinstall. Examples include packages that have interactive preinstallation scripts (in which you can set options specific to that package) and situations in which the automated installation in Sysinstall fails. For times such as these, you need the pkg_add tool; it's used in every package installation, whether it's called directly or run by Sysinstall.

The pkg_add tool is designed to operate on a .tbz or .tgz file you've already downloaded (from the per-release distribution directory described earlier) or on a remote file specified by its URL. For instance, the following two procedures are roughly equivalent:

[View full width]

# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/i386/6.0-RELEASE/packages/www/ webstone-2.5.tbz # pkg_add webstone-2.5.tbz


and

[View full width]

# pkg_add ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/i386/6.0-RELEASE/packages/www/ webstone-2.5.tbz


Of course, the latter method is much more convenient because not only does it eliminate the separate steps of downloading and installing the package, it also does all its work in /usr/tmp (or a similar temp directory) and cleans up after itself when it's done. The former method, however, allows you to store your source tarballs in a local directory (such as ~/tarballs) so you can reinstall your software from them later without downloading them again.

pkg_add also keeps track of dependencies as if you were using it through Sysinstall. If you use pkg_add to add a package that has dependencies, it will automatically download and install the dependencies before proceeding. This ensures that you'll have a fully functional program after it's done working.

Tip

Use pkg_add -nv to do a "dry run" install. This shows you the steps pkg_add would take during the installation, without actually doing anything.


Note

pkg_add warns you if the compiled package was built with a dependency on another package that you have installed, but your version is older than the one the package wants:

[View full width]

pkg_add: warning: package 'xorg-libraries-6.8.2' requires 'pkgconfig-0.17.2', but 'pkgconfig-0.15.0' is installed pkg_add: warning: package 'xorg-libraries-6.8.2' requires 'freetype2-2.1.10_1', but 'freetype2-2.1.5_1' is installed


If you receive warnings such as these, it's a good idea to upgrade the packages in question as soon as possible to avoid incompatibility issues.


An even more convenient way to install packages, one that does not involve your exploring through the FTP site at all, involves using the r option to pkg_add. This is the automated "remote fetching" feature, and it eliminates the need for you to know the current version number of the package you want, or even the version of your own operating system. The package manager will figure it out for you. Simply use the name of the package you want without the version number string, along with the r flag, and pkg_add will determine your platform type and release version and install the package in one step. Here's an example:

[View full width]

# pkg_add r webstone Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-release/Latest/webstone .tbz... Done.


Sometimes, a package installation finishes with a screen that gives you further instructions about how to complete the configuration. This is one benefit of installing packages from the command line rather than through Sysinstall. Another is that Sysinstall provides no feedback about the file size of any package, so you pretty much have to just let it download with no progress feedback other than data rate. If you used a browser to find the package in its FTP directory, you'll find the package size there and at least know how far you have to go when downloading.

Notes on Package Origins

The directory structure at the FreeBSD FTP site is such that each package is actually a symlink, so the file sizes aren't actually directly available if you reach them from the preceding URL. A little digging will get you the information, but it might not be worth your while.

Note that pkg_add does work on .tbz files grabbed from any location, not just the FreeBSD site. However, beware of files from "suspect" locations; adding packages is an act of trust, allowing whoever wrote the package to specify files to be placed in user-executable locations, possibly overwriting other files. (This is why regular users are generally restricted from installing packages and ports.) Viruses and Trojan horses are very uncommon in the UNIX world, but a conscientious administrator should have these potential threats in mind at all times, and especially when installing packages!

If you stick to Sysinstall, or at least to the .tbz files found at the FreeBSD FTP site, you can be assured that all the packages are approved for use and include an MD5 checksum to verify their authenticity, which you can usually do with the md5 tool:

# md5 webstone-2.5.tbz


You can compare the output string from this command to the contents of the checksum file, often provided along with the package, to make sure they match before installing it.


You can also specify multiple packages, run in verbose mode, and prevent pkg_add from running preinstallation or postinstallation scripts. You can even prevent it from recording that it has installed the package. These options and more can be found in the man pkg_add page.




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net