如何获取deb软件包的所有依赖项的URL?

我想确认是否有可能列出指定系统的所有依赖项所需的URL。
假设我想要安装一个软件,它依赖于100多个单独的包,并且我需要获取几十个这样的包。碰巧我处在一个限制性代理环境中(天哪!当然很糟糕),它要求我指定每个需要访问的URL。
我已经找到了可以使用apt-rdepends获取依赖包列表的方法。但是如何将依赖关系正确地映射到URL(假设*.ubuntu.com是可用的)呢?
1个回答

你可以使用 apt-get 命令和 --print-uris 选项来显示 URI。
sudo apt-get --print-uris install geany
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  geany-common
Suggested packages:
  libvte9
The following NEW packages will be installed:
  geany geany-common
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,242 kB of archives.
After this operation, 8,894 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
'http://archive.ubuntu.com/ubuntu/pool/universe/g/geany/geany-common_1.22+dfsg-2ubuntu1_all.deb' geany-common_1.22+dfsg-2ubuntu1_all.deb 2153292 MD5Sum:e7dc7ca72d4e3b27ebfeadaea9fb3289
'http://archive.ubuntu.com/ubuntu/pool/universe/g/geany/geany_1.22+dfsg-2ubuntu1_amd64.deb' geany_1.22+dfsg-2ubuntu1_amd64.deb 1089150 MD5Sum:e201bf70fc0ef23b0f64c410125814cb

这是最简单的方法,而且不需要安装任何额外的东西。
apt-get man摘录:
--print-uris
       Instead of fetching the files to install their URIs are printed. Each URI will have the path, the
       destination file name, the size and the expected MD5 hash. Note that the file name to write to
       will not always match the file name on the remote site! This also works with the source and update
       commands. When used with the update command the MD5 and size are not included, and it is up to the
       user to decompress any compressed files. Configuration Item: APT::Get::Print-URIs.

我们能否在不实际安装软件包的情况下列出相同的内容? - haribabu
嗯...正如你所看到的,我实际上按下了 y 键,但它并没有安装。当你使用 --print-uris 时,唯一做的就是打印URL。没有其他操作被执行。 - Braiam
如果软件包已经安装,它不会打印任何内容。 - peterh
@peterh 是的,这就是man页面上说的“不需要获取文件来安装它们的URI会被打印出来”。 - Braiam