apt show 按多个字段过滤

发布于 2025-01-12 04:02:01 字数 609 浏览 0 评论 0原文

我想从特定的 Debian 源/存储库获取属于特定包的所有二进制包。

apt show bla-dev 命令返回如下输出:

Package: bla-dev
Version: 1.3-2
Priority: extra
Section: libdevel
Source: bla
Maintainer: someone@someone
Installed-Size: 144 kB
Download-Size: 121 kB
APT-Sources: http://my-repo/ all/main amd64 Packages
Description: Headers

我尝试获取包含以下字段的包的所有 Package:Version: 字段:

Source: bla
APT-sources: http://my-repo/

命令apt show '*-*' 显示所有包的数据,所以我认为这会很有帮助,但我真的不知道如何继续(这个命令有点重 - 长文本作为输出)

I want to get all binary packages that belong to specific source package from specific Debian source/repository.

apt show bla-dev command returns output like this:

Package: bla-dev
Version: 1.3-2
Priority: extra
Section: libdevel
Source: bla
Maintainer: someone@someone
Installed-Size: 144 kB
Download-Size: 121 kB
APT-Sources: http://my-repo/ all/main amd64 Packages
Description: Headers

I try to get all Package: and Version: fields of packages that contains the fields:

Source: bla
APT-sources: http://my-repo/

The command apt show '*-*'
shows data of all packages so I think it would be helpful but I don't really know how to continue (This command is a little bit heavy - long text as output)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光瘦了 2025-01-19 04:02:01

您可以在 /var/lib/apt/lists/ 中查找存储库的纯文本包列表元数据,它们是世界可读的:

$ grep --no-filename /var/lib/apt/lists/*golang* -e 'Package: golang'

ppa.launchpad.net_golang-amd64_Packages:Package: golang
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1.15
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1-15-doc
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1.16
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1.16-doc
...

编辑:为了匹配和打印更多字段,awk 可能会工作得更好:

awk '
    /Package: golang/  { p=$2 }
    /Version: /        { v=$2 }
    /Source: golang-d/ { s=$2 }
    /^$/               { if (p && s) printf("%s\t%s\n", p, v); p=v=s="" }
' /var/lib/apt/lists/*golang*

哪个输出:

golang  2:1.17~1longsleep1
golang-any      2:1.17~1longsleep1
golang-doc      2:1.16-1longsleep1+bionic
golang-doc      2:1.17~1longsleep1
golang-go       2:1.17~1longsleep1
golang-src      2:1.17~1longsleep1

You can grep through the plaintext package list metadata for your repo in /var/lib/apt/lists/, they are world-readable:

$ grep --no-filename /var/lib/apt/lists/*golang* -e 'Package: golang'

ppa.launchpad.net_golang-amd64_Packages:Package: golang
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1.15
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1-15-doc
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1.16
ppa.launchpad.net_golang-amd64_Packages:Package: golang-1.16-doc
...

Edit: to match and print more fields, awk might work better:

awk '
    /Package: golang/  { p=$2 }
    /Version: /        { v=$2 }
    /Source: golang-d/ { s=$2 }
    /^$/               { if (p && s) printf("%s\t%s\n", p, v); p=v=s="" }
' /var/lib/apt/lists/*golang*

Which outputs:

golang  2:1.17~1longsleep1
golang-any      2:1.17~1longsleep1
golang-doc      2:1.16-1longsleep1+bionic
golang-doc      2:1.17~1longsleep1
golang-go       2:1.17~1longsleep1
golang-src      2:1.17~1longsleep1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文