You will learn how to manage dependencies during RPM installation on Linux servers such as CentOS, RHEL, Fedora, and Ubuntu. We’ll provide step-by-step instructions on how to properly handle dependency issues and solve common issues. Whether you build your own RPM or use third-party, we’ll cover it in this guide.
Table of Contents
About RPM and Dependencies
Each RPM package contains metadata about the software, including what dependencies it has. When you attempt to install a package, RPM checks the dependencies listed in the package against the software already installed on your server. If all dependencies are met, the installation proceeds. If not, the installation fails, and RPM tells you what dependencies are missing.
Example – Apache HTTP dependency management
Let’s deep-dive to a real-world example with the Apache HTTP package. We’ll take a closer look at the process of installing this package on a CentOS system. Note that the names of Apache packages may vary across different Linux distributions; for CentOS, it is
The Apache HTTP Server depends on various libraries and packages. Here are some key dependencies:
- apr: Apache Portable Runtime library
- apr-util: Apache Portable Runtime Utility library
- centos-logos: CentOS-related icons and graphics, used by Apache’s default welcome page
- httpd-tools: Tools for use with the Apache HTTP Server
- mailcap: Helps the server identify MIME types
- systemd: System and service manager
- shadow-utils: Utilities for managing accounts and shadow password files.
This is not an exhaustive list, as the Apache HTTP Server might have other dependencies depending on the features you want to enable.
Installation – Under the hood
We’ll use the
yum command to install the Apache HTTP Server, as it automatically resolves and installs all dependencies. Here’s how to do it:
sudo yum install httpd
During the installation process,
yum checks for the dependencies required by Apache. If they’re not already installed,
yum presents a list of all packages it will install or update to meet the dependencies. It will then prompt you for confirmation before proceeding. This is what it looks like:
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.37-21.el8 AppStream 1.4 M Installing dependencies: apr x86_64 1.6.3-9.el8 AppStream 125 k apr-util x86_64 1.6.1-6.el8 AppStream 92 k centos-logos x86_64 80.5-2.el8 BaseOS 13 M httpd-tools x86_64 2.4.37-21.el8 AppStream 104 k mailcap noarch 2.1.48-3.el8 BaseOS 39 k redhat-logos x86_64 80.5-2.el8 BaseOS 13 M systemd x86_64 239-30.el8_2 BaseOS 3.1 M Installing weak dependencies: apr-util-bdb x86_64 1.6.1-6.el8 AppStream 27 k apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
By giving you a detailed list and waiting for your confirmation,
yum ensures that the installation process is transparent and under your control. After you agree to the changes,
yum installs Apache and all its dependencies, ensuring a safe and smooth installation process.
Handling Dependencies During RPM Installation
During an RPM installation, the system must resolve all dependencies for the process to succeed. Dependency resolution is about finding and installing all packages that the software requires to function. For example, if you want to install a package named
program1.rpm, which depends on
lib2.rpm, RPM won’t proceed with the installation unless both libraries are already installed.
Let’s illustrate this with a step-by-step installation on CentOS:
- Install a package using RPM:
sudo rpm -i program1.rpm
lib2.rpmare not installed, RPM will output an error like:
error: Failed dependencies: lib1 is needed by program1 lib2 is needed by program1
- To resolve this, install the required libraries:
sudo rpm -i lib1.rpm lib2.rpm
- Then, retry installing the original package:
sudo rpm -i program1.rpm
This should go smoothly if
lib2.rpm don’t have dependencies of their own, or their dependencies are already installed. However, manual dependency resolution can get complicated for packages with many dependencies. Thankfully, we have tools like Yum and DNF that simplify the process.
Tools for Dependency Management
Yum and DNF are two tools that automatically manage dependencies during RPM installations on Fedora, CentOS, and RHEL.
In Ubuntu, you need to use Alien to convert the RPM package into a DEB package (native to Ubuntu), and then use APT (Advanced Package Tool) to handle dependencies.
Here’s a step-by-step guide for each distribution:
- Install Alien:
sudo apt-get install alien
- Convert the RPM package to DEB:
sudo alien program1.rpm
- Install the DEB package with APT:
sudo apt-get install ./program1.deb
Install the package with Yum:
sudo yum install program1.rpm
Install the package using DNF:
sudo dnf install package.rpm
In the end, managing dependencies might seem a daunting task, but with tools like RPM, Yum, DNF, Alien, and APT, the process becomes significantly simplified and manageable.
Frequently Asked Questions (FAQ)
How to ignore dependencies in RPM install command?
To install a package without dependencies in RPM-based Linux distributions, you can use the
--nodeps flag with the
rpm command. For example:
sudo rpm -i --nodeps package.rpm
Remember that this ignores dependencies and could cause the package to not function properly if it needs those dependencies.
How do I remove a package with all dependencies?
To remove a package along with its dependencies, you can use package managers like
dnf. For instance:
sudo yum autoremove package-name
sudo dnf autoremove package-name
These commands will remove the package and its unneeded dependencies. Be aware this may remove other packages that depend on the same libraries.
How to remove RPM package without dependencies?
To remove an RPM package without removing its dependencies, use the
rpm command with the
-e (erase) flag. For example:
sudo rpm -e --nodeps package-name
This command erases the specified package without affecting its dependencies. However, be cautious as this can leave unused libraries on your system.