• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

rpm spec file question

  • Thread starter Thread starter CU
  • Start date Start date

CU

Platinum Member
I would like to have an rpm require different rpms based on some shell commands.
I know you can do this based on distro versions.
if 0%{?fedora} >= 4
Requires: foo
%endif

But, when I try to define my own macro it sets it at build time and not install time.
%define test %(test -e /tmp/test.txt && echo 1 || echo 0)
%if 0%{?test} == 1
Requires: foo
%endif

Is there a way to evaluate the macro later or is it always evaluated when you create the rpm?
 
I believe it is only evaluated at build time. That is why you see different rpm's out there for the different distributions, like:
zenoss-4.1.70-1485.el5.x86_64.rpm
zenoss-4.1.70-1485.el6.x86_64.rpm
zenoss-4.1.70-1485.fc16.x86_64.rpm

etc....
 
I think you may be right. I just tired it using a distro macro and it sets it based on what distro it is build on not installed on. Really wish there was a way to do this, but it appears I will need two builds and two spec files. Using distro macros or custom macros in this way are useless if you only have one build machine because everything is set based on that machine. You would need to build the rpm on each distro version that you want to make custom changes to. This seems like a short coming of the rpm spec. Although I don't know how other package managers or installers on other OS's handle it either, I would think something else could handle this.
 
I would assume that rpm does simply read the list of requirements from rpm-package without executing code at that point. One can do 'rpm -Rp foo.rpm', and that does not even install anything.

Think of yum repository too. It has cached metadata from the packages for more efficient dependency retrieval. The repo is maintained in some server; one distro.

Virtualization has made it a bit easier to have N distros for building.
 
Back
Top