Chapter 18. Package Management

Table of Contents
18.1. Pkgtools
18.2. Slackpkg
18.3. Using rsync
18.4. Tagfiles

18.1. Pkgtools

18.1.1. Introduction

Slackware Linux does not use a complex package system, unlike many other Linux distributions. Package have the .tgz extension, and are usually ordinary tarballs which contain two extra files: an installation script and a package description file. Due to the simplicity of the packages the Slackware Linux package tools do not have the means to handle dependencies. But many Slackware Linux users prefer this approach, because dependencies often cause more problems than they solve.

Slackware Linux has a few tools to handle packages. The most important tools will be covered in this chapter. To learn to understand the tools we need to have a look at package naming. Let's have a look at an example, imagine that we have a package with the file name bash-2.05b-i386-2.tgz. In this case the name of the package is bash-2.05b-i386-2. In the package name information about the package is separated by the '-' character. A package name has the following meaning: programname-version-architecture-packagerevision

18.1.2. pkgtool

The pkgtool command provides a menu interface for some package operations. De most important menu items are Remove and Setup. The Remove option presents a list of installed packages. You can select which packages you want to remove with the space bar and confirm your choices with the return key. You can also deselect a package for removal with the space bar.

The Setup option provides access to a few tools which can help you with configuring your system, for example: netconfig, pppconfig and xwmconfig.

18.1.3. installpkg

The installpkg command is used to install packages. installpkg needs a package file as a parameter. For example, if you want to install the package bash-2.05b-i386-2.tgz execute:


# installpkg bash-2.05b-i386-2.tgz
      

18.1.4. upgradepkg

upgradepkg can be used to upgrade packages. In contrast to installpkg it only installs packages when there is an older version available on the system. The command syntax is comparable to installpkg. For example, if you want to upgrade packages using package in a directory execute:


# upgradepkg *.tgz
      

As said only those packages will be installed of which an other version is already installed on the system.

18.1.5. removepkg

The removepkg can be used to remove installed packages. For example, if you want to remove the "bash" package (it is not recommended to do that!), you can execute:


# removepkg bash
      

As you can see only the name of the package is specified in this example. You can also remove a package by specifying its full name:


# removepkg bash-2.05b-i386-2
      

18.2. Slackpkg

18.2.1. Introduction

Slackpkg is a package tool written by Roberto F. Batista and Evaldo Gardenali. It helps users to install and upgrade Slackware Linux packages using one of the Slackware Linux mirrors. Slackpkg is included in the extra/ directory on the second CD of the Slackware Linux CD set.

18.2.2. Configuration

Slackpkg is configured through some files in /etc/slackpkg. The first thing you should do is configuring which mirror slackpkg should use. This can be done by editing the /etc/slackpkg/mirrors. This file already contains a list of mirrors, you can just uncomment a mirror close to you. For example:


ftp://ftp.nluug.nl/pub/os/Linux/distr/slackware/slackware-10.2/
      

This will use the Slackware Linux 10.2 tree on the ftp.nluug.nl mirror. Be sure to use a tree that matches your Slackware Linux version. If you would like to track slackware-current you would uncomment the following line instead (when you would like to use the NLUUG mirror):


ftp://ftp.nluug.nl/pub/os/Linux/distr/slackware/slackware-current/
      

Slackpkg will only accept one mirror. Commenting out more mirrors will not work.

18.2.3. Importing the Slackware Linux GPG key

By default slackpkg checks packages using the package signatures and the public Slackware Linux GPG key. Since this is a good idea from a security point of view, you probably do not want to change this behaviour. To be able to verify packages you have to import the security@slackware.com GPG key. If you have not used GPG before you have to create the GPG directory in the home directory of the root user:


# mkdir ~/.gnupg
      

The next step is to search for the public key of security@slackware.com. We will do this by querying the pgp.mit.edu server:


# gpg --keyserver pgp.mit.edu --search security@slackware.com
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: searching for "security@slackware.com" from HKP server pgp.mit.edu
Keys 1-2 of 2 for "security@slackware.com"
(1)     Slackware Linux Project <security@slackware.com>
          1024 bit DSA key 40102233, created 2003-02-25
(2)     Slackware Linux Project <security@slackware.com>
          1024 bit DSA key 40102233, created 2003-02-25
Enter number(s), N)ext, or Q)uit > 
      

As you can see we have got two (identical) hits. Select the first one by entering "1". GnuPG will import this key in the keyring of the root user:


Enter number(s), N)ext, or Q)uit > 1
gpg: key 40102233: duplicated user ID detected - merged
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 40102233: public key "Slackware Linux Project <security@slackware.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
      

Be sure to double check the key you received. The key ID and fingerprint of this particular key can be found on the Internet on many trustworthy sites. The key ID is, as mentioned above 40102233. You can get the key fingerprint with the --fingerprint parameter:


# gpg --fingerprint security@slackware.com
pub  1024D/40102233 2003-02-26 Slackware Linux Project <security@slackware.com>
     Key fingerprint = EC56 49DA 401E 22AB FA67  36EF 6A44 63C0 4010 2233
sub  1024g/4E523569 2003-02-26 [expires: 2012-12-21]
      

Once you have imported and checked this key you can start to use slackpkg, and install packages securely.

18.2.4. Updating the package lists

Before upgrading and installing packages you have to let slackpkg download the package lists from the mirror you are using. It is a good idea to do this regularly to keep these lists up to date. The latest package lists can be fetched with:


$ slackpkg update
      

18.2.5. Upgrading packages

The upgrade parameter is used to upgrade installed packages. You have to add an extra parameter to actually tell slackpkg what you want to upgrade, this differs for a stable Slackware Linux version and slackware-current. Upgrades for stable Slackware Linux releases are in the patches directory of FTP mirrors. You can update a slackware-stable installation (e.g. Slackware Linux 10.2) with:


