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

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

问题描述

我正在尝试在系统上创建一个本地yum仓库,其中包含主要来自CentOS基本仓库的各种软件包。默认情况下,承载yum repo的服务器不一定要与要使用yum repo的服务器安装相同的基本软件包。因此,我需要确保我的存储库包含所需的软件包以及它们的每个依赖项。

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工具创建存储库,以尝试使用yum从标准CentOS镜像下载软件包的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存储库中下载软件包中所有依赖项的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天全站免登陆