如何列出/下载 debian 包的递归依赖项? [英] How to list/download the recursive dependencies of a debian package?
问题描述
我需要列出/下载一个 debian 包的所有递归依赖项.
I need to list/download all the recursive dependencies of a debian package.
假设我需要安装包 a.deb,它依赖于包 b.deb,包 b.deb 又依赖于包 c.deb.
Suppose i need to install package a.deb and it depends on package b.deb and again package b.deb depends on package c.deb.
我需要下载所有递归依赖包,以便它们可以安装在其他机器上而无需任何互联网访问.
I need to download all the recursive dependent packages so that they can be installed on some other machine without any internet access.
谢谢.
推荐答案
由于某种原因 apt-rdepends
对我不起作用(在搜索 'docker-engine' 包时,它错过了依赖项在 docker-engine 1.11.1-0
引入的 libltdl7
上).UPD 可能是因为 apt-rdepends
默认不跟随也不列出 Recommends.并且不遵循虚拟包.
For some reason apt-rdepends
did not work for me (when searching the 'docker-engine' package, it missed the dependency onto libltdl7
which was introduced with docker-engine 1.11.1-0
). UPD Supposedly owing to the fact that apt-rdepends
doesn't follow and doesn't list Recommends by default. And doesn't follow virtual packages.
所以我想出了以下命令套件.
So I came up with following command suite.
$ apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances <your-package-here> | grep "^w" | sort -u
(您显然必须将行尾的 <your-package-here>
更改为您要分析的包)
(you obviously have to change <your-package-here>
at the end of the line with the package you want to analyze)
这里的关键是 --recurse
选项.不幸的是,您无法指定您想要的内容(或者我没有找到方法),因此您需要关闭所有不需要的依赖项以仅保留依赖项".有点冗长,难记!
The key here is the --recurse
option. Unfortunately, you cannot specify the content you want (or I did not find the way) so you need to turn off all unwanted dependencies to keep only "dependencies". It is a bit verbose and hard to remember!
来自 apt-cache 手册页:
From the apt-cache man page:
默认情况下,depends 和 rdepends 打印所有依赖项
Per default the depends and rdepends print all dependencies
下载这些依赖项
因此,为了下载这些依赖项,请运行以下命令,将它们下载到当前工作目录:
Download those dependencies
So in order to download those dependencies, run following command which will download them into the current working directory:
$ apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances <your-package-here> | grep "^w" | sort -u)
(可选)安装这些依赖项
这略微扩展了所提出的问题,但它似乎与问题的意图相匹配.
你需要为刚刚下载的包建立index.这是从下载所有 .deb 的同一文件夹中完成的:
You need to build the index of the just downloaded packages. This is done from the same folder where all .deb where downloaded:
$ dpkg-scanpackages . | gzip -9c > Packages.gz
然后将该文件夹(所有 .deb + Packages.gz 文件)复制到无法访问 Internet 的目标系统,并将该文件夹添加到 APT 源列表.
Then just copy that folder (all .deb + the Packages.gz file) to the target system which does not have Internet access and add the folder to the APT source list.
$ echo "deb file:<your folder here> ./" | sudo tee -a /etc/apt/sources.list
$ sudo apt-get update
等等
在没有 Internet 访问的系统上,我可以安装一个包(在我的示例中为 Docker)及其依赖项:
Et voilà
On a system w/o Internet access, I can install a package (Docker in my example) and its dependencies:
$ sudo apt-get install docker-engine
这篇关于如何列出/下载 debian 包的递归依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!