Assign higher priority to PPA

I'm trying to figure out how to assign higher priority to one PPA over another PPA. I had a look on bunch of the answers on this forum but none of them solves my problem.

We have two PPA sources on some of our servers which we stick into separate files in /etc/apt/sources.list.d . Some of these repos provide same packages (in terms of names) but different versions and possibly different binaries. Is there a way how we can PRIORITISE one repo over another ?

I read apt_preferences tutorial but it could not be more obscure and didn't find the answers for my question. Here is the situation. WE have the following sources:

$ ls -l /etc/apt/sources.list.d 
total 12
-rw-r--r-- 1 root root 66 Jan  2 16:50 nginx-source.list
-rw-r--r-- 1 root root 84 Jan  2 16:49 ruby-ng-experimental-source.list

where nginx-source.list content is:

deb     http://ppa.launchpad.net/nginx/stable/ubuntu precise main

and ruby-ng-experimental-source.list content is:

deb     http://ppa.launchpad.net/brightbox/ruby-ng-experimental/ubuntu precise main

Both of these sources provide nginx-full package of different versions etc. When I list the priorities ruby-ng-experimental-source.list is on top of output hence nginx-full is installed from that repo:

$ apt-cache policy nginx-full                                 
nginx-full:
  Installed: 1:1.2.3-1~38~precise1
  Candidate: 1:1.2.6-1~43~precise1
  Version table:
     1:1.2.6-1~43~precise1 0
        500 http://ppa.launchpad.net/brightbox/ruby-ng-experimental/ubuntu/ precise/main amd64 Packages
 *** 1:1.2.3-1~38~precise1 0
        100 /var/lib/dpkg/status
     1.4.1-1ppa0~precise 0
        500 http://ppa.launchpad.net/nginx/stable/ubuntu/ precise/main amd64 Packages
     1.1.19-1ubuntu0.1 0
        500 http://mirror.rackspace.co.uk/ubuntu/ precise-updates/universe amd64 Packages
     1.1.19-1 0
        500 http://mirror.rackspace.co.uk/ubuntu/ precise/universe amd64 Packages

How do I prioritize repo listed in nginx-source.list over the one which is on top of the list now ? I tried something like this:

$ cat /etc/apt/preferences
Package: nginx-full
Pin: origin http://ppa.launchpad.net/nginx/stable/ubuntu
Pin-Priority: 1000

Package: nginx-full
Pin: origin http://ppa.launchpad.net/brightbox/ruby-ng-experimental/ubuntu
Pin-Priority: 100

But that has changed priorities of both sources to the same number - or something like that ? So this has NOT changed the priorities and nginx-full is still being installed form the brightbox PPA

$ apt-cache policy nginx-full  
nginx-full:
  Installed: 1:1.2.3-1~38~precise1
  Candidate: 1:1.2.6-1~43~precise1
  Package pin: (not found)
  Version table:
     1:1.2.6-1~43~precise1 1000
        500 http://ppa.launchpad.net/brightbox/ruby-ng-experimental/ubuntu/ precise/main amd64 Packages
 *** 1:1.2.3-1~38~precise1 1000
        100 /var/lib/dpkg/status
     1.4.1-1ppa0~precise 1000
        500 http://ppa.launchpad.net/nginx/stable/ubuntu/ precise/main amd64 Packages
     1.1.19-1ubuntu0.1 1000
        500 http://mirror.rackspace.co.uk/ubuntu/ precise-updates/universe amd64 Packages
     1.1.19-1 1000
        500 http://mirror.rackspace.co.uk/ubuntu/ precise/universe amd64 Packages

Anyone has any idea how to achieve what I'm trying to do ?


Here is an example of /etc/apt/preferences

mint@mint ~ $ cat /etc/apt/preferences
Package: *
Pin: release o=linuxmint
Pin-Priority: 700

Package: *
Pin: origin packages.linuxmint.com
Pin-Priority: 700

Package: *
Pin: release o=Ubuntu
Pin-Priority: 500

You probably have to run apt-get update after creating the file.


Short answer: Set pinning-priority to less than 0 and set o=LP-PPA-*, e.g.

Package: nginx-full
Pin: release o=LP-PPA-brightbox-ruby-ng-experimental
Pin-Priority: -10

Quote from apt_preferences-manpage:

How APT Interprets Priorities
...
P < 0
prevents the version from being installed

Further information: http://manpages.ubuntu.com/manpages/raring/en/man5/apt_preferences.5.html and https://help.ubuntu.com/community/PinningHowto.