'How do set conditional "Provides" when RPM is installed

This may be impossible but I am asking anyway. I want to create an RPM that will change the Provides based on the hostname of the machine it is being installed on.. For example, in my spec file, I want to make several subpackages based on what I expect the hostname of the machines will be (in our environment, the first four characters of the hostname denote its organization id)
ORG19999 ORG29999 etc

in bash, I would get ${HOSTNAME:0:4} and run that through a case.

For a spec file, is there a way to get that during the install and apply a subpackage that would set the "Provides:" based on what is returned. Provides: ORG1 or Provides: ORG2



Solution 1:[1]

This is impossible using standard RPM mechanism.

You can create empty rpm (this needs to be executed on that target machine) using create-fake-rpm:

create-fake-rpm build hostname-provides "${HOSTNAME:0:4}"

And then installing this package.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 msuchy