Downloading RPM Packages with dependencies [ yumdownloader Vs yum-downloadonly Vs repoquery]

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 beow command.

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

Here,
–destdir is the directory where you want the RPM packages to be saved to (defaults to current directory if not specified).
–resolve – resolves dependencies and download required packages

yumdownloader program is 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.

Note

:
– 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.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值