Yum自动下载RPM包及其所有依赖的包
前几天我尝试去创建一个仅包含我们经常在 CentOS 7 下使用的软件的本地仓库。当然,我们可以使用 curl 或者 wget 下载任何软件包,然而这些命令并不能下载要求的依赖软件包。你必须去花一些时间而且手动的去寻找和下载被安装的软件所依赖的软件包。然而,我们并不是必须这样。在这个简短的教程中,我将会带领你以两种方式下载软件包及其所有依赖包。我已经在 CentOS 7 下进行了测试,不过这些相同的步骤或许在其他基于 RPM 管理系统的发行版上也可以工作,例如 RHEL,Fedora 和 Scientific Linux。
方法1利用"Downloadonly"插件下载 RPM 软件包及其所有依赖包
我们可以通过 yum 命令的 “Downloadonly” 插件下载 RPM 软件包及其所有依赖包, 为了安装 Downloadonly 插件,以 root 身份运行以下命令:
yum install yum-plugin-downloadonly
现在,运行以下命令去下载一个 RPM 软件包
yum install --downloadonly <package-name>
默认情况下,这个命令将会下载并把软件包保存到 /var/cache/yum/ 的 rhel-{arch}-channel/packageslocation 目录,不过,你也可以下载和保存软件包到任何位置,你可以通过 –downloaddir 选项来指定。
yum install --downloadonly --downloaddir=<directory> <package-name>
例子:
yum install --downloadonly --downloaddir=/root/mypackages/ nginx
终端输出:
Loaded plugins: fastestmirror
base | 3.6 kB ::
epel/x86_64/metalink | 5.7 kB ::
epel | 4.7 kB ::
extras | 3.4 kB ::
updates | 3.4 kB ::
(/): updates//x86_64/primary_db | 3.6 MB ::
(/): epel/x86_64/updateinfo | kB ::
(/): epel/x86_64/primary_db | 6.1 MB ::
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 :1.12.-.el7 will be installed
--> Processing Dependency: nginx-all-modules = :1.12.-.el7 for package: :nginx-1.12.-.el7.x86_64
--> Processing Dependency: nginx-filesystem = :1.12.-.el7 for package: :nginx-1.12.-.el7.x86_64
--> Processing Dependency: libcrypto.so.(OPENSSL_1.0.2)(64bit) for package: :nginx-1.12.-.el7.x86_64
--> Processing Dependency: nginx-filesystem for package: :nginx-1.12.-.el7.x86_64
--> Processing Dependency: libprofiler.so.()(64bit) for package: :nginx-1.12.-.el7.x86_64
--> Running transaction check
---> Package gperftools-libs.x86_64 :2.4-.el7 will be installed
--> Processing Dependency: libunwind.so.()(64bit) for package: gperftools-libs-2.4-.el7.x86_64
---> Package nginx-all-modules.noarch :1.12.-.el7 will be installed
--> Processing Dependency: nginx-mod-http-geoip = :1.12.-.el7 for package: :nginx-all-modules-1.12.-.el7.noarch
--> Processing Dependency: nginx-mod-http-image-filter = :1.12.-.el7 for package: :nginx-all-modules-1.12.-.el7.noarch
--> Processing Dependency: nginx-mod-http-perl = :1.12.-.el7 for package: :nginx-all-modules-1.12.-.el7.noarch
--> Processing Dependency: nginx-mod-http-xslt-filter = :1.12.-.el7 for package: :nginx-all-modules-1.12.-.el7.noarch
--> Processing Dependency: nginx-mod-mail = :1.12.-.el7 for package: :nginx-all-modules-1.12.-.el7.noarch
--> Processing Dependency: nginx-mod-stream = :1.12.-.el7 for package: :nginx-all-modules-1.12.-.el7.noarch
---> Package nginx-filesystem.noarch :1.12.-.el7 will be installed
---> Package openssl-libs.x86_64 :1.0.1e-.el7. will be updated
--> Processing Dependency: openssl-libs(x86-) = :1.0.1e-.el7. for package: :openssl-1.0.1e-.el7..x86_64
---> Package openssl-libs.x86_64 :1.0.2k-.el7 will be an update
--> Running transaction check
---> Package libunwind.x86_64 :1.2-.el7 will be installed
---> Package nginx-mod-http-geoip.x86_64 :1.12.-.el7 will be installed
--> Processing Dependency: GeoIP for package: :nginx-mod-http-geoip-1.12.-.el7.x86_64
--> Processing Dependency: libGeoIP.so.()(64bit) for package: :nginx-mod-http-geoip-1.12.-.el7.x86_64
---> Package nginx-mod-http-image-filter.x86_64 :1.12.-.el7 will be installed
--> Processing Dependency: gd for package: :nginx-mod-http-image-filter-1.12.-.el7.x86_64
--> Processing Dependency: libgd.so.()(64bit) for package: :nginx-mod-http-image-filter-1.12.-.el7.x86_64
---> Package nginx-mod-http-perl.x86_64 :1.12.-.el7 will be installed
---> Package nginx-mod-http-xslt-filter.x86_64 :1.12.-.el7 will be installed
--> Processing Dependency: libxslt.so.(LIBXML2_1.0.11)(64bit) for package: :nginx-mod-http-xslt-filter-1.12.-.el7.x86_64
--> Processing Dependency: libxslt.so.(LIBXML2_1.0.18)(64bit) for package: :nginx-mod-http-xslt-filter-1.12.-.el7.x86_64
--> Processing Dependency: libexslt.so.()(64bit) for package: :nginx-mod-http-xslt-filter-1.12.-.el7.x86_64
--> Processing Dependency: libxslt.so.()(64bit) for package: :nginx-mod-http-xslt-filter-1.12.-.el7.x86_64
---> Package nginx-mod-mail.x86_64 :1.12.-.el7 will be installed
---> Package nginx-mod-stream.x86_64 :1.12.-.el7 will be installed
---> Package openssl.x86_64 :1.0.1e-.el7. will be updated
---> Package openssl.x86_64 :1.0.2k-.el7 will be an update
--> Running transaction check
---> Package GeoIP.x86_64 :1.5.-.el7 will be installed
---> Package gd.x86_64 :2.0.-.el7 will be installed
--> Processing Dependency: libpng15.so.(PNG15_0)(64bit) for package: gd-2.0.-.el7.x86_64
--> Processing Dependency: libjpeg.so.(LIBJPEG_6.)(64bit) for package: gd-2.0.-.el7.x86_64
--> Processing Dependency: libpng15.so.()(64bit) for package: gd-2.0.-.el7.x86_64
--> Processing Dependency: libjpeg.so.()(64bit) for package: gd-2.0.-.el7.x86_64
--> Processing Dependency: libfontconfig.so.()(64bit) for package: gd-2.0.-.el7.x86_64
--> Processing Dependency: libXpm.so.()(64bit) for package: gd-2.0.-.el7.x86_64
--> Processing Dependency: libX11.so.()(64bit) for package: gd-2.0.-.el7.x86_64
---> Package libxslt.x86_64 :1.1.-.el7 will be installed
--> Running transaction check
---> Package fontconfig.x86_64 :2.10.-.el7 will be installed
--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.10.-.el7.x86_64
--> Processing Dependency: font(:lang=en) for package: fontconfig-2.10.-.el7.x86_64
---> Package libX11.x86_64 :1.6.-.el7 will be installed
--> Processing Dependency: libX11-common >= 1.6.-.el7 for package: libX11-1.6.-.el7.x86_64
--> Processing Dependency: libxcb.so.()(64bit) for package: libX11-1.6.-.el7.x86_64
---> Package libXpm.x86_64 :3.5.-.el7 will be installed
---> Package libjpeg-turbo.x86_64 :1.2.-.el7 will be installed
---> Package libpng.x86_64 :1.5.-.el7_2 will be installed
--> Running transaction check
---> Package fontpackages-filesystem.noarch :1.44-.el7 will be installed
---> Package libX11-common.noarch :1.6.-.el7 will be installed
---> Package libxcb.x86_64 :1.12-.el7 will be installed
--> Processing Dependency: libXau.so.()(64bit) for package: libxcb-1.12-.el7.x86_64
---> Package lyx-fonts.noarch :2.2.-.el7 will be installed
--> Running transaction check
---> Package libXau.x86_64 :1.0.-2.1.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================================================================
Installing:
nginx x86_64 :1.12.-.el7 epel k
Installing for dependencies:
GeoIP x86_64 1.5.-.el7 base 1.1 M
fontconfig x86_64 2.10.-.el7 base k
fontpackages-filesystem noarch 1.44-.el7 base 9.9 k
gd x86_64 2.0.-.el7 base k
gperftools-libs x86_64 2.4-.el7 base k
libX11 x86_64 1.6.-.el7 base k
libX11-common noarch 1.6.-.el7 base k
libXau x86_64 1.0.-2.1.el7 base k
libXpm x86_64 3.5.-.el7 base k
libjpeg-turbo x86_64 1.2.-.el7 base k
libpng x86_64 :1.5.-.el7_2 base k
libunwind x86_64 :1.2-.el7 base k
libxcb x86_64 1.12-.el7 base k
libxslt x86_64 1.1.-.el7 base k
lyx-fonts noarch 2.2.-.el7 epel k
nginx-all-modules noarch :1.12.-.el7 epel k
nginx-filesystem noarch :1.12.-.el7 epel k
nginx-mod-http-geoip x86_64 :1.12.-.el7 epel k
nginx-mod-http-image-filter x86_64 :1.12.-.el7 epel k
nginx-mod-http-perl x86_64 :1.12.-.el7 epel k
nginx-mod-http-xslt-filter x86_64 :1.12.-.el7 epel k
nginx-mod-mail x86_64 :1.12.-.el7 epel k
nginx-mod-stream x86_64 :1.12.-.el7 epel k
Updating for dependencies:
openssl x86_64 :1.0.2k-.el7 base k
openssl-libs x86_64 :1.0.2k-.el7 base 1.2 M Transaction Summary
====================================================================================================================================================================================================================================
Install Package (+ Dependent packages)
Upgrade ( Dependent packages) Total download size: 6.0 M
Background downloading packages, then exiting:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(/): fontpackages-filesystem-1.44-.el7.noarch.rpm | 9.9 kB ::
(/): fontconfig-2.10.-.el7.x86_64.rpm | kB ::
(/): gd-2.0.-.el7.x86_64.rpm | kB ::
(/): libX11-1.6.-.el7.x86_64.rpm | kB ::
(/): libX11-common-1.6.-.el7.noarch.rpm | kB ::
(/): libXau-1.0.-2.1.el7.x86_64.rpm | kB ::
(/): libXpm-3.5.-.el7.x86_64.rpm | kB ::
(/): libjpeg-turbo-1.2.-.el7.x86_64.rpm | kB ::
(/): libpng-1.5.-.el7_2.x86_64.rpm | kB ::
(/): libunwind-1.2-.el7.x86_64.rpm | kB ::
(/): libxcb-1.12-.el7.x86_64.rpm | kB ::
(/): libxslt-1.1.-.el7.x86_64.rpm | kB ::
warning: /root/mypackages/lyx-fonts-2.2.-.el7.noarch.rpm..tmp: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for lyx-fonts-2.2.-.el7.noarch.rpm..tmp is not installed
(/): lyx-fonts-2.2.-.el7.noarch.rpm | kB ::
(/): GeoIP-1.5.-.el7.x86_64.rpm | 1.1 MB ::
(/): nginx-filesystem-1.12.-.el7.noarch.rpm | kB ::
(/): nginx-mod-http-image-filter-1.12.-.el7.x86_64.rpm | kB ::
(/): nginx-all-modules-1.12.-.el7.noarch.rpm | kB ::
(/): nginx-mod-http-perl-1.12.-.el7.x86_64.rpm | kB ::
(/): nginx-mod-http-xslt-filter-1.12.-.el7.x86_64.rpm | kB ::
(/): nginx-mod-stream-1.12.-.el7.x86_64.rpm | kB ::
(/): nginx-mod-mail-1.12.-.el7.x86_64.rpm | kB ::
(/): nginx-1.12.-.el7.x86_64.rpm | kB ::
(/): openssl-1.0.2k-.el7.x86_64.rpm | kB ::
(/): openssl-libs-1.0.2k-.el7.x86_64.rpm | 1.2 MB ::
(/): nginx-mod-http-geoip-1.12.-.el7.x86_64.rpm | kB ::
(/): gperftools-libs-2.4-.el7.x86_64.rpm | kB ::
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total kB/s | 6.0 MB ::
exiting because "Download Only" specified
现在去你指定的目录位置下,你将会看到那里有下载好的软件包和依赖的软件。在我这种情况下,我已经把软件包下载到 /root/mypackages/ 目录下。
让我们来查看一下内容:
[root@node76 ~]# ls mypackages/
fontconfig-2.10.-.el7.x86_64.rpm libpng-1.5.-.el7_2.x86_64.rpm libXpm-3.5.-.el7.x86_64.rpm nginx-mod-http-geoip-1.12.-.el7.x86_64.rpm openssl-1.0.2k-.el7.x86_64.rpm
fontpackages-filesystem-1.44-.el7.noarch.rpm libunwind-1.2-.el7.x86_64.rpm libxslt-1.1.-.el7.x86_64.rpm nginx-mod-http-image-filter-1.12.-.el7.x86_64.rpm openssl-libs-1.0.2k-.el7.x86_64.rpm
gd-2.0.-.el7.x86_64.rpm libX11-1.6.-.el7.x86_64.rpm lyx-fonts-2.2.-.el7.noarch.rpm nginx-mod-http-perl-1.12.-.el7.x86_64.rpm
GeoIP-1.5.-.el7.x86_64.rpm libX11-common-1.6.-.el7.noarch.rpm nginx-1.12.-.el7.x86_64.rpm nginx-mod-http-xslt-filter-1.12.-.el7.x86_64.rpm
gperftools-libs-2.4-.el7.x86_64.rpm libXau-1.0.-2.1.el7.x86_64.rpm nginx-all-modules-1.12.-.el7.noarch.rpm nginx-mod-mail-1.12.-.el7.x86_64.rpm
libjpeg-turbo-1.2.-.el7.x86_64.rpm libxcb-1.12-.el7.x86_64.rpm nginx-filesystem-1.12.-.el7.noarch.rpm nginx-mod-stream-1.12.-.el7.x86_64.rpm
正如你在上面输出所看到的, nginx软件包已经被依据所有依赖性下载完成了 。
请注意,这个插件适用于 yum install/yum update, 但是并不适用于 yum groupinstall。默认情况下,这个插件将会下载仓库中最新可用的软件包。然而你可以通过指定版本号来下载某个特定的软件版本。
例子:
yum install --downloadonly --downloaddir=/root/mypackages/ httpd-2.2.-.el7
此外,你也可以如下一次性下载多个包:
yum install --downloadonly --downloaddir=/root/mypackages/ httpd vsftpd
方法 2 使用 "Yumdownloader"工具来下载 RPM 软件包及其所有依赖包
“Yumdownloader” 是一款简单,但是却十分有用的命令行工具,它可以一次性下载任何 RPM 软件包及其所有依赖包。
以 root 身份运行如下命令安装 “Yumdownloader” 工具。
yum install yum-utils
一旦安装完成,运行如下命令去下载一个软件包,例如 httpd:
yumdownloader httpd
为了根据所有依赖性下载软件包,我们使用 --resolve 参数:
yumdownloader --resolve httpd
默认情况下,Yumdownloader 将会下载软件包到当前工作目录下。
为了将软件下载到一个特定的目录下,我们使用 --destdir 参数:
yumdownloader --resolve --destdir=/root/mypackages/ httpd
或者:
yumdownloader --resolve --destdir /root/mypackages/ httpd
终端输出:
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 :2.4.-.el7.centos. will be installed
--> Processing Dependency: httpd-tools = 2.4.-.el7.centos. for package: httpd-2.4.-.el7.centos..x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.-.el7.centos..x86_64
--> Processing Dependency: libaprutil-.so.()(64bit) for package: httpd-2.4.-.el7.centos..x86_64
--> Processing Dependency: libapr-.so.()(64bit) for package: httpd-2.4.-.el7.centos..x86_64
--> Running transaction check
---> Package apr.x86_64 :1.4.-.el7 will be installed
---> Package apr-util.x86_64 :1.5.-.el7 will be installed
---> Package httpd-tools.x86_64 :2.4.-.el7.centos. will be installed
---> Package mailcap.noarch :2.1.-.el7 will be installed
--> Finished Dependency Resolution
(/): apr-util-1.5.-.el7.x86_64.rpm | kB ::
(/): mailcap-2.1.-.el7.noarch.rpm | kB ::
(/): apr-1.4.-.el7.x86_64.rpm | kB ::
(/): httpd-tools-2.4.-.el7.centos..x86_64.rpm | kB ::
(/): httpd-2.4.-.el7.centos..x86_64.rpm | 2.7 MB ::
让我们确认一下软件包是否被下载到我们指定的目录下:
ll /root/mypackages/
apr-1.4.-.el7.x86_64.rpm
apr-util-1.5.-.el7.x86_64.rpm
httpd-2.4.-.el7.centos..x86_64.rpm
httpd-tools-2.4.-.el7.centos..x86_64.rpm
mailcap-2.1.-.el7.noarch.rpm
不像 Downloadonly 插件,Yumdownload 可以下载一组相关的软件包。
yumdownloader "@Development Tools" --resolve --destdir /root/mypackages/
Yum自动下载RPM包及其所有依赖的包的更多相关文章
- CentOS yum安装软件时保留安装包及依赖包或者自动下载安装包及相关依赖包
CentOS上安装某个软件一般都有很多相关的依赖包,当然,这也与我们安装时software selection步骤中选择的版本有关系,我们服务器在安装CentOS时一般选择Basic Web Serv ...
- 如何使用yum来下载RPM包而不进行安装
如何使用yum来下载RPM包而不进行安装 2015-03-23 13:15 theo-l译 linux.cn 字号:T | T yum是基于Red Hat的系统(如CentOS.Fedora.RHEl ...
- 【转】用yum只下载rpm包而不安装
转自:http://liucheng.name/1950/ CentOS用yum安装软件是非常方便的,有时,我们只需要下载其中的rpm包,而不直接安装时咋办呢? 一般情况下,yum是不提供只下载的功能 ...
- CentOS7中下载RPM及其所有的依赖包
CentOS7中下载RPM及其所有的依赖包 转载beeworkshop 最后发布于2019-09-28 07:43:40 阅读数 1096 收藏 展开 利用 Downloadonly 插件下载 RP ...
- 配置Jar包及相关依赖Jar包的本地存放路径
配置Jar包及相关依赖Jar包的本地存放路径 用 maven2 ,pom.xml中设置了依赖,会帮你下载所有依赖的.jar到 M2_REPO 指向的目录. M2_REPO是一个用来定义 maven 2 ...
- Linux yum如何下载rpm包到本地
下载前先安装一个小插件 [root@wang yum.repos.d]# yum install -y yum-plugin-downloadonly 安装一个包的同时 加上 yum install ...
- 使用yum来下载RPM包而不进行安装
1. 安装yum-downloadonly. yum-utils 或 yum-plugin-downloadonly 软件包 (RHEL5) # yum install yum-downloadonl ...
- CentOS 7设置yum仅仅下载rpm不安装总结
前言 参考文章:https://linux.cn/article-7937-1.html 在参考文章的基础上进行总结. 使用download-only插件实现 首先我们可以使用downloadonly ...
- 【Linux】用yum来下载rpm,而不安装
方法一:yum yum命令本身就可以用来下载一个RPM包,标准的yum命令提供了--downloadonly(只下载)的选项来达到这个目的. $ sudo yum install --download ...
随机推荐
- jquery.ajax请求aspx和ashx的异同 Jquery Ajax调用aspx页面方法
1.jquery.ajax请求aspx 请求aspx的静态方法要注意一下问题: (1)aspx的后台方法必须静态,而且添加webmethod特性 (2)在ajax方法中contentType必须是“a ...
- ubuntu安装启动redis
1.下载安装 sudo apt-get install build-essential wget http://redis.googlecode.com/files/redis-2.2.13.ta ...
- JS中常用的输出方式(五种)
1.alert("要输出的内容"); ->在浏览器中弹出一个对话框,然后把要输出的内容展示出来 ->alert都是把要输出的内容首先转换为字符串然后在输出的 2.doc ...
- Discuz-阅读权限
设置用户浏览帖子或附件的权限级别,范围 0-255,0 为禁止用户浏览任何帖子或附件. 当用户的阅读权限小于帖子或附件的阅读权限许可(默认时为 1)时, 用户将不能阅读该帖子或下载该附件
- Yii Restful api自定义字段
- Helter Skelter (扫描线 + 离散化 + 树状数组)
扫描线:按照其中一个区间的标记为pos,然后左区间标记d为正影响,有区间标记d为负影响,然后根据所有的pos排序.pos从小扫到大,那么对于某一个区间一定会被扫过2次,那么经过2次之后就只剩下中间那一 ...
- 20155228 2016-2017-2 《Java程序设计》第6周学习总结
20155228 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 输入与输出 在Java中输入串流代表对象为java.io.InputStream实例,输出串 ...
- 【2017-2-23】C#switch case分支语句,for循环语句
switch case分支语句 switch(一个变量值) { case 值:要执行的代码段;break; case 值:要执行的代码段;break; … default:代码段;break;(def ...
- 【Hadoop学习之十三】MapReduce案例分析五-ItemCF
环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-3.1.1 推荐系统——协同过滤(Collab ...
- 20165215 2017-2018-2 《Java程序设计》第6周学习总结
20165215 2017-2018-2 <Java程序设计>第6周学习总结 教材学习内容总结 chapter8 Java把String类定义为final类,即String类不能有子类 用 ...