John Rocha
John Rocha

Reputation: 1705

How to prevent a SUSE RPM from installing on a RedHat system

We have a product that is distributed via RPMs. We create both SUSE SLES10 SP1 RPMs and RedHat 5.5 RPMs. There are differences between the two, things will not work correctly (often mysteriosly) if you install a SUSE RPM on a RedHat machine and vice versa.

Is there a way to prevent a RedHay RPM from being installed on a SUSE system and vice versa? I googled around for this and found http://www.rpm.org/max-rpm/ch-rpm-multi.html but all the constraints here seem to be based on the output from the command uname which doesn't tell you if you're running RedHat or Suse. The os is Linux, and the architecture is the same.

We have ideas to add checks in the install script that can look for 'Red Hat' or 'SUSE' in the /etc/issue file but I'm really hoping there is a better option than this.

Upvotes: 5

Views: 681

Answers (3)

user318904
user318904

Reputation: 3076

Also, you can check if the %{rhel} macro is defined in the spec file.

Upvotes: 0

MarkR
MarkR

Reputation: 63596

You can place a dependency on a redhat-specific package (although SuSE may provide a version).

You could also have your %pre check /etc/redhat-release (or lsb-release etc) for supported OS.

Do any pre-install checks in %pre, not %post, because otherwise they will happen after the package is already installed (%post cannot really fail usefully)

Upvotes: 0

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

Since you're specifically just looking to detect RedHat, look for the presence of a file named /etc/redhat-release. If it's there, you're installing on some version of RedHat.

Upvotes: 1

Related Questions