Chapter 9. FreeBSD Packages

Chapter 8 introduced you to the PBI system of installing and managing software. While this is the preferred way to handle software on your PC-BSD system, it is not the only method available to you. This chapter will introduce you to FreeBSD packages, the second easiest way to manage software on your PC-BSD system. Chapter 9 will introduce you to FreeBSD ports, which allow advanced users to customize their software installations.

Warning

Chapter 9 and Chapter 10 require you to use the command line to manage software. If you prefer to use a GUI or don't have the time right now to learn new commands, use the instructions in Chapter 8 to find, install, and manage your software. You can always come back to these chapters later when you have more time and want to advance your software management skills.

What Is the Ports Collection?

The Internet contains literally hundreds of thousands of free applications. Many can be found at free software websites such as Sourceforge.net (which hosts more than 200,000 applications); others, such as openoffice.org and gimp.org, have their own websites. Some are stable and well documented; others are buggy, and you have to guess how they work. With so much out there to choose from, how do you find the software you need and how do you know it will work on your PC-BSD system?

The FreeBSD Project maintains something known as the ports collection.[48] This is a large collection of software that has been "ported" for FreeBSD. In a nutshell, ported means that someone did a fair bit of work to make the necessary changes needed for the software to run on FreeBSD. If you're curious as to what is involved, the Porter's Handbook[49] contains the instructions for making a port. The person who makes the port is known as the port's maintainer.

To make sure that all the ports in the ports collection work, the FreeBSD Project uses a build farm known as pointyhat.[50] A build farm is a cluster of machines that constantly rebuilds the ports in the ports collection. This is important because an application that is known to work can sometimes stop working (for example, if a software library it uses changes). Sometimes an application that works on one version of FreeBSD won't work on a newer version of FreeBSD without some modification. Pointyhat will e-mail the maintainer if there is a problem with the port until the maintainer fixes the problem.

The FreeBSD Project is also concerned about software security. It maintains a database of known vulnerabilities, known as VuXML,[51] and provides tools you can use to determine if any of your installed software is vulnerable.

The ports collection is the collection of ported software. However, you have two choices in how you install an application from the collection. The first choice is to install the package. Think of a package as a command-line installer program that knows how to install the application, all its dependencies, and any documentation and configuration files associated with the application. The second choice is to compile (or build) the port yourself. This chapter concentrates on packages; Chapter 10 will show you how to compile a port.

What Is a Package?

Like a PBI, a FreeBSD package represents an application that has been pretested for you so that it can be easily installed and used on your PC-BSD system (remember, PC-BSD is really FreeBSD "under the hood"). Similar to a PBI, a package contains instructions to install everything it needs to work on your system. FreeBSD's package management system allows you to see if newer versions of the package are available and provides a way to upgrade or uninstall applications. While the end result is the same, in that both the PBI system and the FreeBSD package management system allow you to install and manage software, the commands you use to do so are different. The major difference is that the PBI system provides a graphical Software Manager, whereas the FreeBSD package system requires you to type commands at a command prompt.

Why Use Packages on PC-BSD?

If the PBI system provides a graphical Software Manager, why would you want to use a command-line system to install software? The most compelling reason is the sheer number of FreeBSD applications that are available. As of February, 2010, there are more than 21,000 applications in the FreeBSD ports collection, meaning that there is a very good chance that the application you are looking for is available as a package. It is also pretty cool that PC-BSD gives you the choice of how you install and maintain your software, rather than forcing you to use one software management system.

Finding Packages

The easiest way to find FreeBSD packages is to point a web browser to http://www.FreshPorts.org, as seen in Figure 1. FreshPorts provides an easy-to-use interface to the information available within the FreeBSD ports collection. If you're wondering what software is available to install on your FreeBSD or PC-BSD system, FreshPorts is the place to go!

FreshPorts website

Figure 9-1. FreshPorts website

If you use the Firefox web browser, you can access this website quickly using a FreshPorts search plugin available from http://www.searchplugins.net/pluginlist.aspx?q=FreshPorts&mode=title. While in Firefox, go to that website and click the I to install the plugin (see Figure 9-2).

