tags:

views:

18

answers:

1

Hey! I've got a generic package that requires a config file and multiple packages that can provide said config file.

So, to define "myserver", I've got:

myserver.spec

Requires: myserver-config


(the config package) myserver-first-config.spec

Name: myserver-first-config

Requires: myserver

Provides: myserver-config


(another config package) myserver-second-config.spec

Name: myserver-second-config

Requires: myserver

Provides: myserver-config


And that's great, but I want to make sure that exactly one of those config packages is installed. So, if I try to install myserver-second-config when myserver-first-config is already installed, I get an error.

Can I just use "Conflicts: myserver-config" in both myserver-{first,second}-config.spec? Can a package conflict with itself? I feel like there's a "proper" way to do this...

Thanks!

A: 

You've probably solved this on your own - in which case it's nice to post the answer here, to help any wayward google visitors :) Otherwise:

  • As of RPM v5, a package cannot conflict with itself, as this would prevent the package from being installed.
  • What you are asking for is an 'alternatives' system, where multiple packages can provide the same file. To implement this, have each package conflict with the other alternatives.

In myserver-first-config:
Conflicts: myserver-second-config

In myserver-second-config:
Conflicts: myserver-first-config

If you were to add a third config, this would become:

myserver-first-config:
Conflicts: myserver-second-config myserver-third-config

myserver-second-config:
Conflicts: myserver-first-config myserver-third-config

myserver-third-config:
Conflicts: myserver-first-config myserver-second-config

This syntax is necessary because packages might partially conflict - and it is better to be explicit about conflicts. If you don't add new config files that often, this solution is completely workable.

rjh