Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to find a list of all packages with the Priority: field set to Required. These are packages that are normally installed on every system, however I've recently discovered that they aren't necessarily installed for foreign architectures using multiarch. What's the best way to find these packages?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

With aptitude you can do that type of search.

aptitude search '?priority(required)'

Note that aptitude is no longer installed by default on newer Ubuntu releases, and its man-page is incomplete; you'll find the full documentation as /usr/share/doc/aptitude/README

share|improve this answer
1  
If you need to limit your options to software that is in the default install, I think the only option is the following geekery (or something similar to it): mawk '/^Architecture: / { arch = $2; } /^Package: / { package = $2; } /^Priority: required/ { print package " (" arch ")"; }' < /var/lib/dpkg/status –  taneli Mar 9 '12 at 16:55
add comment

(Disclaimer: this answer uses a low level system tool to solve the requested problem, not aptitude. But since aptitude relies on dpkg services, it might still be useful.)

You can make use of dpkg-query combined with grep:

dpkg-query -W --showformat='${Package}\t${Priority}\n' | grep "required$"
  • dpkg-query lists all packages, when no package name is specified.
  • The -W or (--show) allows for listing packages using a specified output format.
  • The output format is provided by the --showformat='formatstring' syntax. The string consists of:
    • ${Package} to display the package name.
    • \t to display a Tab character as field separator.
    • ${Priority} to display the package priority.
    • \n to display a newline character at the end of each line.

Since a sample output without grep looks like this:

klibc-utils required
kmod    required
krb5-locales    standard
lame    optional
landscape-client-ui-install optional
language-pack-en    optional

The grep command displays only lines containing the „required” word at the end, i.e. the packages with Priority: required.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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