0

I am on Debian testing/Jessie and I have debian-experimental as well as in my /etc/apt/sources.list. So I am looking to list packages in two ways :-

a. List all the packages which are in experimental.

This I was able to achieve by :-

$ apt list | grep experimental

which gave a listing of all packages which are in experimental. Is there a way though to get a listing of packages who are ONLY in debian-experimental and not in debian-unstable/sid or testing. (I have them in my /etc/apt/sources.list as well.)

If people are wondering, then yes I run a mixed system although majority are from testing.I am sure with grep, awk etc. there would be a way but haven't found it. I looked via search-engines but couldn't come up with an answer.

1

You can do this by listing both sets of packages and determining the difference between the two results:

grep -Fxv -f <(apt list | grep unstable | cut -d/ -f1) <(apt list | grep experimental | cut -d/ -f1)

This produces “experimental minus unstable”, and can be adapted to calculate any difference by changing unstable and/or experimental. Strictly speaking it matches more than just the suite; the following variant matches exactly by matching only after the / in apt list’s output:

grep -Fxv -f <(apt list | egrep /.\*unstable | cut -d/ -f1) <(apt list | grep /.\*experimental | cut -d/ -f1)

(Otherwise packages with “experimental” in their name appear when they shouldn’t, for example when comparing testing and experimental, trafficserver-experimental-plugins is listed even though it’s only present in unstable.)

Furthermore, apt list only lists candidate packages by default, so to get the correct results especially when comparing testing and unstable you need to do:

grep -Fxv -f <(apt list --all-versions | egrep /.\*unstable | cut -d/ -f1) <(apt list --all-versions | grep /.\*experimental | cut -d/ -f1)

Both cuts extract the package name from apt’s output. The first set of packages (from unstable) is given as a list of patterns for grep using the -f option. -F tells grep to consider the patterns as plain text strings rather than regular expressions; -x tells it to match each pattern completely; and -v tells it to list lines which don’t match the given patterns. So grep takes all the packages in experimental, keeps only those which aren't in the list of packages from unstable, and outputs the result.

The <() constructs use process substitution to feed the standard output of the commands contained within the brackets to a pipe which can then be used as input for another command; see the advanced bash guide for details.

  • Could you improve that a bit so I can also toss testing in that list, would that be possible ? – shirish Jan 29 '15 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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