“apt-get -s update”或其他一些 apt 命令是否可以选择列出将从中下载软件包的存储库?

“apt-get -s update”或其他一些 apt 命令是否可以选择列出将从中下载软件包的存储库?

或其他一些 apt 命令是否apt-get -s upgrade可以选择列出将从中下载软件包的存储库?

apt-cache policy会告诉你一个单独的包,但我需要一些东西来逐行显示每个包的存储库。

答案1

你可以尝试这样的事情:

apt-get -s upgrade | awk '/^Inst/ {print $2}' | 
    xargs apt-cache policy | 
    awk '/:$|^$/ && ! /Version table:/ {print "\n" $0 } ; /:\/\// { print $2 }'

输出(刚刚在我的 debian sid 系统上运行)如下所示:

sqlite3:
http://my.local.mirror.redacted/debian

libsqlite3-0:
http://my.local.mirror.redacted/debian

libsqlite3-0:i386:
http://my.local.mirror.redacted/debian

python-newt:
http://my.local.mirror.redacted/debian

libnewt0.52:
http://my.local.mirror.redacted/debian

libruby:
http://my.local.mirror.redacted/debian
http://my.local.mirror.redacted/debian

mercurial:
http://my.local.mirror.redacted/debian

mercurial-common:
http://my.local.mirror.redacted/debian
http://my.local.mirror.redacted/debian

sysstat:
http://my.local.mirror.redacted/debian

libmilter1.0.1:
http://my.local.mirror.redacted/debian

有些软件包有两个 URL。这是因为我的系统是 amd64,添加了 i386 架构,这些软件包有 amd64 和 i386 版本可供升级。

如果您希望拥有完整的输出行,则它看起来像这样:

mercurial-common:
        990 http://my.local.mirror.redacted/debian unstable/main amd64 Packages
        990 http://my.local.mirror.redacted/debian unstable/main i386 Packages

{ print $2 }然后从第二个脚本中删除awk

答案2

你可以使用--print-uris它给出这样的东西,

~# apt-get upgrade -s --print-uris
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  libcgi-fast-perl libperl5.14 perl perl-base perl-modules
5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Inst perl [5.14.2-21+deb7u2] (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [i386]) []
Inst libperl5.14 [5.14.2-21+deb7u2] (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [i386]) []
Inst perl-base [5.14.2-21+deb7u2] (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [i386]) []
Conf perl-base (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [i386]) []
Inst perl-modules [5.14.2-21+deb7u2] (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [all])
Inst libcgi-fast-perl [5.14.2-21+deb7u2] (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [all])
Conf perl (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [i386])
Conf perl-modules (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [all])
Conf libperl5.14 (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [i386])
Conf libcgi-fast-perl (5.14.2-21+deb7u3 Debian-Security:7.0/oldstable [all])

相关内容