1. Software Management Tools

Abstract

Once your server is installed, you may need to install or uninstall software. Mandriva Enterprise Server 5, offers two options to accomplish this task: the graphical Rpmdrake application (see Section 1.4, “Managing Software with Rpmdrake), and the command-line tools. The latter is comprised of urpmi to install and upgrade software, urpme to remove RPM packages, urpmf and urpmq to search the RPM databases. These are all the underlying programs behind Rpmdrake.

1.1. Local repository configuration

In order to facilitate the installation of software packages, it is possible to create a repository of packages directly on the hard drive of your server.

[Note] Note

Prerequisites

  • You must have a minimum of disk space 3 GB.

  • You need the installation CD/DVD.

1.1.1. Configuring a local repository in graphical mode

Here's how to configure a local repository with graphical tools.

  • Insert the installation CD/DVD.

  • An icon representing the media appears on the desktop. Double-click on it to explore the contents of the DVD.

  • Copy the i586 directory (or x86_64) on your hard drive to the desired location.

  • Once the copy is complete, run the Mandriva Linux Control Center.

    Figure 5.1. The Mandriva Linux Control Center

    The Mandriva Linux Control Center

  • Click on Configure media sources for install and update.

  • In File, choose Add a custom medium.

    Figure 5.2. Adding repository

    Adding repository

  • Fill the fields.

    Figure 5.3. Adding custom repository

    Adding custom repository

    There are 3 repository to configure :

    - Medium main

    Medium name : Mandriva - mes5 (Enterprise Server)

    Medium path : /data/i586/media/main/

    - Medium non-free

    Medium name : Mandriva - mes5 (Enterprise Server) non-free

    Medium path : /data/i586/media/non-free/

    - Medium restricted

    Medium name : Mandriva - mes5 (Enterprise Server) restricted

    Medium path : /data/i586/media/restricted/

    [Note] Note

    In our example, the i586 directory of the DVD has been copied to /data

  • Disable CDROM media : uncheck Enabled.

1.1.2. Configuring a local repository in command line

Here's how to configure a local repository with command lines.

  • Insert the installation CD/DVD.

  • The CD/DVD is mounted in /mnt/cdrom

  • Copy the i586 (or x86_64) directory on your hard drive (for example in /data):

    cp -r /media/cdrom/i586 /data/
  • Remove old media:

    urpmi.removemedia -a
  • Add medias:

    urpmi.addmedia "Mandriva - mes5 (Entreprise Server) main" file://data/i586/media/main/
    urpmi.addmedia "Mandriva - mes5 (Entreprise Server) non-free" file://data/i586/media/non-free/
    urpmi.addmedia "Mandriva - mes5 (Entreprise Server) restricted" file://data/i586/media/restricted/
  • Update with the added media:

    urpmi.update -a

1.2. Installing and Updating RPMs with urpmi

1.2.1. Basic Notions

The main purpose of urpmi is to easily download and install RPM packages. RPM software packages often contain dependencies: urpmi recognizes those dependencies, downloads the required missing packages, and removes conflicting packages.

urpmi fetches the list of available RPMs and the RPMs themselves from a source media. Roughly speaking, a source media is described by a name and a location specified by an URL. Currently supported media types include local drives, removable drives (such as CDs), ISO images, and network media via different protocols (http, ftp, ssh and rsync). NFS mounted directories are treated like local drives.

1.2.2. Installing RPMs

Here's a description of the basic urpmi options:

urpmi <list of package names>

That prompts urpmi to fetch and install all packages and their unmet dependencies from the media you've configured. In the process, urpmi might ask questions. For example, if some packages need to be upgraded, or if some new (unspecified) packages have to be installed, that operation will require confirmation. If some packages need to be removed (due to conflicts with the requested packages), urpmi will also ask for confirmation. In some cases, urpmi will also propose a choice between different alternatives, usually proposing the “best” package as a default.

Another very useful urpmi feature is to upgrade all packages to the latest version found on the media. This is done with the following command:

urpmi --auto-update

urpmi can also install RPM files directly. Instead of using rpm -i foobar.rpm, you can pass the path of the RPM file to urpmi and it will then try to resolve the needed dependencies:

urpmi /home/user/foobar.rpm

Here are some useful options for urpmi :

--auto

Automatic mode: urpmi doesn't ask questions and always selects the default choice.

--test

To test the installation of packages without actually installing anything or modifying the system.

