I never worked with rpm spec files before so the answer can be quite obvious. My custom rpm has several versions to simplify let it be 1.0.0 and 2.0.0. For example, it can work with or without packageA but if packageA is installed for version 2.0.0 it should be at least 7.0.0. For testing purposes I create hello-world.spec file.
$cat hello.spec
[mylaptop]# cat ~/hello.spec
Name: hello-world
Version: 1
Release: 1
Summary: Most simple RPM package
License: FIXME
%define packageA_installed %(rpm -qa packageA-client)
%define version 2.2.0
%if "%packageA_installed"
%global with_packageA 1
# just for test purpose it will be deleted after testing and I will only set with_packageA
Requires: packageA-client == 1
%else
# just for test purpose it will be deleted after testing and I will only set with_packageA
Requires: packageA-client == 0
%global with_packageA 0
%endif
# I need check if packageA is installed and current rpm version 2.2.0
%if "%with_packageA" == "1" && "%{version}" == "2.2.0"
#if true - for 2.2.0 can work only with 7.0.0 and higher packageA
Requires: packageA-client >= 7.0.0
%endif
.......
On the system where packageA-client is installed:
[mylaptop(with packageA-client)]# rpm -qa packageA-client
packageA-client-7.0.0-93073D.RedHat7.x86_64
[mylaptop(with packageA-client)]# rpm -i hello-world-1-1.x86_64.rpm
error: Failed dependencies:
packageA-client = 1 is needed by hello-world-1-1.x86_64
It means that packageA-client was found and error is expected
Then I try to run the same on the system where is packageA-client is not installed:
[mylaptop(without packageA-client)]# rpm -qa packageA-client
[mylaptop(without packageA-client)]# rpm -i ~/hello-world-1-1.x86_64.rpm
error: Failed dependencies:
packageA-client = 1 is needed by hello-world-1-1.x86_64
packageA-cllent >= 7.0.0 is needed by hello-world-1-1.x86_64
[mylaptop(without packageA-client)]#
I expect that error will be packageA-client = 0 is needed by hello-world-1-1.x86_64
since it should go to the else condition because if not true since packageA-client was not found. What is wrong here and what is the right way to implement logic like this.
Requirestag to ensure thatpackageAis installed. If you can install the package withoutpackageA, you don't have a requirement. That is, whether or nothello-worlddepends onpackageAdoes not depend on whetherpackageAis already installed or not. What are you really trying to accomplish here? - chepnerpackageA-clientbe installed ifpackageAis installed, that makes a little more sense, though I'm not sureRequiresis the best way to manage it. What should happen if you installhello-worldfirst withoutpackageAbeing installed, then subsequently installpackageA? - chepnerif (packageA == installed && version == 2.2.0)then packageA should be at least 7.0.0. Regards your second question the same logic should be done for packageA if hello-world is installed and it version 2.2.0 the we should not allow packageA installation lower then 7.0.0. - Nick SConflicts: packageA < 7.0.0will handle that case, but there's still the issue of making thepackageA-clientrequirement depend on the presence ofpackageA. - chepnerclientin the naming of variable... to not write it likewith_packageA-clientThank you for answer I will tryConflicts:- Nick S