Using Packages


Packages are precompiled software for a particular version and architecture of OpenBSD. We're going to discuss using packages first, as they're generally easier and faster to use than ports. Once you have a grip on packages, we'll proceed to ports. Many of the tools that can be used for packages also work on ports.

Almost every OpenBSD port is available as a package. Some pieces of software cannot be redistributed without various restrictions, so they are only available as ports. Packages are available on the OpenBSD CD-ROM set and via FTP.

Package Files

Each package is available as a single file named after the port it is found in, a version number, and a ".tgz" extension. For example, the windowmaker0.80.1.tgz port is from the port named "windowmaker," version 0.80.1. A quick search of /usr/ports/INDEX will show that this is a package prepared from the port /usr/ports/x11/windowmaker.

To install a standalone package, all you need is the package file. You can get the package file from a CD-ROM, from an FTP site, or from anyone who makes it available over the Internet. (The last creates definite trust issues, however!) If your package depends on other packages, you'll need to install those required packages as well. If your packages are all available at the same location, the package installation process will handle these dependencies automatically.

Installing Packages

Once you have your package file, use pkg_add(1) to extract the software and add it to your system. For example, one of the first pieces of software I install on any computer I manage is the emacs text-processing package.

 # pkg_add emacs-21.2.tgz # 

Package installations usually run silently, although you'll occasionally see messages from the package offering advice or instructions. Pay attention to these messages, and take whatever action they recommend.

If your package has library or program dependencies, it will automatically try to install those as well. It will refuse to install incomplete software. While emacs is a standalone program (arguably because it has all possible lesser programs integrated with it), other packages are not quite so simple. For example, the WindowMaker window manager requires several other programs to run correctly. If you download the WindowMaker package on its own and try to install it without the correct versions of the required packages, the install will fail.

 # pkg_add windowmaker-0.80.1.tgz pkg_add(windowmaker-0.80.1): add of dependency `libiconv-1.8' failed! pkg_add(windowmaker-0.80.1): add of dependency `libiconv-1.8' failed! pkg_add(windowmaker-0.80.1): add of dependency `libiconv-1.8' failed! pkg_add(windowmaker-0.80.1): add of dependency `libiconv-1.8' failed! pkg_add(windowmaker-0.80.1): add of dependency `gettext-0.10.40' failed! pkg_add(windowmaker-0.80.1): add of dependency `gettext-0.10.40' failed! pkg_add(windowmaker-0.80.1): add of dependency `libiconv-1.8' failed! # 

If I downloaded and tried to install libiconv-1.8 and gettext-0.10.40, I would have come across a variety of other programs that libiconv and gettext need. I didn't download these packages along with WindowMaker, and I don't have them already installed. pkg_add(1) will automatically install dependencies for packages, if it can find them. The simplest thing to do is install the packages from the CD-ROM or configure pkg_add(1) to use a FTP server. Let's look at both.

Installing from CD-ROM

If you have an OpenBSD CD-ROM set, you already have a fairly extensive set of packages. To use them, just mount the CD-ROM and read the package file. Read Chapter 15 for full details on mounting and unmounting removable media; if you're reading the chapters in order, just nod and smile for those bits.

 # mount /dev/cd0c /mnt # 

Your CD-ROM is now available under /mnt. Under the release directory, you should find a directory called "packages," with a subdirectory for each architecture on the CD-ROM. This directory contains a selection of precompiled packages for that release. For example, on the 3.2 CD-ROM /mnt/3.2/ packages/i386 contains 182 packages.

Installing WindowMaker from package on CD-ROM is quite simple, as packages for all of the required applications are present.

 # cd /mnt/3.2/packages/i386 # pkg_add windowmaker-0.80.1.tgz # 

That's it! WindowMaker and its dependencies are now installed and ready to configure and use.

Installing from FTP

OpenBSD has thousands of packages for each of its architectures, which would fill up many CD-ROM sets. The OpenBSD disks only contain the most popular packages. If you want to install a package that is less popular, you will need to grab it from an FTP site.

Your first step is to find an OpenBSD FTP server with the packages you want for the release and architecture you're running. The server you installed from is probably your best choice, unless you've found a faster mirror since you installed. Much like the CD-ROM, the "packages" directory is under the "release" directory, and each architecture has a subdirectory.

You could choose to download a package and all its dependencies, but it can be quite a bit of work figuring out which packages a piece of software depends on, and which packages those packages depend on, and so on. It's much better to simply give pkg_add the full location to the package, and let it figure out all of the dependencies for you.

Take note of the full URL to the package directory for your architecture. For example, if you're installing the windowmaker-0.80.1.tgz package from ftp5.usa.OpenBSD.org, the full URL path to the package directory is ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.2/packages/i386/. You can use this on the command line as part of the package filename, and pkg_add will automatically grab the required packages from the same location.

 # pkg_add ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.2/packages/i386/ windowmaker-0.80.1.tgz >>> ftp -o - ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.2/packages/i386/ windowmaker0.80.1.tgz >>> ftp -o - ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.2/packages/i386/gettext- 0.10.40.tgz ... # 

