• 怎样在 CentOS 里下载 RPM 包及其所有依赖包


    方法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/ 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
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
    --> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Running transaction check
    ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
    ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
    ---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed
    ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =======================================================================================================================================
     Package Arch Version Repository Size
    =======================================================================================================================================
    Installing:
     httpd x86_64 2.4.6-40.el7.centos.4 updates 2.7 M
    Installing for dependencies:
     apr x86_64 1.4.8-3.el7 base 103 k
     apr-util x86_64 1.5.2-6.el7 base 92 k
     httpd-tools x86_64 2.4.6-40.el7.centos.4 updates 83 k
     mailcap noarch 2.1.41-2.el7 base 31 k
    
    Transaction Summary
    =======================================================================================================================================
    Install 1 Package (+4 Dependent packages)
    
    Total download size: 3.0 M
    Installed size: 10 M
    Background downloading packages, then exiting:
    (1/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:01 
    (2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01 
    (3/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:01 
    (4/5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:01 
    (5/5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:09 
    ---------------------------------------------------------------------------------------------------------------------------------------
    Total 331 kB/s | 3.0 MB 00:00:09 
    exiting because "Download Only" specified

     现在去你指定的目录位置下,你将会看到那里有下载好的软件包和依赖的软件。在我这种情况下,我已经把软件包下载到 /root/mypackages/ 目录下。让我们来查看一下内容:

    ls /root/mypackages/

    样本输出:

    apr-1.4.8-3.el7.x86_64.rpm
    apr-util-1.5.2-6.el7.x86_64.rpm
    httpd-2.4.6-40.el7.centos.4.x86_64.rpm
    httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm
    mailcap-2.1.41-2.el7.noarch.rpm

     正如你在上面输出所看到的, httpd软件包已经被依据所有依赖性下载完成了 。
    请注意,这个插件适用于 yum install/yum update, 但是并不适用于 yum groupinstall 。默认情况下,这个插件将会下载仓库中最新可用的软件包。然而你可以通过指定版本号来下载某个特定的软件版本。
    例子:

    yum install --downloadonly --downloaddir=/root/mypackages/ httpd-2.2.6-40.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 0:2.4.6-40.el7.centos.4 will be installed
    --> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
    --> Running transaction check
    ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
    ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
    ---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed
    ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
    --> Finished Dependency Resolution
    (1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01 
    (2/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:02 
    (3/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:02 
    (4/5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:03 
    (5/5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:19

     让我们确认一下软件包是否被下载到我们指定的目录下。

    ls /root/mypackages/

    终端输出:

    apr-1.4.8-3.el7.x86_64.rpm
    apr-util-1.5.2-6.el7.x86_64.rpm
    httpd-2.4.6-40.el7.centos.4.x86_64.rpm
    httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm
    mailcap-2.1.41-2.el7.noarch.rpm

     不像 Downloadonly 插件,Yumdownload 可以下载一组相关的软件包。

    yumdownloader "@Development Tools" --resolve --destdir /root/mypackages/

    转自:https://linux.cn/article-7937-1.html

  • 相关阅读:
    用js实现广告图片后加载
    Sql server存储过程和C#分页类简化你的代码
    SQL Server 1069 错误(由于登录失败而无法启动服务)解决方法
    ASP.NET编程中的十大技巧
    ASP.NET通用分页程序
    asp.net中使用SPLIT这个函数把一个字符串分成数组
    win2003+iis6服务器设置问题集
    一个较优雅的GridView隐藏列取值解决方案
    ACCESS的iif语句转到SQL语句!!!
    SCOPE_IDENTITY 和 @@IDENTITY
  • 原文地址:https://www.cnblogs.com/lgjava/p/13474309.html
Copyright © 2020-2023  润新知