Tip

There are two Is to choose from. The first one will use the default search engine icon, and the second one will install the Beastie icon. If you change your mind about which to install, use the Manage Search Engines menu in the Firefox search bar drop-down menu to remove the plugin.

Installing the FreshPorts Firefox plugin

Figure 9-2. Installing the FreshPorts Firefox plugin

A pop-up Add Search Engine message will ask if you want to Add this plugin. Check the box Start using it right away; then press Add. You can then click the drop-down arrow in the search engine bar in the upper-right corner of Firefox to select the FreshPorts search utility, as seen in Figure 9-3. To search for an application using the plugin, simply type the name of the software into the FreshPorts search bar and it will show you the results from FreshPorts.org.

Firefox search plugin menu showing FreshPorts search plugin

Figure 9-3. Firefox search plugin menu showing FreshPorts search plugin

Tip

If you don't use the Firefox web browser, you can still search for software using the Search utility at the FreshPorts.org website.

FreshPorts provides a lot of useful information that can assist you in deciding which software to install. If you have no idea where to start and want to get a feel for what software is available, click the Categories hyperlink, located about halfway down the page in the right frame. This will show you a view of all available software divided into categories, as seen in Figure 9-4. Click a category to browse all its applications.

Using FreshPorts to browse software categories

Figure 9-4. Using FreshPorts to browse software categories

Let's take a closer look at the type of information that is available for a port within the ports collection. Figure 9-5 shows the results from a FreshPorts search for the phrase "dillo".

Search results for "dillo"

Figure 9-5. Search results for "dillo"

From the output, you can see that dillo is "a fast, small graphical Web browser" and that there are three versions available within the ports collection. Version 0.8.6_4 has a skull icon, indicating that it has had a known security vulnerability in VuXML. If that vulnerability has not been fixed yet, a package will not be available. You can click the skull icon to read details about the vulnerability (click the dillo hyperlink in the page that opens up).

Each FreshPorts entry contains the following information about the software:

Name:

The name of the application, followed by its version number and category. Click the magnifier icon to determine whether any other software depends upon this application.

Maintained by:

The e-mail address of the person responsible for making sure the software works on FreeBSD. Click the magnifier icon to see what other applications they are responsible for.

CVSWeb:

Contains the complete history of the application since it first became available within the FreeBSD ports collection. CVSWeb will be discussed in more detail in Chapter 10.

Sources:

