Is it possible to pin a version of a debian package?

Is it possible to pin only the major version? (like with pip install "pyramid < 1.4.0" will install the latest 1.3.x but will not upgrade the major version)?


You can do this, for example, by creating a file /etc/apt/preferences.d/yourpackage as

Package: yourpackage
Pin: version 7.*
Pin-Priority: 999

This would allow upgrades to yourpackage to versions matching 7.*

| improve this answer | |
  • Thanks so needed this. TBH I google a bit and cannot find some definitive and comprehensive doc for apt pinning apart from tutorials which are sometimes too specific and random docs here and there. Is there some official doc anywhere? – eirc Aug 31 '16 at 10:46
  • Haven't seen much other than: man apt_preferences – Gregor Aug 31 '16 at 21:12
  • 1
  • 2
    This example works great, but the answer doesn't specify where to put this. Create the file, for example, /etc/apt/preferences.d/yourpackage – berto Jan 5 '19 at 20:11

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.