如何下载rpm软件包和所有依赖项(RHEL/CentOS 7)

时间:2020-01-09 10:38:14  来源:igfitidea点击:

在本文中,我将分享"下载rpm软件包和所有依赖项的步骤",这样我们就不必为单独下载rpm的依赖项而烦恼。

这些是我们可以用来执行此操作的一些命令

  • yumdownloader

  • repotrack

准备工作

yumdownloader和repotrack都是yum-utils rpm的一部分,因此在开始使用这些工具之前,请先安装此rpm。

说明:

在RHEL系统上,我们必须具有RHN的活动订阅,或者我们可以配置本地脱机存储库," yum"程序包管理器可以使用该本地存储库安装所提供的rpm及其依赖项。

# yum install -y yum-utils

使用yumdownloader下载rpm包和所有依赖项

以下是下载rpm软件包及其所有依赖项的命令

# yumdownloader  --downloadonly --downloaddir=. glibc --resolve
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
No Match for argument .
--> Running transaction check
---> Package glibc.i686 0:2.17-222.el7 will be installed
--> Processing Dependency: glibc-common = 2.17-222.el7 for package: glibc-2.17-222.el7.i686
--> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.17-222.el7.i686
--> Processing Dependency: libfreebl3.so for package: glibc-2.17-222.el7.i686
---> Package glibc.x86_64 0:2.17-222.el7 will be installed
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-196.el7 will be updated
--> Processing Dependency: glibc-common = 2.17-196.el7 for package: glibc-2.17-196.el7.x86_64
---> Package glibc-common.x86_64 0:2.17-222.el7 will be an update
---> Package nss-softokn-freebl.x86_64 0:3.28.3-6.el7 will be updated
---> Package nss-softokn-freebl.i686 0:3.36.0-5.el7_5 will be installed
--> Processing Dependency: nss-util >= 3.36.0-1 for package: nss-softokn-freebl-3.36.0-5.el7_5.i686
--> Processing Dependency: nspr >= 4.19.0 for package: nss-softokn-freebl-3.36.0-5.el7_5.i686
---> Package nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.17-196.el7 will be updated
--> Processing Dependency: glibc = 2.17-196.el7 for package: glibc-headers-2.17-196.el7.x86_64
--> Processing Dependency: glibc = 2.17-196.el7 for package: glibc-devel-2.17-196.el7.x86_64
---> Package nspr.x86_64 0:4.13.1-1.0.el7_3 will be updated
---> Package nspr.x86_64 0:4.19.0-1.el7_5 will be an update
---> Package nss-util.x86_64 0:3.28.4-3.el7 will be updated
---> Package nss-util.x86_64 0:3.36.0-1.el7_5 will be an update
--> Running transaction check
---> Package glibc-devel.x86_64 0:2.17-196.el7 will be updated
---> Package glibc-devel.x86_64 0:2.17-222.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-196.el7 will be updated
---> Package glibc-headers.x86_64 0:2.17-222.el7 will be an update
--> Finished Dependency Resolution
(1/2): nss-softokn-freebl-3.36.0-5.el7_5.i686.rpm                                                                                                                             | 211 kB  00:00:00
(2/2): glibc-2.17-222.el7.i686.rpm                                                                                                                                            | 4.2 MB  00:00:01
exiting because "Download Only" specified

例如,我其中下载glibc及其所有依赖项rpms

# yumdownloader --downloadonly --downloaddir=/tmp/glibc --resolve

说明:

此命令用于下载软件包及其依赖项,并不总是能够成功识别所有依赖项。
最好使用repoquery查找依赖项,然后使用yumdownloader下载它们。

# repoquery -R --resolve --recursive glibc |xargs -r yumdownloader
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
No Presto metadata available for base
(1/27): basesystem-10.0-7.el7.centos.noarch.rpm                                                                                                                               | 5.0 kB  00:00:00
(2/27): centos-release-7-5.1804.el7.centos.x86_64.rpm                                                                                                                         |  24 kB  00:00:00
(3/27): chkconfig-1.7.4-1.el7.x86_64.rpm                                                                                                                                      | 181 kB  00:00:00
(4/27): gmp-6.0.0-15.el7.i686.rpm                                                                                                                                             | 416 kB  00:00:00
(5/27): gawk-4.0.2-4.el7_3.1.x86_64.rpm                                                                                                                                       | 874 kB  00:00:00
(6/27): gmp-6.0.0-15.el7.x86_64.rpm                                                                                                                                           | 281 kB  00:00:00
(7/27): keyutils-libs-1.5.8-3.el7.i686.rpm                                                                                                                                    |  25 kB  00:00:00
(8/27): keyutils-libs-1.5.8-3.el7.x86_64.rpm                                                                                                                                  |  25 kB  00:00:00
(9/27): libcap-2.22-9.el7.x86_64.rpm                                                                                                                                          |  47 kB  00:00:00
(10/27): grep-2.20-3.el7.x86_64.rpm                                                                                                                                           | 344 kB  00:00:00
(11/27): libffi-3.0.13-18.el7.i686.rpm                                                                                                                                        |  27 kB  00:00:00
(12/27): libffi-3.0.13-18.el7.x86_64.rpm                                                                                                                                      |  30 kB  00:00:00
(13/27): libverto-0.2.5-4.el7.x86_64.rpm                                                                                                                                      |  16 kB  00:00:00
(14/27): libgcc-4.8.5-28.el7_5.1.i686.rpm                                                                                                                                     | 108 kB  00:00:00
(15/27): libtasn1-4.10-1.el7.x86_64.rpm                                                                                                                                       | 320 kB  00:00:00
(16/27): nss-softokn-freebl-3.34.0-2.el7.i686.rpm                                                                                                                             | 206 kB  00:00:00
(17/27): nspr-4.19.0-1.el7_5.i686.rpm                                                                                                                                         | 128 kB  00:00:00
(18/27): nss-softokn-freebl-3.34.0-2.el7.x86_64.rpm                                                                                                                           | 220 kB  00:00:00
(19/27): p11-kit-0.23.5-3.el7.i686.rpm                                                                                                                                        | 241 kB  00:00:00
(20/27): nss-util-3.36.0-1.el7_5.i686.rpm                                                                                                                                     |  76 kB  00:00:00
(21/27): p11-kit-trust-0.23.5-3.el7.x86_64.rpm                                                                                                                                | 129 kB  00:00:00
(22/27): p11-kit-0.23.5-3.el7.x86_64.rpm                                                                                                                                      | 252 kB  00:00:00
(23/27): pcre-8.32-17.el7.i686.rpm                                                                                                                                            | 420 kB  00:00:00
(24/27): popt-1.13-16.el7.x86_64.rpm                                                                                                                                          |  42 kB  00:00:00
(25/27): pcre-8.32-17.el7.x86_64.rpm                                                                                                                                          | 422 kB  00:00:00
(26/27): zlib-1.2.7-17.el7.x86_64.rpm                                                                                                                                         |  90 kB  00:00:00
(27/27): sed-4.2.2-5.el7.x86_64.rpm                                                                                                                                           | 231 kB  00:00:00

