Prevent packages 'on hold' to show up when I upgrade
Pin a package version using Apt Preferences
-
Check current priority policy for my package, Example with
virtualbox
:$ apt-cache policy virtualbox virtualbox: Installed: 4.3.6-dfsg-1 Candidate: 4.3.6-dfsg-2 Version table: 4.3.6-dfsg-2 0 500 http://archive.ubuntu.com/ubuntu/ trusty/multiverse amd64 Packages *** 4.3.6-dfsg-1 0 100 /var/lib/dpkg/status
-
Create new file in
/etc/apt/preferences.d/
sudo vim /etc/apt/preferences.d/my_pin
-
Add package you want (joker
*
can be used), with higher priority (default0
, max1000
, or even negative value like-1
to skip a version)Package: virtualbox* Pin: version 4.3.6-dfsg-1 Pin-Priority: 500
-
Check again:
$ apt-cache policy virtualbox virtualbox: Installed: 4.3.6-dfsg-1 Candidate: 4.3.6-dfsg-1 Package pin: 4.3.6-dfsg-1 Version table: 4.3.6-dfsg-2 500 500 http://archive.ubuntu.com/ubuntu/ trusty/multiverse amd64 Packages *** 4.3.6-dfsg-1 500 100 /var/lib/dpkg/status
No need to use hold, So
sudo apt-mark unhold virtualbox
but you could leave it as 2nd lock.
Now, if I check apt-get update
, nothing is mentioned about about virtualbox
(In held back packages listing).
- Reference: How to use APT Preferences Pinnig
- Hash sign
#
can be used to comment lines in APT Preferences files.