如何阻止在 RedHat 系统上安装 SUSE RPM
我们有一个通过 RPM 分发的产品。我们创建 SUSE SLES10 SP1 RPM 和 RedHat 5.5 RPM。两者之间存在差异,如果您在 RedHat 计算机上安装 SUSE RPM,则事情将无法正常工作(通常是神秘的),反之亦然。
有没有办法防止 RedHay RPM 安装在 SUSE 系统上,反之亦然?我用谷歌搜索了一下,发现 http://www.rpm.org/ max-rpm/ch-rpm-multi.html 但这里的所有约束似乎都基于命令 uname
的输出,该命令不会告诉您是否正在运行 RedHat或苏塞。操作系统是Linux,架构是一样的。
我们有想法在安装脚本中添加检查,可以在 /etc/issue 文件中查找“Red Hat”或“SUSE”,但我真的希望有比这更好的选择。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您只是想检测 RedHat,因此请查找是否存在名为
/etc/redhat-release
的文件。如果存在,则表明您正在安装 RedHat 的某个版本。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.您可以依赖特定于 redhat 的软件包(尽管 SuSE 可能提供版本)。
您还可以让 %pre 检查 /etc/redhat-release (或 lsb-release 等)是否支持操作系统。
在 %pre 而不是 %post 中进行任何预安装检查,因为否则它们会在软件包安装后发生(%post 不会真正失败)
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)
另外,您可以检查 %{rhel} 宏是否在规范文件中定义。
Also, you can check if the %{rhel} macro is defined in the spec file.