|< Free Open Study >|| |
Slackware uses standard tarballs (.tar.gz files) for its packaging format. Since tarballs can be read by any Unix system (and any Linux distribution), they are platform-independent (though, of course, their contents typically are not). This section will discuss how Slackware Linux 8.0 handles package management with tarballs.
TAR files are not compressed, so they are frequently compressed before being distributed. In the early days of Unix, the most common compression format was the common Unix compress program, which gives files a .Z extension. The GNU project introduced the GNU Zip (gzip) compression format, with the .gz extension. Later, the bzip compression program introduced the .bz2 extension. A tarball is simply a TAR file compressed with one of these schemes; the extensions end up being .tar.Z, .tar.gz, or .tar.bz2. The most common format for Linux and other open source software is a gzipped TAR archive; sometimes the extension is shortened to .tgz. All of these file types (that is, simple .tar files as well as .tar.gz files, etc.) are sometimes referred to as tarballs; a tarball can be compressed or uncompressed.
Just as Slackware aims at simplicity in its use of tarballs as the native format for its package manager, it aims for similar simplicity in the tools for managing packages. This is most obviously evident in the package management tool, known simply as pkgtool, which is a console (text-based) menu program. It's really not much more than a user-friendly front-end for invoking the other tools described below. The pkgtool menu provides several installation options, an option to remove an installed package, and an option to view the contents of packages that are currently installed.
You can install packages from the following three sources:
The current directory
Another (arbitrary) directory
A floppy disk
Each of the above options allows administrators to install multiple packages at once. This is actually the way packages are installed when the system itself is first installed. These are the actual activities that pkgtool performs when it installs multiple packages:
The Slackware installation program invokes pkgtool to install the packages selected by the user. (This step is only invoked during installation of the system—it's skipped if you just run pkgtool by hand.) This step sets the directory that pkgtool is to use in step 2.
pkgtool scans its input directory for all files it can find that end in either .tgz or .tar.gz, that is, it searches for any standard tarballs.
pkgtool then asks the user whether each tarball should be installed, and acts accordingly.
The other options supported by pkgtool allow the user to remove a package after selecting it from a list, and also allow the user to view a list of all installed packages, as well as their contents. This functionality is just a front-end for the other tools listed in the following sections. The tools can always be invoked from the command line, but the pkgtool command provides a consolidated user interface.
Slackware packages can be installed via a command line with the installpkg program. This program takes a single parameter—the name of a tarball—to install and has several options that tweak where and how the package is installed. The command is very simple so we won't replicate all the options. The most useful option, however, is the -root <path> option. This parameter changes the root of the installation to <path>; for example, a package that would normally be installed in the root directory can be placed somewhere else, such as /opt via the command installpkg -root /opt packagename.tgz.
The installpkg command has additional options you can use that provide various interactive menu capabilities; these features are typically used when installpkg is called from another program or script, such as the pkgtool front-end command.
Slackware packages can be upgraded via the upgradepkg command. This command is even simpler than the installpkg command. If the new package has the same name as the package already installed, then the command upgradepkg <file name> will upgrade the package. If the file names are different, then the command upgradepkg <old package name>%<new package filename> will upgrade the package. For example, if foo-2.0.tgz is an upgrade of foo-1.0.tgz, then the command upgradepkg foo-1.0%foo-2.0.tgz will accomplish the upgrade. In either case, the effect is the same: the tool consults the list of files that the old package had installed, and then installs the new (upgraded) package.
If there are any files contained in the original package that were not replaced by the upgrade package, then the old stale files are removed. If a package needs to be upgraded into to a different root directory, then the ROOT environment variable must be set to that effect (in contrast to the installpkg command, which accepts this setting as a command line option). Note that the package will have to be upgraded into the same root as it is installed, or else it's not really an upgrade.
The command to uninstall a package is removepkg. This command takes a single argument, which is the name of the package to be removed. As with upgradepkg, the root of the package can be altered by setting the ROOT environment variable. Of course, the root directory has to match the directory where the package is actually installed. To remove the package, the tool retrieves the list of files installed by the package and then simply removes them.
Slackware's package management system also provides a very easy way to create Slackware-compatible packages. A developer administrator, or other packager, simply creates the directory layout of the software to be packaged in a temporary scratch directory. For example, an administrator might compile a software package and place it in /tmp. Then, the makepkg command is run, which creates a tarball with the necessary structure, and even creates a basic installation script if one is required. This package can then be installed (or upgraded) by one of the other tools.
There are additional advanced features that can be exploited when creating Slackware packages. The makepkg command is useful for many or most situations, but if more extensive functionality is required (such as a custom installation script,) it can be taken advantage of. Interested users can consult the Slackware documentation at http://www.slackware.com.
Slackware's package management tools are fairly basic when compared to Red Hat's RPM (discussed in Chapter 4) or Debian's apt tools (discussed in Chapter 6). However, even though Slackware's tools might not be quite state of the art among Linux distributions, they are still at least as sophisticated as most other Unix systems' tools.
It's important to remember the Slackware philosophy of simplicity and ease of maintenance throughout. There is literally nothing that these tools do that cannot be done manually with a text editor. When a package is installed, a file containing the description of the package and a list of all its files is placed in the directory /var/log/packages. These files are human-readable, meaning that they can be viewed, or even accessed via various scripts if an administrator is feeling particularly clever. For example, you can grep for the string "etc" in /var/log/packages to find a list of all files in the /etc/ directory that are owned by packages; Red Hat doesn't make this quite so easy.
The tools discussed in this section use these same files to do their work. In fact, the tools themselves are simply shell scripts! Slackware's package management mechanism is really shorthand for things that an administrator can accomplish by hand. That this fact is not immediately obvious to users of the tools is a tribute to the success of Slackware's elegant simplicity, and a great demonstration of that traditional Unix "hacker mystique" of self-sufficiency and simplicity.
|< Free Open Study >|| |