Shows the original source location of the software that was ported, as well as the checksums and size of the software source. Note that this is for informational purposes because the package system will fetch the software for you (that is, you shouldn't download it yourself).

Main Web Site:

This is the primary site of the application. This website often contains screenshots, documentation, and more information about the software.

Distfiles Availability:

Shows the availability of the software source for that category. This will be discussed in more detail in Chapter 10.

PortsMon:

Shows a report on the status of the FreeBSD port. See http://portsmon.freebsd.org for more information about the PortsMon project.

Installation instructions:

Provides the commands used to install the software using the FreeBSD ports system (discussed in Chapter 10) and the FreeBSD packages system (discussed in the "Installing a Package" section of this chapter).

In addition to the information about each port, the FreshPorts website contains lots of other useful information. The Latest Vulnerabilities section (in the right frame) can be used to browse through software with known existing security vulnerabilities. The Ports section contains hyperlinks to the software categories, the list of deleted ports, and the FreshPorts RSS newsfeeds.

The Statistics section contains graphs; counts for the total number of ported applications; and the number of broken, deprecated, and vulnerable applications. It also contains hyperlinks to lists of software added within the last 24 or 48 hours, 7 days, fortnight, and month. The FAQ in the This Site section includes explanations of packages and ports and descriptions of all the icons used on the website.

Ports Console

Beginning with version 8, PC-BSD provides a Ports Console utility to use when installing FreeBSD packages. An icon for this utility can be found on the desktop. It is also available in Kickoff

Ports Console

Tip

Curious power users can read the underlying shell script that sets up the environment for Ports Console in /PCBSD/portjail/portjail.sh.

If you have ever installed packages before on a FreeBSD system, you know that there are several pkg_* commands that are used to manage FreeBSD packages. You will use the same commands on a PC-BSD system. Never use any pkg_* command directly from a PC-BSD command prompt! Instead, always use these commands within PC-BSD's Ports Console tool.

Warning

Just in case you missed the warning in the preceding paragraph, you really don't want to use any commands that start with pkg_ outside of the Ports Console on a PC-BSD system. Ports Console ensures that the packages you install and manage don't interfere with the software already installed with the PC-BSD operating system.

Ports Console provides a safe environment for installing and managing FreeBSD packages. It does so by creating a jail[52] that separates the applications you install from the PC-BSD operating system. This means that you can install, update, and uninstall all the FreeBSD packages you like, without worrying about accidentally deleting applications that are needed by the PC-BSD operating system. This separation also means that Software Manager (described in detail in Chapter 8) has no idea which FreeBSD packages you have installed. FreeBSD packages will not show up in Software Manager's Installed Software tab and Update Manager will not notify you if new versions of your installed FreeBSD packages become available. As you go through this chapter, you'll learn how to use the command-line tools to manage your packages—meaning you can still manage your installed packages; you just won't be doing it with Software Manager.

When you start Ports Console, it looks like any other Konsole prompt. In reality, you have connected to a jail. Take a look at the difference between Figure 9-6 and Figure 9-7.

Listing of the / directory in Ports Console

Figure 9-6. Listing of the / directory in Ports Console

Listing of the / directory in Konsole

Figure 9-7. Listing of the / directory in Konsole

Notice that the Ports Console is missing the /PCBSD directory, which contains programs used to maintain the operating system, and the /Programs directory, which contains the software installed using the PBI system. You will see even more of a difference if you try the pkg_info command, as demonstrated in Figure 9-8 and Figure 9-9. (Yes, I know I told you never to run a pkg_* command outside of Ports Console—we'll do it just this once with a view-only command to demonstrate the difference.)

pkg_info output in Ports Console before installing any FreeBSD packages

Figure 9-8. pkg_info output in Ports Console before installing any FreeBSD packages

pkg_info output in Konsole on a default installation of PC-BSD

Figure 9-9. pkg_info output in Konsole on a default installation of PC-BSD

The pkg_info command is used to view which non-PBI applications (e.g., FreeBSD packages) are installed. Notice that Ports Console indicates that no packages are installed because we haven't installed any yet. However, if you press your spacebar to scroll through the output of pkg_info within Konsole, you'll see that hundreds of applications were installed with PC-BSD. These are the applications you don't want to mess up. This is why you use Ports Console to maintain that separation between whatever software you're playing with and the software that PC-BSD needs to keep your system humming happily along.

Installing a Package

Okay, now that we're in Ports Console, how do we add an application? Let's return to the dillo example we saw at FreshPorts in Figure 9-5. FreshPorts indicates that you can install dillo2 (version 2.1.2_1) using the command pkg_add -r dillo2 (the -r means to fetch the remote package from the FreeBSD ports collection on the Internet). Double-check that you're in Ports Console (the title of your window should say portjail: csh) and that you are connected to the Internet. Become the superuser with the su command and type the pkg_add command, as seen in Figure 9-10. Note that the title bar at the top of the screen has changed to portjail: pkg_add, indicating that the package is being fetched. The informational messages in the Ports console screen let you know what is happening with the installation.

Installing the dillo2 package using Ports Console

Figure 9-10. Installing the dillo2 package using Ports Console

When the installation is complete, you will receive your prompt back.

You probably noticed that dillo requires a lot of additional software, known as dependencies, to install and run. pkg_add found and installed all these dependencies for you. This "just works," thanks to the hard work of the maintainer of this port. If you ever want to know who to thank for making a favorite software application available for your system, check the port's Maintainer section at FreshPorts. Send a thank you e-mail or buy them their beverage of choice if you ever meet them in person to let them know that you appreciate their effort.

If you now repeat the pkg_info command, you'll get a listing of all the software that was installed, as seen in Figure 9-11.

Viewing the software that was installed with dillo2

Figure 9-11. Viewing the software that was installed with dillo2

Determining what was Installed

Now that you have an installed application, you'll want to use it. pkg_info can be used to determine the path to the application. Use the -Lx switch to receive a list of what was installed, and filter your search using | grep bin. This tells pkg_info that you're interested only in the path to the binary (another name for the application's executable). The output indicates that this package installed three binaries, as seen in Figure 9-12.

Using pkg_info to find the location of the dillo2 binary

Figure 9-12. Using pkg_info to find the location of the dillo2 binary

Tip

Note that I asked pkg_info about dillo, not dillo2. The x in -Lx tells pkg_info to look for a package with the specified name (in this case, dillo). By not including the number, pkg_info will search for all versions of dillo and will let me know if multiple versions of dillo are installed.

It's a good bet that dillo, located in the /usr/local/bin directory is the executable you are looking for. You can double-check this with the whatis command. Note that in this example, the original creator of the dillo application (not the port maintainer) has not created any documentation (man pages) for the dpid or dpidc applications because the whatis command can't find anything appropriate. To see if any documentation was installed at all, I filtered the pkg_info output for the word dpid. The results show only the two binaries and a configuration file (config files live in a path containing /etc/). Looks like I'll have to go to the dillo website to see if there is any information at all about these binaries.

So, how do you start the dillo web browser? The short answer is to type dillo and press Enter. But take note of the longer answer:

  • Type exit to leave the superuser account. Remember that you install applications as the superuser but run them as your regular user account.

  • Once you are back to your regular user account, type rehash. If you don't, your shell doesn't know that you've just installed a new application, meaning that it won't find it and will give you a "command not found" error message.

  • Occasionally, a binary will be installed outside of the path your shell searches when it is looking for an application, so it can start it for you. If this happens, you have to type the full path to the binary rather than just the binary name. If you're not sure what your path is, type $PATH to view it.

  • Always run the application from Ports Console.

This last point is a biggie on a PC-BSD system. Because FreeBSD packages are installed into their own jail, they are available only from within the jail. This means that they can be started only within Ports Console and, for example, can't be added to the Kickoff menu. If you find yourself installing FreeBSD packages because the software you need isn't available as a PBI, it probably means that there should be a PBI for that software. If you're a power user, consider making the PBI yourself using the instructions in Chapter 14. If you're not confident enough to tackle creating a PBI, see Chapter 11 to learn how to interact with the PC-BSD community to see if someone else can create the PBI.

What to Do if Something Fails

Packages usually work flawlessly by using the instructions in the previous section. But occasionally something goes wrong. Sometimes pkg_add stops with a message saying that it can't fetch the package. Sometimes pkg_add complains that it can't find a dependency and refuses to finish the installation without it. Sometimes the package installs, but you get an error message when you try to run the application.

If pkg_add tells you it can't fetch the package, double-check that you are the superuser and that the pkg_add command FreshPorts told you to use was typed correctly into Ports Console. If you see a typo, fix it and try again. If it still won't fetch, double-check that you're connected to the Internet by pinging a website name. If it still won't fetch or still refuses to install or run, you'll have to do a bit of research to see what is going wrong.

Go back to that port's entry in FreshPorts. Does it have a skull icon or a message indicating that it is broken, forbidden, or restricted? If so, there probably isn't a package available. If you really want that version of the software, consider trying to build its port instead. Otherwise, try another version of the port or another application that provides similar functionality.

You can also browse the FreeBSD ports mailing list archives[53] to see if other users are experiencing the same problem. If you want to discuss the error on that mailing list, be sure to read the Frequently Asked Questions About The FreeBSD Mailing Lists[54] document first so that your e-mail contains all the information needed to get a useful response from the mailing list.

Updating Packages

Before you can update a package, you have to be aware that there is a newer version to update to. This section will show you how to create a customized watch list. We will then show you how to update to the newer version.

Automatic Notifications with FreshPorts

While Update Manager won't tell you when newer versions of FreeBSD packages become available, you can configure FreshPorts to send you an e-mail when changes are made to your installed ports.

To do so, you'll have to first create an account with FreshPorts. Once you have activated your account and are logged in, a Watch Lists section will appear in the right frame of the FreshPorts website. Click the Upload hyperlink, which will open the page seen in Figure 9-13.

Creating a FreshPorts Watch List to be notified of changes to your installed ports

Figure 9-13. Creating a FreshPorts Watch List to be notified of changes to your installed ports

From within Ports Console, type pkg_info -qoa|more. This will create a list of the ports you have installed. Depending on what you have installed, this list may be several pages long. Cut/paste the list of ports you see in Ports Console into the Paste box seen in Figure 9-13. Then, return to Ports Console and press the spacebar to go to the next page so you can copy/paste its ports. Repeat until you get your prompt back in Ports Console. When finished, double-check that your pasted list contains only ports (e.g., not the word More); then click the Upload button. You should receive a message that your watch list has been updated. You can then configure how often you want to be notified by going back to Watch Lists

Creating a FreshPorts Watch List to be notified of changes to your installed ports
Configuring how often to be notified of changes to your installed ports

Figure 9-14. Configuring how often to be notified of changes to your installed ports

Check the box next to Watch List Notification. If you don't want to receive a daily e-mail, click Day to choose another selection from the drop-down menu. When finished, press the update button at the bottom of the page. You'll now receive an e-mail regarding any changes to your ports at the frequency that you configured.

Tip

Don't forget to update your watch list whenever you add new packages. You can choose to replace or append (add to) your list.

Performing the Upgrade

The easiest way to upgrade to a newer version of a package is to remove the old one first (see the next section, "Removing a Package"); then use pkg_add to install the new version.

Power users can also use the portupgrade application to upgrade all or some of their FreeBSD software at once. portupgrade is discussed in detail in Chapter 10.

Removing a Package

While pkg_add is used to install (add) FreeBSD software, pkg_delete is used to uninstall (delete) FreeBSD software. Figure 9-15 shows an example of uninstalling the dillo package installed earlier. Note that this command is run within Ports Console and that you have to become superuser in order to uninstall a package. Again, the -x indicates that you have not given the version number of the port, just its name. pkg_delete will remove any software containing the name you specify—in this example, any software containing "dillo".

Using Ports Console and the pkg_delete command to uninstall the dillo package

Figure 9-15. Using Ports Console and the pkg_delete command to uninstall the dillo package

In this example, pkg_delete didn't have any informational messages when it removed the dillo package. Sometimes you will see informational messages when you delete a package. You can verify that the package did uninstall by running pkg_info, as seen in Figure 9-15.

pkg_delete will not let you delete a package if another application needs it. Figure 9-16 shows an example of this. In this example, dillo is still installed and I tried to uninstall the wget package that installed with the dillo package as a dependency.

pkg_delete will not let you uninstall software needed by another application

Figure 9-16. pkg_delete will not let you uninstall software needed by another application

If you receive an error message that "no packages match pattern(s)", double-check that you don't have a typo in your pkg_delete command. If the command looks good, use pkg_info to double-check that the package you are trying to uninstall is indeed installed.

Summary

This chapter introduced you to the FreeBSD ports collection and demonstrated how to work with FreeBSD packages. While FreeBSD packages are fairly easy to work with, they do require you to use command-line utilities and to occasionally deal with error messages. The Ports Console provided on your PC-BSD system means that you can experiment with FreeBSD packages without worrying about messing up the software that came with your operating system.

The next chapter is definitely for power users as it will show you how to build your own customized applications. If that sounds like fun, read on! If it sounds a bit intimidating, skip to Chapter 11, in which we will introduce you to the PC-BSD community.



[48] See http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports.html for more details.

[49] http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/

[50] http://pointyhat.freebsd.org

[51] http://www.vuxml.org/

[52] Wikipedia provides a good introduction and references to FreeBSD jails http://en.wikipedia.org/wiki/FreeBSD_jail.

[53] http://lists.freebsd.org/pipermail/freebsd-ports/

[54] http://www.freebsd.org/doc/en_US.ISO8859-1/articles/mailing-list-faq/article.html

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset