3

I'm attempting to pin a package based on more than one field. In my case, the origin and the version.

My specific reasons for doing this is to ping RabbitMQ's Erlang release at a specific version. I want to prevent installation of another version of Erlang (from RabbitMQ's repo) or the version that I want, from another repo. On the RabbitMQ Bintray repos, I limited the version by using the "component" field in the sources.list (They provided one of those per major Erlang version. e.g. erlang would get all version, erlang-23.x would get only the 23.* versions of Erlang. This is no longer done with the repos that replaced Bintray) (This is needed since the base OS might contain packages of the same major version as the RabbitMQ Erlang repo (pin based on origin) and the RabbitMQ Erlang repo might contain newer Erlang versions than supported by the RabbitMQ that I want to run (pin based on version))

My sources.list extract:

deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu bionic main
deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu bionic main

I can't find details on the syntax of the Pin parameter. (There are examples, but nothing for more than one field)

Things I've tried in a file in /etc/apt/preferences.d/:

  • Multiple entries:
Package: erlang*
Pin: origin dl.cloudsmith.io
Pin-Priority: 1000

Package: erlang*
Pin: version 1:23.*
Pin-Priority: 1000

This results in both the cloudsmith packages and all the version 23.x version being set to priority 1000. (If different priorities are used, only the first matching one is applied - i.e all the cloudsmith.io packages gets the priority from the first block, the cloudsmith 23.x packages does not get the priority from the second block)

  • Two Pin entries:
Package: erlang*
Pin: origin dl.cloudsmith.io
Pin: version 1:23.*
Pin-Priority: 1000

This results in only the first field being applied (origin in this case)

  • Multiple space-separated entries:
Package: erlang*
Pin: origin dl.cloudsmith.io version 1:23.*
Pin-Priority: 1000

This does not match any packages.

(I checked the results with apt-cache policy and swopped the version and origin around to see if both are taken into account, or only one)

(Another, less elegant solution is to lower the priority of the OS's packages. This will fail if more repos are added)

1 Answers1

1

man 5 apt_preferences explains multiple criterions can be defined using a comma-separated list like this:

Pin: origin dl.cloudsmith.io, version 1:23.*