Print Friendly, PDF & Email
Sometimes you may need to download RPM packages without installing them. It could become too challenging and time-consuming for manual downloading if multiple dependencies of the RPM packages exist.
GOAL

To download packages with all their dependencies without installing them.

RELATED

HOW TO CREATE A LOCAL YUM REPOSITORY CONTAINING MANUALLY DOWNLOADED RPM PACKAGES

SOLUTION

For this purpse, you can use both the downloadonly plugin for yum and the yumdownloader utility.

DEMO

Create a directory for storing downloaded packages

[root@dbpilot ~] mkdir /oracle/prerequesits
The downloadonly plugin for yum

Install the downloadonly plugin for yum

# (RHEL5)
# yum install yum-downloadonly

# (RHEL6)
# yum install yum-plugin-downloadonly

# (RHEL7)
# In RHEL7 downloadonly is included in the yum itseft

Download package you need to the previously created directory. For instance, the vim package.

# (RHEL5 and RHEL6)
# yum install --downloadonly --downloaddir=/oracle/prerequesits vim

# (RHEL7)
# yum install --downloadonly --downloaddir=/oracle/prerequesits vim
[root@dbpilot ~] yum reinstall --downloadonly --downloaddir=/oracle/prerequesits vim
Loaded plugins: ulninfo
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.160-1.el7 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================
 Package                Arch             Version                     Repository                        Size
============================================================================================================
Reinstalling:
 vim-enhanced           x86_64           2:7.4.160-1.el7             OEL73_x64_NETWORK_REPO           1.0 M

Transaction Summary
============================================================================================================
Reinstall  1 Package

Total download size: 1.0 M
Installed size: 2.2 M
Background downloading packages, then exiting:
vim-enhanced-7.4.160-1.el7.x86_64.rpm                                                | 1.0 MB  00:00:00
exiting because "Download Only" specified

Verify that downloaded vim package exists in the directory

[root@dbpilot ~] ls /oracle/prerequesits
vim-enhanced-7.4.160-1.el7.x86_64.rpm
NOTE

In the RHEL7, if your package is already installed on a host you have to use the reinstall option to download it. Otherwise it fails.

The yumdownloader utility

Install the package by the following command

[root@dbpilot ~] yum install yum-utils

Download package you need to the previously created directory. For instance, the mlocate package.

[root@dbpilot ~] yumdownloader --destdir=/oracle/prerequesits --resolve mlocate
--> Running transaction check
---> Package mlocate.x86_64 0:0.26-6.el7 will be reinstalled
--> Finished Dependency Resolution
mlocate-0.26-6.el7.x86_64.rpm                                   | 112 kB  00:00:00

Verify that downloaded mlocate package exists in the directory

[root@dbpilot ~] ls /oracle/prerequesits
mlocate-0.26-6.el7.x86_64.rpm  vim-enhanced-7.4.160-1.el7.x86_64.rpm

Written At
05 FEB 201813:00
Red Hat Release
5.x-7.x x64