How can I choose which software I want to install from a Debian repository? I know that didn't make much sense, let me explain more detail.

I want to install a «unstable» version of gnupg with (ECC support), but I'm afraid of adding a «unstable» repository to my sources.list file, because it will mess up other sotware when i run:

aptitude upgrade

In short: I want all other packages to be in stable version, except gnupg.

  • 4
    You should use apt pinning. See man apt_preferences, or more generally, google "apt preferences". "I don't want to access to all other packages in the «non-free» repository". I'm unclear what you mean by "access". What is the problem with adding the non-free repository? You don't; have to install any of the other packages if you don't want to. – Faheem Mitha Jan 24 '16 at 22:55
  • My bad, I was thinking of unstable repository at the same time as i was writing about the non-free repository. Non-free repository will not mess up package versions. – BufferOverflow Jan 24 '16 at 23:08
  • Would you please delete the post then? – Rui F Ribeiro Jan 25 '16 at 1:09
  • Why? The second part of the post is still valid. It was just the first part that I mixed up. – BufferOverflow Jan 25 '16 at 1:14
  • This question feels like it is a dupe, but anyway, I've added an answer. – Faheem Mitha Jan 25 '16 at 3:42

Pinning all packages in unstable is easy. Just add

Package: *
Pin: release a=unstable
Pin-Priority: 50

or similar to /etc/apt/preferences.

This will hold back all packages in unstable from upgrade by apt or aptitude. Note that there is nothing magic about 50. From man apt_preferences:

0 < P < 100 causes a version to be installed only if there is no installed version of the package

NOTE: I think this could be better expressed as:

causes a version to be installed only if there is no installable version of higher priority available.

I.e. if pkg is available in your default release, then the unstable version of pkg will not be installed by default.

So any number in that range will work.

To install a version from unstable in this case, you will either have to do

apt-get install pkg/unstable pkg/dep1 pkg/dep2 ...

in which case you will have to add additional dependencies manually (as shown, using dep1 and dep2 as examples) if they are not available in your current release version, or

apt-get install -t unstable pkg

which will automatically take dependencies from unstable, which you probably don't want do to in general. So, be careful with this latter command.

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.