Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted
+50

Here is a example of /etc/apt/preferences

Probably have to run apt-get update after making it.

share|improve this answer
    
thanks. This has helped a lot! –  gyre May 13 '13 at 10:42
    
/etc/apt/preferences doesn't exist on 13.04, although /etc/apt/preferences.d/ exists, but is an empty directory. –  Yet Another User May 15 '13 at 15:16
    
The file is not stock you just create it –  GM-Script-Writer-62850 May 15 '13 at 15:24
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.