RPM 패키지가 빌드된 시스템이 CentOS인지 여부를 사양 파일에서 어떻게 확인합니까?

RPM 패키지가 빌드된 시스템이 CentOS인지 여부를 사양 파일에서 어떻게 확인합니까?

Requires:빌드된 특정 배포판에 따라 달라지는 필드 가 포함된 사양 파일이 있습니다 . 따라서 다음과 같은 조건부 구조를 만들 수 있어야 합니다.

%if %{?fedora}
Requires:       xterm libssh clang
BuildRequires:  wxGTK3-devel  cmake clang-devel lldb-devel libssh-devel hunspell-devel sqlite-devel desktop-file-utils
%endif
%if (centos test)
Requires:       xterm libssh clang
BuildRequires:  wxGTK3-devel cmake clang-devel lldb-devel libssh-devel hunspell-devel
%endif

여기서는 (centos test)우리가 사용하는 배포판이 CentOS인지 확인하기 위한 몇 가지 테스트로 대체될 것입니다. 나는 이것을 테스트하기 위해 %{?rhel}and 를 사용해 보았습니다. %{?centos}그러나 둘 다 실패했습니다. 나는 또한 이러한 테스트를 시도했지만 그 %{rhel}%{centos}아무 것도 작동하지 않았습니다(매크로를 인식하지 못하는 것 같습니다). RPM 매크로 참조를 검색했습니다(예:https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s07.html그리고https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html-single/RPM_Guide/index.html) 그러나 이러한 유형의 매크로는 언급되지 않았습니다.

답변1

에서 인용https://fedoraproject.org/wiki/Packaging:DistTag#Conditionals:

특정 릴리스 시리즈를 확인하려면 다음을 사용해야 한다는 점을 기억하세요.

%if 0%{?rhel}

설마

%if %{?rhel}

추가 0이 없으면 %{rhel}이 정의되지 않은 경우 %if 조건이 더 이상 존재하지 않으며 rpm이 빌드되지 않습니다.

마찬가지로 첫 번째 조건에서는 0%{?fedora}를 사용해야 합니다.

관련 정보