我有一个RPM,在安装后和卸载前阶段使用semanage (SELinux策略管理工具)和restorecon (SELinux上下文配置工具)。
不幸的是,在RHEL 6/7和8之间,包含这些工具的包从policycoreutils-python重命名为policycoreutils-python-utils。
RHEL8 RPM的工作规范文件包含:
Requires(post): policycoreutils-python-utils
Requires(preun): policycoreutils-python-utilsRHEL6 6/7 RPM的工作规范文件包含:
Requires(post): policycoreutils-python
Requires(preun): policycoreutils-python我可以使用两个规范文件/两个RPM,每个OS类型都有一个,但是我很懒,我想要一个可以满足所有功能的规范。
我读到了包含OS版本的OS条件%{rhel}。根据“RPM手册”,以下内容应该有效:
%if %{rhel} < 8
Requires(post): policycoreutils-python
Requires(preun): policycoreutils-python
%endif
%if %{rhel} == 8
Requires(post): policycoreutils-python-utils
Requires(preun): policycoreutils-python-utils
%endif如果我检查目标系统上的%{rhel}变量的值,就会得到我期望的结果:
centos7-system» rpm --eval '%{rhel}'
7
centos8-system» rpm --eval '%{rhel}'
8在CentOS 6/7实例上安装此RPM很好。但是,在CentOS 8实例上安装与操作系统无关的RPM时,我得到:
centos8-system» dnf install my-1.26-0.x86_64.rpm
<...>
Error:
Problem: conflicting requests
- nothing provides policycoreutils-python needed by my-1.26-0.x86_64调试输出:
centos8-system» rpm -ivvvh my-1.26-0.x86_64.rpm 2>&1 | grep Requires
D: Requires: /bin/bash YES (db files)
D: Requires: /bin/sh YES (db files)
D: Requires: /bin/sh YES (cached)
D: Requires: /bin/sh YES (cached)
D: Requires: /usr/bin/env YES (db files)
D: Requires: /usr/bin/perl YES (db files)
D: Requires: /usr/bin/php YES (db files)
D: Requires: nagios-plugins NO
D: Requires: perl(Getopt::Long) YES (db provides)
D: Requires: perl(strict) YES (db provides)
D: Requires: policycoreutils-python NO
D: Requires: policycoreutils-python NO (cached)
D: Requires: policycoreutils-python NO
D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides)
D: Requires: rpmlib(FileDigests) <= 4.6.0-1 YES (rpmlib provides)
D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides)
D: Requires: rpmlib(PayloadIsXz) <= 5.2-1 YES (rpmlib provides)似乎使用的是用于Requires 6/7场景的CentOS,而不是来自CentOS 8场景的CentOS。
我在这里看不到什么?我能做些什么来调试这个吗?
发布于 2022-01-27 14:21:06
您可以省略条件并依赖于语义exectutable,而不是policycoreutils-python包:
Requires(post): %{_sbindir}/semanage
Requires(post): %{_sbindir}/restorecon有关示例,请参阅Fedora的dokuwiki.spec。依赖于包的一个例子是bdii.spec。
发布于 2022-02-02 15:28:22
规范文件中的条件在构建期间进行计算。因此,当您的SPEC文件包含:
%if %{rhel} < 8
Requires(post): policycoreutils-python
%endif
%if %{rhel} == 8
Requires(post): policycoreutils-python-utils
%endif你在RHEL 7上构建你的软件包,然后它就会有
Requires(post): policycoreutils-python即使你在RHEL 8上安装了你的软件包,这个要求也会被使用。它不会在软件包构建后被重新评估。
如果您只想要一个二进制包,那么就需要Andreas指出的文件库所需的文件。企业解决方案是使用
Release: 1%{?dist}
...
%if %{rhel} < 8
Requires(post): policycoreutils-python
Requires(preun): policycoreutils-python
%endif
%if %{rhel} == 8
Requires(post): policycoreutils-python-utils
Requires(preun): policycoreutils-python-utils
%endif并使用以下方法为不同的平台构建它:
mock -r epel-7-x86_64 my.src.rpm
mock -r epel-8-x86_64 my.src.rpm第一个命令生成my-1.0-1.el7并要求policycoreutils-python,而第二个命令生成my-1.0-1.el8并需要policycoreutils-python-utils。
作为边注,条件应写成:
%if 0%{?rhel} < 8若要防止未定义宏时出现语法错误,请执行以下操作。
https://unix.stackexchange.com/questions/687719
复制相似问题