Question: the way to check if "load" macro is built-in in a spec file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Our spec file ruby.spec used for RHEL 7 ruby is implementing "load"
macro by ourselves like this.
Because the "load" built-in macro is available from rpm version 4.12.0. [1]
But we want to build the spec file with the following 2 environments.

* My local environment: Fedora 31 : rpm-4.15.1-1.fc31.x86_64
* RHEL 7 environment on mock (chroot): rpm-build-4.11.3-43.el7


%include %{SOURCE100}

%{load %{SOURCE4}}
%{load %{SOURCE5}}

$ cat
# Include the constants defined in macros files. Could be dropped as soon as
# RPM supports the %%load macro (RPM 4.12+ probably).
%define load() %{lua:source_macros(rpm.expand("%1"))} <= This line is error.

I got the following error when I executed the command "rhpkg srpm" to
create the SRPM file. This error comes from the rpm.

$ rpm -q rpm

$ rhpkg srpm
error: /path/to/ruby/ line 30: Macro %load is a built-in (%define)
error: query of specfile /path/to/ruby/ruby.spec failed, can't parse

Could not execute srpm: Could not get n-v-r-e from /path/to/ruby/ruby.spec

I want to call following line conditionally, "if the rpm version is >=
4.12.0" or "if the macro with options: "load()" is not defined as
built-in. For example like this. But it becomes error on the line "%if
! %{defined load}".
Do you have any idea how to fix this?

$ git diff
diff --git a/ b/
index bf9c07e..ba37835 100644
--- a/
+++ b/
+%if ! %{defined load} <= This line is error.
 %define load() %{lua:source_macros(rpm.expand("%1"))}

$ rhpkg srpm
error: /home/jaruga/git/rh-packages/scl/rh-ruby27/ruby/ line
30: failed to load macro file 0

  > %{load:...}         load a macro file (in >= 4.12.0)

Thank you.

Jun | He - His - Him

Rpm-list mailing list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux