How to version lock packages in Ubuntu? [duplicate]

On CentOS exists the yum versionlock option, where you can lock a package to a specific version, so it is never upgraded past that.

I would like that

puppet-server-2.7.19-1
puppet-2.7.19-1

stays on 2.7, and never upgraded to 3.0. Puppet Labs have released 3.0 and put it into the stable repo, so 2.7 will get upgraded to 3.0, which is not backwards compatible.

Does Ubuntu have something similar to yum versionlock?


Solution 1:

You can create a file in /etc/apt/preferences and pin packages' version.

The format for the file would be somewhat like this:

Package: puppet-server
Pin: version 2.7*
Pin-Priority: 550

See also:

  • Debian documentation | Apt Howto
  • Debian Wiki | Apt preferences
  • manpage of apt_preferences

Solution 2:

You can try this:

aptitude hold puppet-server puppet
echo "puppet-server hold" | dpkg --set-selections
echo "puppet hold" | dpkg --set-selections