我想从特定的Debian源/存储库中获取属于特定source包的所有二进制程序包。
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 '*-*'
显示了所有包的数据,所以我认为这会很有帮助,但我真的不知道如何继续(这个命令有点重,输出的文本很长(
您可以在/var/lib/apt/lists/
中通过repo的明文包列表元数据进行grep,它们是世界可读的:
$ 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("%st%sn", 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