3

We have a few PPA sources on some of our servers which we stick into /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 gave a read to 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:

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

and ruby-ng-experimental-source.list:

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 directory:

$ 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 ?

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 ALL sources - or something like that ?

$ 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

Thanks for the answers!

milosgajdos
  • 1,828
  • 2
  • 21
  • 30
  • Isn't apt-get just select the latest version, since all those ppa enabled? – Danila Ladner May 10 '13 at 16:19
  • not if you have multple sources! The one on top has 1.2.6 and the second one has 1.4.1 available yet the package is installed from the first one. – milosgajdos May 10 '13 at 16:27
  • I'm not quite sure, but from the documentations I can find it seems that `Pin: origin` only accepts a hostname as argument. As both repos are on `ppa.launchpad.net`, this is not very helpful in your case... – etagenklo May 11 '13 at 13:29

1 Answers1

3

Prioritizing via Pin: origin does not work in your case because it expects a hostname as argument:

Pin: origin ppa.launchpad.net

As both repos are on ppa.launchpad.net, this won't help you.

You can find the reason why you get provided with the lower version here:

http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version

The version number 1.4.1-1ppa0~precise is missing the epoch part, so this is interpreted by apt as 0:1.4.1-1ppa0~precise, which is lower than 1:1.2.6-1~43~precise.

You could therefore instead try to pin via version number:

Pin: version 0:*

Another way would be to pin via the release option with the name of the repo issuer:

Pin: release o=<issuer>

To find out the correct value for <issuer> on your different repos, run apt-cache policy without arguments.

etagenklo
  • 5,834
  • 1
  • 27
  • 32