使用yum下载软件包所有依赖项的RPM

piv4azn7  于 2022-11-07  发布在  其他
关注(0)|答案(2)|浏览(245)

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.
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.
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.
Is there a way to download the RPMs for all dependencies on a package from a yum repo?

x0fgdtte

x0fgdtte1#

有一个bash脚本,rpm的维护者很友好地与我分享了这个脚本,我put on github。希望你觉得它有用!
您也可以阅读讨论该问题的原始SO question
这个脚本可以在Fedora 23+上运行,因为它使用了dnf的下载插件。在Fedora 22-上运行可能很容易,因为百胜肯定也有类似的插件。
此外,它是有价值的,因为repotrack不工作的fedora 23(至少它不为我工作)。

2admgd59

2admgd592#

在四处寻找解决方案的过程中,我遇到了很多挫折,我写了一个简单的脚本,使用了repotrace和wget。我发现yumdownloader(即使有resolve标志)也不能解析所有的依赖关系。
如果你有一个很长的软件包列表,你一定会遇到重复的,首先用“repotrack -u标志”只下载url,然后获得唯一的记录,解决了必须多次下载相同的rpm的问题。


# !/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

快乐的rpming

相关问题