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)
CodePudding user response:
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