5

I want to install all MATE packages,

$ sudo apt-get install '^mate'

However, it selects too many packages, and some packages are conflicted with some installed ones.

Now, I want to exclude them. Any idea?

No surprise, this won't work:

$ sudo apt-get install '^mate && !-dev'

Or, can I simply let apt-get ignore those conflicted packages?

1

You could try something like:

list="" ; for pkg in $(apt-cache search ^mate | grep -v -- '-dev'); list="$list $pkg" ; done ; sudo apt-get install $list
  • 1
    apt-cache search doesn't support ^, well, maybe shorter? sudo apt-get install $(apt-cache search ^mate | grep ^mate | grep -v -- '-dev' | cut -d' ' -f1) – Xiè Jìléi Aug 5 '12 at 4:04
  • ah, thanks. i was working off memory, without an 'apt' using system to test on right now. :) – Tim Kennedy Aug 6 '12 at 4:18
5

You can only pass a regular expression as an argument to apt-get install.

You can make a regular expression that does what you want, but it's tedious. The negation of a regular expression can be expressed with a regular expression, but the size of the complement regex grows exponentially with the size of the original in general.

apt-get install '^mate(.?.?.?|.*([^v]|[^e]v|[^d]ev|[^-]dev))$'

You can use Aptitude's search patterns to generate the list of packages with a semi-decent syntax, and pass the resulting list to apt-get install or aptitude install.

aptitude search '^mate !-dev$'
0

I have asked the question myself as well. I tried negative lookaheads, but apt-get didn't understand them. So i searched for another way, to archive the same result and found the answer here. Nonetheless, since the choosen solution uses grep, you can use lookaheads and shorten the serach expression, in terms of calls, even more:

apt-cache search '^mate' | grep -P '^mate(?!.*dbg)(?!.*dev).*'

And keep in mind that Mates packages, such as atril, don't start with a mate at the beginning of their name. They don't even contain it at all.

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.