# slackpkg upgrade patches
      

In this case slackpkg will use the packages from the patches directory. In slackware-current updated packages are put in the normal slackware package sub-directories. So, we can pass that as an parameter to slackpkg upgrade:


# slackpkg upgrade slackware
      

You can also upgrade individual packages by specifying the name of the package to be upgraded, for example:


# slackpkg upgrade pine
      

18.2.6. Installing packages

The install is used to install packages:


# slackpkg install rexima
      

Be aware that neither slackpkg, nor the Slackware Linux package tools do dependency checking. If some program does not work due to missing libraries, you have to add them yourself with slackpkg.

18.3. Using rsync

Another popular method of keeping Slackware Linux up to date is by keeping a local mirror. The ideal way of doing this is via rsync. rsync is a program that can synchronize two trees of files. The advantage is that rsync only transfers the differences in files, making it very fast. After syncing with a mirror you can upgrade Slackware Linux with upgradepkg, or make a new installation CD. The following example synchronizes a local current tree with an up-to-date tree from on a mirror:


# rsync -av --delete \
--exclude=slackware/kde \
--exclude=slackware/kdei \
--exclude=slackware/gnome \
--exclude=bootdisks \
--exclude=extra \
--exclude=testing \
--exclude=pasture \
--exclude=rootdisks \
--exclude=source \
--exclude=zipslack \
rsync://fill-in-mirror/pub/slackware/slackware-current/ \
/usr/share/mirrors/slackware-current
    

The -a parameter implies a few other options that try to make a copy that is as exact as possible (in terms of preserving symlinks, permissions and owners). The --delete deletes files that are not available on the mirror anymore. It is good idea to use this parameter, because otherwise your tree may get bloated very quickly with older package versions. With the --exclude parameter you can specify which files or directories should be ignored.

After syncing the tree you can use upgradepkg to update your Slackware Linux installation. For example:


# upgradepkg /usr/share/mirrors/slackware-current/slackware/*/*.tgz
    

18.4. Tagfiles

18.4.1. Introduction

Tagfiles are a relatively unknown feature of Slackware Linux. A tagfile is a file that can be used to instruct installpkg what packages should be installed from a collection of packages. For instance, the Slackware Linux installer generates a tagfile during the Expert and Menu installation methods to store which packages should be installed during the installation process.

The nice aspect of tagfiles is that you can easily create tagfiles yourself. By writing your own tagfiles you can automate the package installation, which is ideal for larger client or server roll-outs (or smaller set-ups if it gives you more comfort than installing packages manually). The easiest way to create your own tagfiles is by starting out with the tagfiles that are part of the official Slackware Linux distribution. In the following sections we are going to look at how this is done.

18.4.2. Creating tagfiles

Tagfiles are simple plain-text files. Each line consists of a package name and a flag, these two elements are separated by a colon and a space. The flag specifies what should be done with a package. The fields are described in Table 18-1. Let's look at a few lines from the tagfile in the "a" disk set:


aaa_base: ADD
aaa_elflibs: ADD
acpid: REC
apmd: REC
bash: ADD
bin: ADD
      

It should be noted that you can also add comments to tagfiles with the usual comment (#) character. As you can see in the snippet above there are different flags. The table listed below describes the four different flags.

Table 18-1. Tagfile fields

Flag Meaning
ADD A package marked by this flag will automatically be installed
SKP A package marked by this flag will automatically be skipped
REC Ask the user what to do, recommend installation of the package.
OPT Ask the user what to do, the package will be described as optional.

As you can read from the table installpkg will only act automatically when either ADD or SKP is used.

It would be a bit tedious to write a tagfile for each Slackware Linux disk set. The official Slackware Linux distribution contains a tagfile in the directory for each disk set. You can use these tagfiles as a start. The short script listed below can be used to copy the tagfiles to the current directory, preserving the disk set structure.


#!/bin/sh

if [ ! $# -eq 1 ] ; then
  echo "Syntax: $0 [directory]"
  exit
fi

for i in $1/*/tagfile; do 
  setdir=`echo $i | egrep -o '\w+/tagfile$' | xargs dirname`
  mkdir $setdir
  cp $i $setdir
done
      

After writing the script to a file you can execute it, and specify a slackware/ directory that provides the disk sets. For example:


$ sh copy-tagfiles.sh /mnt/flux/slackware-current/slackware
      

After doing this the current directory will contain a directory structure like this, in which you can edit the individual tag files:


a/tagfile
ap/tagfile
d/tagfile
e/tagfile
[...]
      

18.4.3. Using tagfiles

On an installed system you can let installpkg use a tagfile with the -tagfile parameter. For example:


# installpkg -root /mnt-small -tagfile a/tagfile /mnt/flux/slackware-current/slackware/a/*.tgz
      

Of course, tagfiles would be useless if they cannot be used during the installation of Slackware Linux. This is certainly possible: after selecting which disk sets you want to install you can choose in what way you want to select packages (the dialog is named SELECT PROMPTING MODE. Select tagpath from this menu. You will then be asked to enter the path to the directory structure with the tagfiles. The usual way to provide tagfiles to the Slackware Linux installation is to put them on a floppy or another medium, and mounting this before or during the installation. E.g. you can switch to the second console with by pressing the <ALT> and <F2> keys, and create a mount point and mount the disk with the tagfiles:


# mkdir /mnt-tagfiles
# mount /dev/fd0 /mnt/mnt-tagfiles
      

After mounting the disk you can return to the virtual console on which you run setup, by pressing <ALT> and <F1>.