You can watch pkg_add recurse through all the dependencies and subsequently install each one in turn. This is a pain to type, however, and requires that you know the exact package name when you want to install the software. Most people only know that they want "WindowMaker," which happens to be installed as part of the windowmaker-0.80.1 package. You can get around this by installing the package directly from an FTP command prompt.

If you don't know the name of the package you want to install, you can install it from within FTP. This lets you find the name easily enough, but stops pkg_add from automatically installing dependencies. For example, here I've logged in to my preferred FTP server and have wandered down to the package directory for my architecture and checked for any packages beginning with the name "wind."

 ftp> ls wind* 229 Entering Extended Passive Mode (|||56722|) 150 Opening ASCII mode data connection for '/bin/ls'. -r--r--r--  1 anonftp  wheel  1583322 Oct 15 05:07 windowmaker-0.80.1.tgz -r--r--r--  1 anonftp  wheel   202966 Oct 15 05:07 windowmaker-extra-0.1.tgz -r--r--r--  1 anonftp  wheel   646971 Oct 15 05:07 windowmaker-lang-0.80.1.tgz 226 Transfer complete. ftp> 

The first one is my port, although the various WindowMaker add-ons might interest me once I have the main package installed. From within the FTP client, I can download the package and direct it straight to a command.

 ftp> get windowmaker-0.80.1.tgz "| pkg_add -v -" 

This dumps the download straight to pkg_add(1). Unfortunately, because pkg_add just sees the package coming in from standard input, it doesn't know where to find the dependencies. You'll see it start to choke almost immediately on the libiconv package.

 local: | pkg_add -v - remote: windowmaker-0.80.1.tgz 229 Entering Extended Passive Mode (|||49334|) 150 Opening BINARY mode data connection for 'windowmaker-0.80.1.tgz' (1583322 bytes). Requested space: 400000 bytes, free space: 979604480 bytes in /var/tmp/ instmp.MSNlPE8498 pkg: Handling dependencies for windowmaker-0.80.1   checking libiconv-* (libiconv-1.8) -> Not found ... 

At this point, you'll see quite a bit of output complaining about missing packages. You can download those packages separately, install them via FTP, or any combination thereof. You might well find installing the software via ports simpler.

Note

Each time you attempt to install a package from within FTP and the installation fails, the entire package is downloaded, tested, and deleted. In my opinion, if you plan to install a package with many dependencies you're better off downloading the packages to your local hard drive and attempting to install from there rather than trying to install directly from within the FTP client. It might not be as nifty, but it will save bandwidth and time.

I tend to use an initial FTP query with a Web browser to identify the complete package name and then give pkg_add(1) the full URL to the package and let it sort out the dependencies. You may find some other method more suitable for your circumstances.

Installing from FTP is not quite as secure as installing from CD-ROM. While the OpenBSD release team has verified all the packages on the CD-ROM set, a malicious hacker could have tampered with a random FTP server. You could be installing Trojan horses, backdoors, or worse. Booby-trapped source code has happened often enough to be a realistic concern.

Package Architectures

Every architecture has its own package files. Packages built for one architecture will not run on a different architecture. If you have a package file for WindowMaker on the Alpha platform and install it on i386 hardware, the install process will work. The program will not run, mind you, but the base install will appear to be successful.

For example, I can successfully install the WindowMaker package for Alpha machines on my i386, and pkg_add won't complain at all. If I try to run it, however, I will immediately get an error.

 # wmaker /usr/local/bin/wmaker: Exec format error. Binary file not executable. # 

This binary format actually is executable, just not on i386 hardware. The error you get will differ depending on the hardware you're running on and the architecture the package was compiled for.

Package Contents

Now that your software is installed, how do you find it on your system? There's no Start menu, after all, and no icon is dropped on your desktop. OpenBSD installs almost everything under /usr/local; if /usr/local/bin is in your $PATH, you might just try to run the command and see if it works. If it doesn't, you'll have to check the package installation record.

The directory /var/db/pkg contains a complete record of everything installed by ports or packages on your system: program names, documents, and locations. For example, this system now contains a directory called windowmaker-0.80.1. If you look in that directory, you'll see three files: +COMMENT, +CONTENTS, and +DESC.

The +COMMENT file contains a very brief description of the software. +DESC contains a longer description of the software, including a URL (if available) where you can go for more information. The most interesting file is +CONTENTS, which lists every file installed by the package. The file is quite long, but we'll look at the start of it.

Note

You may have difficulties trying to view these files with more(1) or less(1). The plus sign is a special character. To view the file, try specifying it by full path (i.e., "more /var/db/pkg/ windowmaker-0.80.1/+CONTENTS") or, if you're in the directory, by giving a leading period and slash (i.e., "less ./+CONTENTS").

 # more ./+CONTENTS 1 @name windowmaker-0.80.1 2 @pkgdep libiconv-1.8 @pkgdep libiconv-1.8 ... 

