Prevent packages 'on hold' to show up when I upgrade

Pin a package version using Apt Preferences

  1. 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
    
  2. Create new file in /etc/apt/preferences.d/

    sudo vim /etc/apt/preferences.d/my_pin
    
  3. Add package you want (joker * can be used), with higher priority (default 0, max 1000, or even negative value like -1 to skip a version)

    Package: virtualbox*
    Pin: version 4.3.6-dfsg-1
    Pin-Priority: 500
    
  4. 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
    
  5. 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.