
In Linux, we can download any package using curl or wget commands. These commands, however, won’t download the required dependencies for rpm packages. You will need to spend more time to manually search and download the dependencies required by the package. Well not anymore! In this article, I will walk you through how to download an RPM package with all dependencies using the ‘yumdownloader’ utility.
yumdownloader is a program used for downloading RPMs from Yum repositories. Using this utility we can easily download rpm packages along with its dependencies. As its name suggests it will not install the package but only perform downloads. I tested this guide on CentOS 7.x / RHEL 7.x, although the same steps might work on other RPM-based Linux distros such as RHEL, Fedora and Scientific Linux.
Install the YumDownloader Utility
Let’s first install the yumdownloader utility.
Open the terminal and the run below yum command to install the yumdownloader utility.
# yum install yum-utils
Download Packages
Once done with the installation, run the following command to download a package. Let’s assume that we want to download httpd server rpm packages. Run the following command for this download.
# yumdownloader httpd
To download packages with all dependencies, you have to use –resolve option:
–resolve option in yumdownloader will resolve the dependency and download the required packages.
# yumdownloader --resolve httpd
Download Package At Specific Location
By default, yumdownloader downloads the packages in the current working directory.
To download packages with all dependencies to a specific location, use –destdir option:
–destdir option in the yumdownloader command is used to specify the path of the directory where we want to put the downloaded rpms.
# yumdownloader --resolve --destdir=/root/mypackages/ httpd Or
# yumdownloader --resolve --destdir /root/mypackages/ httpd
Sample output:
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: epel.mirror.angkasa.id * extras: centos.excellmedia.net * updates: centos.excellmedia.net --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed --> 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 package: httpd-2.4.6-40.el7.centos.4.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed --> Finished Dependency Resolution (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 confirm whether packages have been downloaded in the specified location or not.
# 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
Download the packages related to a particular group
The Yumdownload utility can download the packages related to a particular group as well.
If you want to download all the packages which come under the group “Development Tools” then run below command in terminal.
# yumdownloader "@Development Tools" --resolve --destdir /root/mypackages/
That’s all!!