该命令将在我们当前的工作目录中下载glibcrpm及其所有依赖项。
因此,如我们所见,该命令能够成功获取更大的依赖项列表,而当我们仅使用yumdownloader时,该列表被跳过。

使用repotrack下载rpm包和所有依赖项

repotrack是一个用于跟踪特定程序包及其依赖关系的程序。
它将下载一个或者多个软件包以及所有依赖项。

使用以下命令,我在当前目录中使用repotrack下载glibc及其所有依赖项。

# repotrack glibc
Downloading basesystem-10.0-7.el7.centos.noarch.rpm
Downloading bash-4.2.46-30.el7.x86_64.rpm
Downloading ca-certificates-2016.2.22-70.0.el7_5.noarch.rpm
Downloading centos-release-7-5.1804.4.el7.centos.x86_64.rpm
Downloading chkconfig-1.7.4-1.el7.x86_64.rpm
Downloading coreutils-8.22-21.el7.x86_64.rpm
Downloading filesystem-3.2-25.el7.x86_64.rpm
Downloading gawk-4.0.2-4.el7_3.1.x86_64.rpm
Downloading glibc-2.17-222.el7.i686.rpm
Downloading glibc-2.17-222.el7.x86_64.rpm
Downloading glibc-common-2.17-222.el7.x86_64.rpm
Downloading gmp-6.0.0-15.el7.i686.rpm
Downloading gmp-6.0.0-15.el7.x86_64.rpm
Downloading grep-2.20-3.el7.x86_64.rpm
Downloading info-5.1-5.el7.x86_64.rpm
Downloading keyutils-libs-1.5.8-3.el7.i686.rpm
Downloading keyutils-libs-1.5.8-3.el7.x86_64.rpm
Downloading krb5-libs-1.15.1-19.el7.x86_64.rpm
Downloading libacl-2.2.51-14.el7.x86_64.rpm
Downloading libattr-2.4.46-13.el7.x86_64.rpm
Downloading libcap-2.22-9.el7.x86_64.rpm
Downloading libcom_err-1.42.9-12.el7_5.x86_64.rpm
Downloading libffi-3.0.13-18.el7.i686.rpm
Downloading libffi-3.0.13-18.el7.x86_64.rpm
Downloading libgcc-4.8.5-28.el7_5.1.i686.rpm
Downloading libgcc-4.8.5-28.el7_5.1.x86_64.rpm
Downloading libselinux-2.5-12.el7.x86_64.rpm
Downloading libsepol-2.5-8.1.el7.x86_64.rpm
Downloading libstdc++-4.8.5-28.el7_5.1.i686.rpm
Downloading libstdc++-4.8.5-28.el7_5.1.x86_64.rpm
Downloading libtasn1-4.10-1.el7.x86_64.rpm
Downloading libverto-0.2.5-4.el7.x86_64.rpm
Downloading ncurses-5.9-14.20130511.el7_4.x86_64.rpm
Downloading ncurses-base-5.9-14.20130511.el7_4.noarch.rpm
Downloading ncurses-libs-5.9-14.20130511.el7_4.x86_64.rpm
Downloading nspr-4.19.0-1.el7_5.i686.rpm
Downloading nspr-4.19.0-1.el7_5.x86_64.rpm
Downloading nss-softokn-freebl-3.36.0-5.el7_5.i686.rpm
Downloading nss-softokn-freebl-3.36.0-5.el7_5.x86_64.rpm
Downloading nss-util-3.36.0-1.el7_5.x86_64.rpm
Downloading nss-util-3.36.0-1.el7_5.i686.rpm
Downloading openssl-libs-1.0.2k-12.el7.x86_64.rpm
Downloading p11-kit-0.23.5-3.el7.i686.rpm
Downloading p11-kit-0.23.5-3.el7.x86_64.rpm
Downloading p11-kit-trust-0.23.5-3.el7.x86_64.rpm
Downloading pcre-8.32-17.el7.x86_64.rpm
Downloading pcre-8.32-17.el7.i686.rpm
Downloading popt-1.13-16.el7.x86_64.rpm
Downloading sed-4.2.2-5.el7.x86_64.rpm
Downloading setup-2.8.71-9.el7.noarch.rpm
Downloading tzdata-2016e-3.el7.noarch.rpm
Downloading zlib-1.2.7-17.el7.x86_64.rpm

此命令还可以成功下载glibc rpm的所有依赖项列表。