How to author a .spec file that requires either sl-release or centos-release or redhat-release?

StackOverflow https://stackoverflow.com/questions/18599123

  •  27-06-2022
  •  | 
  •  

문제

I reckon my question is somewhat related to "https://serverfault.com/q/299179" and "https://serverfault.com/q/283330/71790", but then there was no satisfying answer there for me in either of those.

In order to ensure that the dependencies are correct for my .rpm, I want to require a particular minimum release. In my case sl-release >= 6.1. Alright, so I wrote Requires: sl-release >= 6.1 in the .spec file and then it dawned on me: "What if somebody tries to install this on one of the related distros?" (like CentOS or RHEL itself).

Since Scientific Linux is based on RHEL, like CentOS, there should be a way to express that I require something based off a particular RHEL release. Alas, a quick yum list installed|grep release only yielded:

sl-release.x86_64  6.1-2         @anaconda-ScientificLinux-201107272231.x86_64/6

Dang, sl-release was clearly specific to Scientific Linux (and yum list wasn't any more helpful and yum grouplist offered nothing either). So I thought the dependency must be somehow expressed by Provides: and issued a yum deplist sl-release. Alas, the output was again not helpful to my cause.

도움이 되었습니까?

해결책

... turns out that aside from the conditionals pointed out in "https://serverfault.com/q/283330/71790", there is something like a symbolic/alias name for the above. Guessing a little, a web search turned up centos-release and of course redhat-release as the package names used on the other two related distros.

Since it took me some time to come up with the solution and sharing is caring, I decided to write down what I found for the next internaut doing a web search.

So, next I ran yum install redhat-release in order to install it, hoping it would be available. It was:

$ sudo yum install redhat-release
Setting up Install Process
Package sl-release-6.1-2.x86_64 already installed and latest version
Nothing to do

Apparently the name redhat-release somehow magically translates to sl-release. I.e. it's an alias.

Conclusion

You can use the generic name redhat-release, even on the two derived distros CentOS and Scientific Linux to refer to the respective distribution-specific packages centos-release and sl-release. So:

Require: redhat-release >= 6.1

does the job on all of them.


On a related note, I knew that all of them have a file /etc/redhat-release and yum whatprovides /etc/redhat-release gave me:

$ yum whatprovides /etc/redhat-release
sl-release-6.1-2.x86_64 : Scientific Linux release file
Repo        : local
Matched from:
Filename    : /etc/redhat-release



sl-release-6.1-2.x86_64 : Scientific Linux release file
Repo        : installed
Matched from:
Other       : Provides-match: /etc/redhat-release
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top