--media *media1,...,mediaN*

This option forces urpmi to only use the specified media, instead of defaulting to all available media. You can also specify a substring of media names for urpmi to select all media containing that substring. For example, urpmi --auto-update --media updates will search updates from all media that have “updates” in their name.

See the urpmi(8) manpage for more information.

1.2.3. Media Management with urpmi

1.2.3.1. Adding Media

urpmi is only usable when at least one media is defined. Usually, the OS installation procedure configures a predefined set of media, corresponding to the installation method you've selected: installation CDs, an HTTP or FTP server if you've installed from a networked mirror. System administrators often want to add media. To do so, use the urpmi.addmedia program:

urpmi.addmedia [options] <name> <url> [with hdlist]

In this synopsis, <name> is the name of the new media, <url> the URL where the RPMs are to be found, and the “with” parameter optionally specifies where to find the information file that describes the media's contents..

Supported URLs can be http://, ftp://, rsync://, ssh:// (this will use rsync over ssh), file://, and removable://. removable:// works like file://, but instructs urpmi that the directory is mounted from a removable media, such as a CD or a DVD. If the media requires authentication, you can use the usual URL syntax:

<scheme>://<login>:<pass>@host/path

Those credentials will not be stored in any world-readable file.

In some cases, if your media points to an external HTTP or FTP server, you might want to use a proxy to access it. Use the --proxy and --proxy-user options (the second one is needed if your proxy requires authentication.)

1.2.3.2. Removing media

This is straight forward. To remove a media named foo, simply use the command:

urpmi.removemedia foo
1.2.3.3. Updating Media

Some media never change. This is the case, for example, for CD-ROMs. However, other media, typically updates, grow. New RPMs are added and old ones are removed. Therefore, before using them you should instruct urpmi that their contents might have changed.

To do this, use the urpmi.update program. You can either update all media:

urpmi.update -a

You can also update only specifically named media:

urpmi.update updates-one updates-two
1.2.3.4. Creating Your own Media

The easiest way to create your own media is to let urpmi.addmedia do it. However, this will work properly only if you have a small number of RPMs, stored on disk or on a shared NFS mount. To do this, assuming that your RPMs are under a directory like /var/my-rpms, enter the command below:

urpmi.addmedia my-media /var/my-rpms

To create a media containing a large number of RPMs, or to be put on a shared server, you'll need to use the gendistrib tool. It comes in the rpmtools package. It generates a mirror tree for one or several media.

