I'm in search for something analog to this question: Zypper: How do I display all packages from a certain repository?

Since I'm on Ubuntu, I need an aptitude based solution: How can I get a list of installed packages from a certain repository?

link|improve this question

feedback

6 Answers

After reading info page of aptitude and a dozen of attempts, I finally got this :

aptitude search '?narrow(?installed,?not(?archive(testing)) ?archive(unstable))'

or (equivalent) :

aptitude search '~S ~i (!~Atesting ~Aunstable)'

It will search packages installed from unstable archives of any repository. You have to filter out packages from your default archive (testing in above example).

If you want to filter packages installed from www.debian-multimedia.org/unstable :

aptitude search '~S ~i (!~Atesting ~Aunstable ~O"Unofficial Multimedia Packages")

You get archive, origin, etc. for each repository from apt-cache policy command, on the release lines.

link|improve this answer
feedback
up vote 4 down vote accepted

Whoa, it's so trivial (at least on Ubuntu desktop systems). Use Synaptic! Then, in the left column, you can filter packages by their origin.

However, there must be a CLI way, too. I update the answer, if I find it (as long as anyone else posted it before).

link|improve this answer
I was trying to do this and found this SU post via Google, can't believe I overlooked Synaptic, thanks! – David Claridge Nov 27 '10 at 20:33
feedback

Examine the origin tag (such as o=Debian) for each of your current repositories:

apt-cache policy

Then search for packages from (or not from) a particular origin:

aptitude search "?installed?origin(Debian)"
aptitude search "?installed?not(?origin(Debian))"

This is not suitable for a security audit because it relies on each repository to provide its own origin information, but it might be helpful for troubleshooting the origin of packages that are present in multiple repositories.

link|improve this answer
feedback

I tried to look up how to list all packages from a specific repository, but I'm not familiar enough with how apt works to figure it out.

Once you find a list of all packages from a specific repository, however, you can put the names of all the packages in a file named filename, and then run

dpkg --get-selections | grep -f 'filename'

to list all the installed packages out of that list. Sorry I couldn't be of more help.

link|improve this answer
Thanks for the try, but it doesn't help a bit without the knowledge, where a package came from. – Boldewyn Apr 20 '10 at 18:48
feedback

I've found this :

sudo aptitude search "?origin (<repository>) ?installed"

List of search terms supported by "aptitude search". http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s05.html#tableSearchTermQuickGuide

link|improve this answer
Why do you need to run this with sudo ? It seems to me that this also works without running it as root. – Andre Holzner Dec 4 '10 at 17:15
feedback

You can use this

aptitude upgrade $(aptitude search '?origin(Unofficial Multimedia Packages) ?upgradable' -F '%p')

The search will filter all packages from the given origin (in this case the debian-multimedia repo) and will print out just the package name, then upgrade just those packages.

To get the origin, I had to check the Release file from the repository (first line in the file).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.