The Beauty of Package Management in Linux

A friend of mine called me recently stating that he had a very stripped down (No GUI, minimal packages) version of SUSE linux and wished to install the Apache Web Server. The problem seemed simple enough but the method he chose was a recipe for frustration. He attempted to install the software using source packages he found online. In his attempts at compilation, it complained of requiring other packages such as apr-utils and even after installing these dependencies it still complained of others.

His distress call was noted and was quite inevitable as an all too familiar dependency hell memory had emerged. I quickly assured him that packages are the way to go, and beyond that, a repository whereby the dependencies would also be resolved without intervention is your best bet.

Package Management commands vary between Linux Distributions but the basic concepts will remain the same

  1. Configure the repository from which the packages can be obtained

  2. Query the repository to ensure that the required package(s) exist(s)

  3. Install the required packages

Repository Configuration

The repository chosen depends on the version of the Operating System (OS), in this case my friend was using SUSE Linux 11.1.

To add a repo execute the following as the root user.

zypper ar -f http://download.opensuse.org/distribution/11.4/repo/oss/ opensusepack

The above command adds a repository called opensusepack with files contained at the location http://download.opensuse.org/distribution/11.4/repo/oss/. It tells the system that when using zypper to add packages it can locate them along with any dependencies at that online location.

Querying the Repository

zypper search apache 

The above command searches configured repositories for any packages containing apache.

Package Installation

Finally to install the Apache Web Server

zypper install apache

In summary, once the repository is configured, we can search for and install any packages that are located in the repository. All necessary dependency and GPG key checks are done automatically and we can immediately begin using the newly installed software.

References