Any line beginning with an @ symbol is a comment. The +CONTENTS file begins by listing 1 the package it belongs to. You'll then find several lines describing each of the packages this package requires, marked by the 2 pkgdep keyword. Continue down the list, and you'll find several more entries of interest.

 ... 1 @cwd /usr/local 2 @src /usr/ports/x11/windowmaker/w-windowmaker-0.80.1/fake-i386/usr/local 3 @comment 4 subdir=x11/windowmaker 5 cdrom=yes ftp=yes @comment 6 libdepend iconv.3.0:gettext-0.10.40:libiconv-*:libiconv-1.8 ... 

The 1 cwd (change working directory) keyword indicates where this software is installed. WindowMaker is installed under /usr/local. The 2 src label shows where the package was built. The 3 comment keyword is used for general notes about a package. We can see the 4 port the package was built from, and if the package will be on the 5 CD-ROM or on the FTP site. The 6 libdepend comment shows all of the libraries that the port depends on.

 ... @comment 1 newdepend gettext-0.10.40:libiconv-*:libiconv-1.8 @comment newdepend windowmaker-0.80.1:gettext->=0.10.38:gettext-0.10.40 2 @comment $OpenBSD: PLIST,v 1.25 2002/07/23 07:58:05 wilfried Exp $ ... 

You may have noticed that some packages appear repeatedly in the dependencies list. When a package depends on many other packages, and those other packages have their own dependencies, it's very easy for a single package to be listed as a dependency several times. The 1 newdepend comment strips this down to the bare minimum of packages that are absolutely required, hiding the complex chain of dependencies. Finally, the 2 exact version of the port this package was created with is shown.

After all of this, we finally get to the list of files contained within the package.

 ... 1 GNUstep/Apps/WPrefs.app/WPrefs 2 @comment MD5:146e8da921092c048731ea2827aa5879 GNUstep/Apps/WPrefs.app/WPrefs.tiff @comment MD5:a47a7110635258aecf2d2744be8b485e ... 

Most of the remainder of the file is a list of files that are contained within the package. For example, 1 we can see that the package includes the file "GNUstep/Apps/WPrefs.app/WPrefs." Each file is listed relative to the directory tree given at the top of the +CONTENTS file. For example, this whole package is installed under /usr/local, so the WPrefs file is actually available as /usr/local/ GNUstep/Apps/WPrefs.app/WPrefs.

Most files installed in a "share" directory are either documentation or data intended for internal use by the program. Files installed in a "bin" directory are programs, and files installed in a "man" directory are manual pages. Some programs, such as WindowMaker, have their own directory hierarchy and do whatever they want. Still, a "grep man ./+CONTENTS" will quickly give you a list of all the man pages the program includes, which will give you a start on learning about a program.

Next, we see a 2 MD5 checksum for the file. The package-handling tools use this checksum to verify that a file has not been damaged in transit or by operator error. Checksums allow you to verify later that a file is the same as what was contained in the original package (see Chapter 10).

At the very end of the package list, we'll see a few instructions for uninstalling the package. These really aren't very useful for day-to-day systems administration, so we'll skip them.

Uninstalling Packages

So, after all this, suppose you don't want to keep the software on your system? That's simple enough with pkg_delete(1). Just give pkg_delete(1) one argument, the full name of the package you want to uninstall, and the program will remove the package from your system.

 # pkg_delete windowmaker-0.80.1 # 

If you try to uninstall a package required by other packages, pkg_delete will complain loudly. You might have a very legitimate reason for doing so, but pkg_delete will try to keep you from cutting off your own feet. If you insist, however, the "-f" flag will let you force an uninstall of a package even if it is required by other packages. Don't expect software that requires this package to work once you've uninstalled it, however! For example, if I delete the libiconv package my WindowMaker desktop will almost certainly not run.

Packaging Problems

The package system is fast, efficient, and reliable, and absolutely wonderful for many people. The system has a few problems, however — specifically lags in the software-porting process, software-synchronization requirements, and the support for newer packages on older versions of OpenBSD.

Each version of OpenBSD only supports the packages that it was built with. If you have an OpenBSD 3.2 machine, and you have a package from OpenBSD 3.3 that you want to install, you're on your own. It may work, or not; it will probably fall into a gray area where most of the functions work, but enough doesn't that you'll get quite frustrated. You may be able to compile a port instead, however.

The overwhelming majority of packages are software produced by third parties, who release their software on a schedule completely independent of OpenBSD. Some time after the software developers release an updated version of their software, the OpenBSD package is updated. There is a delay between the release of an original software package and the porting to OpenBSD. A popular package might be updated in hours, while large or less frequently used packages can languish at an older version for days or weeks. These packages are not officially available until the next release of OpenBSD, so you may be running less-than-perfectly-new software for a few months. In almost all cases, this is not aproblem.

Also, packages are interdependent, and many rely on others in order to function properly. Those other packages must be of the correct version. If I tried to install a package that depended on windowmaker-0.80.1, it wouldn't work if I had windowmaker-0.80.2 or windowmaker-0.80 installed.

All of this goes away if you install your software from an OpenBSD CD-ROM or only use packages from a particular release of OpenBSD. You only experience these problems if you try to mix and match packages from different OpenBSD versions. Even if you do this, however, you will not be able to install customcompiled software from a package. You'll have to use a port for that.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

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