Download A RPM Package With All Dependencies In CentOS

97.3K

We can download any package using curl or wget commands, right? However, these commands will not download the required dependencies. You may need to spend some time manually finding and downloading the dependencies required by the package to install. Well, not anymore! In this short tutorial, let’s see how to download an RPM package with all dependencies on CentOS. I tested this guide on CentOS 7, although the same steps could work on other RPM-based systems like RHEL, Fedora, AlmaLinux, and Rocky Linux.

Download an RPM package with all dependencies on CentOS

We can do this in two methods. Let’s use the Downloadonly plugin in the first method.

1. Download RPM packages with all dependencies using the “Downloadonly” plugin

We can easily download any RPM package with all dependencies using the “Downloadonly” plugin for

the yum command. To install the Downloadonly plugin, run the following command as root. # yum

install yum-plugin-downloadonly Now, run the following command

to download an RPM package.

# yum install -downloadonly <package-name>

By default, this command will download and save the packages to the /var/cache/yum/ location. However, you can download and save the packages to any location of your choice using the “-downloaddir” option.

# yum install -downloadonly -downloaddir=<directory> <package-name>Example:# yum install -downloadonly -downloaddir=/root/mypackages/ httpd

Sample output

😛 lugins loaded: fastestmirror Loading mirror speeds from cached host file * Base: centos.excellmedia.net * Epel: epel.mirror.angkasa.id * Extras: centos.excellmedia.net * Updates

:

centos.excellmedia.net Dependency Resolution -> Transaction Check Execution -> Package httpd.x86_64 will be installed 0:2.4.6-40.el7.centos.4 -> Processing dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Processing dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Processing dependency: libaprutil-1.so.0()(64bit) For the package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Processing dependency: libapr-1.so.0()(64bit) For package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Execution Transaction check -> Package will be installed apr.x86_64 0:1.4.8-3.el7 -> Package Apr-util.x86_64 0:0:000 1.5.2-6.el7 will be installed -> Package httpd-tools.x86_64 will be installed 0:2.4.6-40.el7.centos.4 -> Mailcap.noarch package 0:2.1.41-2.el7 -> Dependency resolution dependencies terminated Resolved =================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== ================================================================================================================================================================================================================================================================================================================================================================================================================================ ====x86_64================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== 4.6-40.el7.centos.4 updates 2.7 M Installation for dependencies: x86_64 Apr 1.4.8-3.el7 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.2.00 4.6-40.el7.centos.4 updates 83 k mailcap noarch 2.1.41-2.el7 base 31 k Transaction Summary===3.el7.x86_64=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== rpm===========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================01 (2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 KB 00:00:01 (3/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 KB 00:00:01 (4/5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 KB 00:00:01 (5/5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:09 – Total 331 kB/s | 3.0 MB 00:00:09 exiting because “Download Only” specified Now

go to the location you specified in the previous command. You will see there the downloaded package with all dependencies. In my case, I downloaded the packages to the /root/mypackages/ directory.

Let’s verify the content.

# ls /root/mypackages/

Sample output:

apr-1.4.8-3.el7.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm httpd-2.4.6-40.el7.centos.4.x86_64.rpm httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm mailcap-2.1.41-2.el7.noarch.rpm

As you can see from the above output, the httpd package has been downloaded with all dependencies.

Please note that this plugin is applicable for “yum install/yum update” and not for “yum groupinstall”. By default, this plugin will download the latest packages available in the repository. However, you can download a particular version by specifying the version.

Example

:# yum install -downloadonly -downloaddir=/root/mypackages/ httpd-2.2.6-40.el7

Also, you can download multiple packages at once as shown below

. # yum install -downloadonly -downloaddir=/root/mypackages/ httpd vsftpd

DownloadFree Guide: “10 Easy Ways to Restore Your Linux System”

2. Download

RPM packages with all dependencies using “Yumdownloader” utility Yumdownloader

is a simple but useful command line utility that downloads any RPM package along with all required dependencies at once. Install Yumdownloader

using the following command

as root.

# yum install yum-utils

Once installed, run the following command to download a package, for example httpd.

# yumdownloader httpd To download packages with all dependencies, use the -resolve:# yumdownloader -resolve httpd option By default, Yumdownloader will download the packages to the

current working directory.

To download packages along with all dependencies to a specific location, use the –

destdir

:

# yumdownloader -resolve -destdir=/root/mypackages/ httpd

option O

# yumdownloader -resolve -destdir /root/mypackages/ httpd

Sample output

😛 Lugins loaded: fastestmirror Loading mirror speeds from cached host file * base: centos.excellmedia.net * epel: epel.mirror.angkasa.id * Extras: centos.excellmedia.net * Updates: centos.excellmedia.net -> Execution of transaction verification -> The package will be installed httpd.x86_64 0:2.4.6-40.el7.centos.4 -> Processing dependency: httpd-tools = 2.4.6-40.el7.centos.4 For package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Processing dependency: /etc/mime.types For package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Processing dependency: libaprutil-1.so.0()(64bit) For package: httpd-2.4.6-40.el7.centos.4.x86_64 -> Processing dependency: libapr-1.so.0()(64bit) For the package: httpd-2.4.6-40.el7.centos.4.x86_64 -> running transaction check -> package will be installed apr.x86_64 0:1.4.8-3.el7 -> package apr-util.x86_64 will be installed 0:1.5.2-6.el7 -> package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed -> Mailcap.noarch package will be installed 0:2.1.41-2.el7 -> Dependency resolution completed (1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 KB 00:00:01 (2/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 KB 00:00:02 (3/5): Apr-1.4.8-3.el7.x86_64.rpm | 103 KB 00:00:02 (4/5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 KB 00:00:03 (5/5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:19

Let’s check if the packages have been downloaded to the specified location

. # ls /root/mypackages/

Sample output:

apr-1.4.8-3.el7.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm httpd-2.4.6-40.el7.centos.4.x86_64.rpm httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm mailcap-2.1.41-2.el7.noarch.rpm

Unlike the Downloadonly plugin, Yumdownload can download the packages related to a particular group.

# yumdownloader “@Development Tools” -resolve -destdir /root/mypackages/

Personally, I prefer Yumdownloader over the Downloadonly plugin for yum. But, both are easy and do the same job. You can choose one that suits you best.

Contact US