You may sometime need to download packages without installing them. This could become difficult and time consuming if there are multiple dependencies of the RPM packages you want to download. To save time and complexity, the following programs can be used to download a rpm package without installing it:

  • yum-downloadonly plugin allows “yum” to download packages without installing them
  • yumdownloader (part of yum-utils package)
  • repotrack or repoquery (part of yum-utils package)

 

Besides the above commands you can also use the basic “yum deplist” command to find the dependancy list for a RPM package. For example, to find the dependent packages for the “nano” rpm, use the below command.

# yum deplist nano
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.sfo12.us.leaseweb.net
 * epel: mirror.pnl.gov
 * extras: mirrors.xmission.com
 * nux-dextop: mirror.li.nux.ro
 * updates: mirror.pac-12.org
package: nano.x86_64 2.3.1-10.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-29.el7_4
  dependency: /sbin/install-info
   provider: info.x86_64 5.1-4.el7
  dependency: libc.so.6(GLIBC_2.14)(64bit)
   provider: glibc.x86_64 2.17-196.el7_4.2
  dependency: libncursesw.so.5()(64bit)
   provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
  dependency: libtinfo.so.5()(64bit)
   provider: ncurses-libs.x86_64 5.9-14.20130511.el7_4
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.17-196.el7_4.2
   provider: glibc.i686 2.17-196.el7_4.2

 

1. yumdownloader

 

The most commonly used program for downloading packages without installing them is “yumdownloader”. yumdownloader utility is particularly helpful if downloading a installed package. The yum-utils package provides yumdownloader utility. To install “yum-utils”:

# yum install yum-utils

 

The syntax of “yumdownloader” utility to download RPM along with its dependencies is:

# yumdownloader [options] package1 [package2] [package..]

 

For example, to download the RPM “firefox” and all its dependencies, use the below command.

# yumdownloader --destdir=/var/tmp/ --resolve firefox

 

Here,

–destdir –  the directory where you want the RPM packages to be saved to (defaults to the current directory if not specified).

–resolve – resolves dependencies and download required packages

 

yumdownloader program is a quite powerful tool to download packages when used with appropriate wildcards. For example:

# yumdownloader [a]*                (will download all available packages whose name starts with "a")
# yumdownloader [a-c]*              (will download all available packages whose name starts with "a", "b" and "c")
# yumdownloader glibc*              (will download all available packages whose name starts with "glibc")

 

NOTE:

Although there are commands which can be used to download the main package along with its dependencies, they will sometimes fail to download all packages. In that case, it is required to download the missing packages one by one.

– The package is saved in the current working directly by default; use the –destdir option to specify an alternate location.

– Be sure to add –resolve if you need to download dependencies.

 

2. repoquery / repotrack

 

Frequently used “yumdownloader –resolve” command to download the package along with its dependencies does not always successfully recognize all dependencies. It is better to use “repoquery” to find the dependencies and then use “yumdownloader” to download them.

 

For example you can use the repoquery command to find all the dependencies for the firefox RPM and then use the command output with “yumdownloader” for downloading the dependencies.

# repoquery -R --resolve --recursive firefox | xargs -r yumdownloader 

 

You can also use the “repotrack” utility to download the RPM along with all its dependencies. For Example:

# repotrack firefox

 

3. yum-downloadonly plugin for yum

 

The “yum-downloadonly” plugin allows “yum” to download packages without installing them. Install the package including “downloadonly” plugin:

(CentOS/RHEL 5)
# yum install yum-downloadonly

(CentOS/RHEL 6,7)
# yum install yum-plugin-downloadonly

 

Run yum command with “–downloadonly” option as follows:

# yum install --downloadonly --downloaddir=[directory] [package]

 

Notes about yum-downloadonly plugin:

 

– Before using the plugin, check /etc/yum/pluginconf.d/downloadonly.conf to confirm that this plugin is “enabled=1”

– This is applicable for “yum install/yum update” and not for “yum groupinstall”. Use “yum groupinfo” to identify packages within a specific group.

– If only the package name is specified, the latest available package is downloaded (such as sshd). Otherwise, you can specify the full package name and version (such as httpd-2.2.3-22.el5).

– If desired, you can download multiple packages on the same command.

– You still need to re-download the repodata if the repodata expires before you re-use the cache. By default it takes two hours to expire.

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)