A typical media repository, under a root directory /ROOT/, has the following structure, (we have two media, named “first” and “second”):

    ROOT/ - media/
    |- first/
    |   `- media_info/
    |- second/
    |   `- media_info/
    `- media_info/

The RPMs are placed in the first and second subdirectories. Repository metadata is contained in the top-level media_info directory. Per-media metadata is contained in the first/media_info and second/media_info subdirectories.

Per-media metadata consists of an hdlist.cz file that contains the gzipped headers of the media's RPMs, a synthesis.hdlist.cz file (much smaller than the hdlist) containing only the information necessary for urpmi to resolve dependencies, and optionally, a pubkey file if the RPMs are signed (so that urpmi can check that the RPMs it downloads are signed with the key associated to this media.)

Before using gendistrib, you must create a media_info/media.cfg file to describe this media repository. The syntax of this file is like that of .ini files. It contains one section per media:

[first] hdlist=hdlist_first.cz name=First
    supplementary media

In the previous case, first is the directory name, hdlist_first.cz is the name of the hdlist file that will be created (it must end with .cz), and name= gives a human-readable description of the media.

Then, you can run gendistrib. You should pass it the /ROOT/ directory as parameter. It will then generate the hdlist and synthesis files and all other files needed for proper repository operation.

For further information, see the gendistrib(1) manpage.

1.2.4. Parallel Installation Command: urpmi-parallel

urpmi-parallel is a useful add-on to urpmi to install packages on many network hosts. It runs a urpmi command in parallel on a specified number of hosts. More precisely, the machine you run the command on (the server) tests the results on each machine in the group (the “clients”) one by one, downloads all necessary packages for all machines in the group, distributes the appropriate packages to each machine, then calls urpmi on the machine to do the actual installation.

urpmi must be installed on all client machines, but it's not necessary to have a media defined on client machines.

To use it, follow these steps:

  1. Make sure you can ssh from the server to each client machine as root (you can use ssh-add on the server host to avoid entering your passphrase and/or password many times).

  2. Install urpmi-parallel-ssh or urpmi-parallel-ka-run on the server machine. The first plugin uses plain ssh to distribute commands to other hosts, while the second one uses ka-run, an efficient parallelization method on top of any remote shell (rsh or ssh), adapted to clusters.

  3. Edit /etc/urpmi/parallel.cfg to look like this:

    mynetwork:ssh:host1:host2:host3

    On this line, mynetwork is the name of the alias you will use to specify the network to urpmi, ssh is the install method (to use ka-run, look up the entry for /etc/urpmi/parallel.cfg in urpmi.files(5)), and hostN are the host names of all clients on your network. You can put localhost in this list.

  4. Run the urpmi command: for example, to install “package_name”:

    urpmi --parallel mynetwork package_name

1.2.5. Restricted urpmi

urpmi has a more secure counterpart: rurpmi. It is similar to urpmi, but has a stripped-down set of features. It's intended to be used by users without root privileges, but with sudo rights on it, preventing any abuse of this tool to compromise the system.

Its syntax is similar to urpmi, but it prevents installing arbitrary RPMs. They need to come from a registered media. A number of dangerous options, listed in the rurpmi(8) manpage, are also forbidden.

1.2.6. Removing RPMs with urpme

The tool used to uninstall RPMs is urpme. For example:

urpme <list of package names>

This will attempt to remove all listed packages and the packages that depend on them. It will refuse to uninstall “important” packages (the ones that are part of the base system).

See the urpme(8) pmanpage for the reference of all options urpme supports.

Note that urpme isn't able to detect packages that are no longer used. For example, libraries not used by applications. To clean them up, a handy tool is rpm-find-leaves. It will list all RPMs on your system that no other package requires.

1.3. Searching for Packages with urpmf and urpmq

1.3.1. urpmf

urpmf is a grep-like tool for the urpmi database (the database of all RPMs in the media). By default, it will search through the file names contained in packages, but a variety of options allows more advanced searches.

For example, to find all packages that begin with apache- :

urpmf --name '^apache-'

The ^ is the beginning-of-line anchor used in standard regular expressions.

To find all packages that contain files whose path name includes /etc/httpd.conf.d :

urpmf /etc/httpd.conf.d

To find all packages that provide mail-server with their version and release number (-f) :

urpmf --provides -f mail-server

See the urpmf(8) manpage for more examples and the list of all options.

1.3.2. urpmq

The urpmq tool allows you to query the urpmi database. It has several modes of operation. Here are a couple of interesting uses:

urpmq -i package

It lists the information for that package (like rpm -qi would do for an installed package). The --summary option is similar, but only gives one-line, concise information.

urpmq --source package

This returns the URL where the package can be retrieved from.

urpmq -d package

It gives the list of all RPMs that are required by the specified package (recursively).

Inversely, the urpmq -R package returns the list of all RPMs that require the specified package.

See the urpmq(8) manpage for a list of all options.

1.4. Managing Software with Rpmdrake

The urpmi set of tools is command-line based. You can also use a graphical tool called Rpmdrake. It consists of different components which you access by choosing one of the entries of the System+Configuration+Packaging menu in the main menu, or by clicking on Software Management in the Mandriva Linux Control Center.

Figure 5.4. Software Management in the Mandriva Linux Control Center

Software Management in the Mandriva Linux Control Center

We recommend that you access Rpmdrake via the Mandriva Linux Control Center.

1.4.1. Install Software

When launched, Rpmdrake searches the database of available packages. Then the Software Packages Installation interface is displayed.

Figure 5.5. The Software Package Installation interface

The Software Package Installation interface

The upper part of the window allows you to manipulate the list of packages you can install. This list is in the middle-left of the window. On its right is an area where the currently selected package is described. At the bottom of the window are two buttons and information about the space required to install the selected packages, as well as how much space is available on your disk.

[Note] Note

Additionally, a status bar in the lower part of the window displays messages about actions currently in progress or completed.

1.4.1.1. Selecting Packages to Install

In Figure 5.5, “The Software Package Installation interface”, the samba-3.2.7-0.3mdv2009.0 package is selected in the tree-view. In the package-description are shown the required disk space, a short summary (“Samba (SMB) server programs”), as well as a detailed description.

[Tip] Tip

If your software medium repository is configured to use complete package lists (not the summary synthesis files, but the full hdlist ones, which is the default behaviour after installing Mandriva Linux), you may get more information on the package by choosing the Maximum information radio button in the access area. In addition is a list of the files provided by the package and the change log.

The status bar displays the disk space required by the selected packages, as well as the current free space. Please note that due to dependencies, the disk space required by the selected packages might be greater than the size required by the chosen package itself.

[Note] Note

Rpmdrake shows you an alert box if you try to install more software than the available disk space. Delete files you no longer use to proceed with the installation.

Now you can begin the installation by clicking on the Install button. A new window appears, showing you a progress bar of how your installation is proceeding. If you prefer to leave without doing anything, click the Quit button.

While selecting applications to install, it may happen that you choose a package which requires dependencies (additional libraries or another tool) to work correctly. In this case, Rpmdrake displays an information window enabling you to choose whether to accept the selected dependencies, or to Cancel the operation (Figure 5.6, “Rpmdrake Dependency Alert Box”).

Figure 5.6. Rpmdrake Dependency Alert Box

Rpmdrake Dependency Alert Box

Let's say you want to install a package which requires dependencies, and various packages are capable of providing that dependency. The list of alternatives is then presented. You may read the additional information presented by clicking the Info button to help you choose the best alternative.

We will now take a closer look at the search and sort functions provided to ease your job as a system administrator:

1.4.1.2. Searching for Packages

To search for a specific package, just type its name (or part of the name) in the text area next to the Search button. Then choose from the pull-down list where you want to look for it (either in the package name, in the description provided with the package or in the names of the files stored in the packages). After clicking on the Search button, a new list appears (Search results), showing you the results Rpmdrake found while scanning the package databases.

Let's look at the different sort orders:

Mandriva Linux choices

Shows the list of packages in the four groups you saw during the installation process. This is the easier sort order because it focuses on a selected part of the available packages: those considered to be the most useful.

All packages, alphabetical

Displays a flat list of all available packages you can install.

packages, by group

Shows the list of packages grouped by function (e.g. games, system, video, etc.).

All packages, by size

Displays a package list sorted by size.

All packages, by selection state

Shows a flat list in which all selected packages are displayed first. The other available packages are listed below.

All packages, by medium repository

Displays packages alphabetically and under the name of the data medium they belong to (see Section 1.4.4, “The Software Media Manager”).

All packages, by update availability

Might show two groups of packages: one for packages you can install, and a second list of packages for which an older version is already installed.

1.4.2. Remove Software

This interface works like the “Install Software” one, so we won't repeat its basic functions (Section 1.4.1, “Install Software”).

1.4.3. Mandriva Linux Update

When you launch Mandriva Linux Update, it first asks you to choose an Internet repository to check for updates. You should choose one in a country near you.

A small difference to the “Install Software” interface is the ability to choose the kind of update you want to install by grouping them in certain ways. You may select:

Security updates

These solve security issues and should be installed as soon as possible.

Bugfixes updates

These ones fix application misbehavior.

Normal updates

They just bring slight improvements.

The other difference is a new text section (“Reason for update”) inside the package description area. It tells you why this update was made available. This may help you decide if you want to update certain packages or not. When you have a slow Internet connection or you have to pay per MB when you are downloading, it would be wise to read it.

1.4.4. The Software Media Manager

This part of Rpmdrake is dedicated to the configuration of the package media repositories. As you can see in Figure 5.7, “The Software Media Manager”, some media are configured: “Main”, “Contrib”, etc. With this tool you can add other software media: a CD from a magazine containing RPMs, a Web repository, etc.

Figure 5.7. The Software Media Manager

The Software Media Manager

The checkboxes in the left-hand column allow you to flag the repositories:

Enabled?

Uncheck this box to temporarily disable the corresponding medium. The packages contained in this medium won't be available for installation until you enable the medium again.

Updates?

This box must be checked for update media, that is, media that contain updates of packages that are already installed on your machine, but with an older version number. Therefore only update media are taken into account when looking for updates.

Various buttons allow you to perform actions on the selected media.

Remove

Allows you to remove a medium which you no longer use. Simply select the medium to be removed in the list and click on Remove.

Edit

Enables you to change the URL or the relative path to the synthesis/hdlist file.

Click the Proxy button to configure a proxy server. Note that you can also define a global proxy for all remote media through the main interface's Proxy button.

This option also allows you to change from using hdlist files to synthesis files.

[Note] Note

Synthesized files only give information about package names, their dependencies and a short summary. You won't be able to search for files inside uninstalled packages, for example, and you won't be able to see the full description for a package if you click on its name.

Add

Permits you to add all publicly available official package sources from Internet repositories. This is useful if you have a fast Internet connection or you only have the first installation CD at hand. Choosing a mirror geographically near to your location is recommended.

After choosing a mirror and clicking OK, package information for the source you chose is downloaded and all included packages will be available for you to install and update your system.

Add custom

Enables you to add a custom software repository source.

Update

Shows a list of already defined media. With it, you can choose the ones from which you want to update the list of available packages. This is useful for remote media to which new packages are being added. Just start the process by clicking on Update.

Manage Keys

It is important that any new package you install is authenticated. To do so, each package can be electronically signed with a “key”, and you can allow/disallow keys on a per-medium basis. In Figure 5.8, “Managing Keys ”, Mandriva Linux key is allowed for medium Installation CD. Click on Add a key to allow another key for the selected medium, and on Remove key to remove a key from the selected medium.

[Warning] Warning

As with all security-related questions, make sure you know what you're doing if you decide to remove keys.

Figure 5.8. Managing Keys

Managing Keys

Proxy

If you are sitting behind a firewall and you still need to access remote media (especially for package updates), you can do so if you have a proxy server which leads to the Internet (at least in an area where you can find a package server). Normally, it should be enough to fill in the Proxy hostname to get it working (Figure 5.9, “Configuring a Proxy server”). If you need a user/password combination to get through the proxy, you can also specify it here. Just confirm your changes by clicking OK and you're done.

Figure 5.9. Configuring a Proxy server

Configuring a Proxy server

Parallel

If you run a large network of computers, you may want to install a package on all the computers in parallel. This button opens a dialog window allowing the configuration of the “Parallel” mode. See the urpmi(8) manpage for more information.

Global Options

Allows you to configure the program used to download new packages and if the source should be checked against a given key. These choices are used on all installed sources.

Up and Down Arrows

Enable you to change the order in which sources are used when installing packages.

[Note] For advanced users

Rpmdrake processes the urpmi configuration file (/etc/urpmi/urpmi.cfg) from top to bottom to obtain a list of medium repositories and the packages that each contains.

If a given package appears in more than one medium, and versions differ, then the one with the newest version is used, ignoring the rest.

When a package with the same version appears in more than one medium, only the one appearing first will be used, the rest are ignored.

Either way, you won't miss available packages.

1.4.5. Managing a Computer Group

1.4.5.1. Defining the Group

By using Rpmdrake's parallel mode, you can define groups of machines to install the same software packages on. This greatly simplifies managing a large number of systems, such as in a LAN. Make sure park-rpmdrake, urpmi-parallel-ssh and urpmi-parallel-ka-run are installed.

[Note] Note

This tool is accessible only in expert mode. Choose OptionsExpert mode from the menu and then access the Software Management section of Mandriva Linux Control Center.

Click on New Group, provide a Name for the group, select the Protocol to use (ssh in our example), check the networks to be scanned for hosts in the list or add other networks. By default, only your local network is listed. Then click on Scan.

[Note] Note

Hosts on the network must have an ssh server running and the corresponding ports (tcp/22 by default) open if they also host a firewall. The rsync package must be installed as well. Also, root must be allowed to login using ssh (PermitRootLogin yes in /etc/ssh/sshd_config, on the hosts).

Wait a few minutes until the network scan finishes and then check the hosts to be made part of the group.

Figure 5.10. Adding Computers to a Group

Adding Computers to a Group

You are then asked for root's password on each of the selected hosts to automate the installation of packages on them.

1.4.5.2. Managing Packages on a Group of Computers
[Note] Note

For package installation or removal in a specific group to succeed, all computers in that particular group must be available.

Select the group and click the Use Group button. You can now install packages on the selected computers group, as you would on a single computer.

You can also install packages on the computers' group from the command line:

urpmi --parallel <group_name> <package_name>

For example, issuing urpmi --parallel GraphicDesign gimp will install GIMP on all computers which are part of the GraphicDesign group.

To remove a package from a computer group, use:

urpme --parallel <group_name> <package_name>

For example, issuing urpme --parallel GraphicDesign gcc will remove the C compiler from all computers which are part of the GraphicDesign group.