Just for fun or if you do not trust the caches, you can query a source's declared packages from, well, the source. The repositories are pretty much websites, either HTTP or FTP.
Your system has source URLs, which you can query for specific architectures and binary/source parameters. Then you can query the specific architecture's package lists.
E.g., I use an excellent jRiver's media player MediaCenter on Pop!_OS. To query their stable repository, which I have configured, first find out the URL:
$ cat /etc/apt/sources.list.d/mediacenter26.list
#MC
deb [arch=i386,amd64,armhf] http://dist.jriver.com/stable/mediacenter/ jessie main
Then grab the list location for the architecture which interests you. Note that the URL is formed following the pattern <archive_url>/dists/<distro>/Release:
For my use case I wanted a list of packages from multiple repos matching the same dist release, specifically Jessie. This host has multiple jessie repos configured, Dell's linux repo and the Debian archives for some dependencies.
I wound up with this, ahem, one-liner:
for p in $(dpkg -l | awk '/ii/{ print $2 }'); do for i in $(apt-cache policy "$p" | awk '/Installed/{ print $2}'); do apt-cache policy "$p" | grep -A1 '\*\*\*\ '$i'' | if grep -q jessie; then echo $p; fi; done; done
Quite ugly, as we need to run apt-cache twice, once to get the installed version of a package and a second time to match that installed version against the target repo, which conveniently can be matched by just "jessie" in this case.
If you remove the 'grep -q' you'll get output of the matched repo line as well for confirmation, or otherwise. You could adapt this match syntax to regex to match on multiple repos.
Simple:
Or more flexible:
For fancier querying, use
apt-cache policy
andaptitude
as described here:I don't know if this is what you're looking for:
https://superuser.com/questions/132346/find-packages-installed-from-a-certain-repository-with-aptitude
Like it says, Synaptic Package Manager allows you to search by "origin". This isn't programmatic, but it should give you what you're looking for.
Old thread, but thought it might help. Use awk, sort and uniq to grab only the packages and discard the Package repo checksums.
Just for fun or if you do not trust the caches, you can query a source's declared packages from, well, the source. The repositories are pretty much websites, either HTTP or FTP.
Your system has source URLs, which you can query for specific architectures and binary/source parameters. Then you can query the specific architecture's package lists.
E.g., I use an excellent jRiver's media player MediaCenter on Pop!_OS. To query their stable repository, which I have configured, first find out the URL:
Then grab the list location for the architecture which interests you. Note that the URL is formed following the pattern
<archive_url>/dists/<distro>/Release
:Finally, append the architecture's list path to the distribution and extract the package names from the lists of signatures:
Naturally, tune or remove the
grep
|cut
|sort
filters to your taste. Remove-s
(silent) parameter fromcurl
to see diagnostics if needed.... or use a Synaptic package manager.
For my use case I wanted a list of packages from multiple repos matching the same dist release, specifically Jessie. This host has multiple jessie repos configured, Dell's linux repo and the Debian archives for some dependencies.
I wound up with this, ahem, one-liner:
Quite ugly, as we need to run apt-cache twice, once to get the installed version of a package and a second time to match that installed version against the target repo, which conveniently can be matched by just "jessie" in this case.
If you remove the 'grep -q' you'll get output of the matched repo line as well for confirmation, or otherwise. You could adapt this match syntax to regex to match on multiple repos.