使用 yum 下载软件包的所有依赖项的 RPM [英] Download RPMs for all dependencies for package using yum

查看:46
本文介绍了使用 yum 下载软件包的所有依赖项的 RPM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的系统上创建一个本地 yum 存储库,其中包含主要来自 CentOS 基础存储库的各种软件包.默认情况下,托管 yum 存储库的服务器不一定会安装与将使用 yum 存储库的服务器相同的基本软件包.出于这个原因,我需要确保我的 repos 包含我想要的包以及它们的每一个依赖项.

I'm attempting to create a local yum repo on my system containing various packages from, chiefly, the CentOS base repos. The server which is hosting the yum repo will not necessarily have the same base packages installed by default as the servers which will be using the yum repo. For this reason, I need to ensure that my repos contain the packages that I want and every single one of their dependencies.

我正在使用 yum-utils 软件包中提供的 yumdownloader 工具创建我的存储库,以尝试从标准 CentOS 镜像下载使用 yum 的软件包的 RPM 文件.有用的是,它提供了一个命令行选项 --resolve,它还可以下载依赖项.但是,由于它是建立在 yum 本身之上的,yumdownloader 只会下载系统上尚不存在的软件包的依赖项.

I'm creating my repos using the yumdownloader tool provided in the yum-utils package to try to download an RPM file for a package using yum from the standard CentOS mirrors. Helpfully it provides a command line option, --resolve, which also downloads dependencies. However, because it's built on yum itself, yumdownloader will only download dependencies for the package that are not already present on the system.

比如我想下载包A,它依赖于包B、C和D.如果系统已经安装了包D,yumdownloader --resolve A只会下载A,B 和 C,但不是 D.

For example, I wish to download package A, which depends on Packages B, C and D. If package D is already installed on the system, yumdownloader --resolve A will only download A, B and C, but not D.

有没有办法从 yum repo 下载软件包的所有依赖项的 RPM?

Is there a way to download the RPMs for all dependencies on a package from a yum repo?

推荐答案

在四处寻找解决方案的挫折之后,我编写了一个使用 repotrace 和 wget 的简单脚本.我发现 yumdownloader(即使带有 resolve 标志)也不能解决所有依赖项.

After a lot of frustration looking around for a solution I have written a simple script that uses repotrace and wget. I've found that yumdownloader (even with the resolve flag) does not resolve all dependencies.

如果您有很长的软件包列表,您肯定会遇到重复,首先使用repotrack -u 标志"下载 url,然后获取唯一记录解决了必须多次下载相同 rpm 的问题.

if you have a long list of packages you are bound to run into duplicates, downloading just the urls first with the "repotrack -u flag" and then getting unique records resolves having to download the same rpm multiple times.

#!/bin/bash

while read i; do
    repotrack -u $i >> dep_rpm_urls_02.txt
done < list_of_packages_01.txt


awk '!seen[$0]++' dep_rpm_urls_02.txt > dep_rpm_urls_clean_03.txt

while read j; do
    wget $j
    echo dowloaded $j
done < dep_rpm_urls_clean_03.txt

快乐的转

这篇关于使用 yum 下载软件包的所有依赖项的 RPM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