'RPM Build error: Too many levels of recursion in macro expansion. It is likely caused by recursive macro declaration
I have been trying to build a rpm using rpmbuild but I keep getting the following error-
error: Too many levels of recursion in macro expansion. It is likely caused by recursive macro declaration.
Environment Details- rpmbuild --version RPM version 4.11.3
part of .spec file-
############# we define product here ###################
%define name abc
%define installdir /direc
############### product Info ###################
Summary: ABC management package
Name: %{name}
Version: %{version}
Release: %{release}
Source: %{name}-%{version}.tgz
Vendor: XYZ
License: Commercial
Group: System Environment/Libraries
Prefix: %{_prefix}
Buildroot: %{_tmpbuildroot}
################Dependencies ###########################
Requires : %{name} = %{version}, mod_php, php-pgsql
.rpmmacros file
%_topdir /home/jan/rpmbuild/
%_tmppath /home/jan/rpmbuild/tmp
%_tmpbuildroot /home/jan/rpmbuild/build
%_buildroot /home/jan/rpmbuild/BUILD
%version 100.0.111.20200213
%release R_jenkins-XXXXXX-61
%extra_require ameyocrm = 100.0.111.20200213
Command used to build rpm -
sudo rpmbuild -bb -vv /home/jan/Work/BuildMachine/RPM/rpm_spec/rpm/SPECS/myspecfile.spec --target "\x86_64-redhat-linux\"
Solution 1:[1]
%name
, %version
and %release
macros are in-built. You should not try to override them. The %name
macro is defined as the content of the Name:
tag, same goes for %version
and %release
.
Rewrite it to something like this:
Name: abc
Version: 100.0.111.20200213
Release: R_jenkins-XXXXXX-61
Source: %{name}-%{version}.tgz
...
EDIT: As noted by @Danila:
Requires : %{name} = %{version}
Means that your package requires itself, which makes no sense.
EDIT2
If you want to be able to define the version number and release from outside, you can just define another macro:
%{!?_version: %define _version 100.0.111.20200213 }
%{!?_release: %define _release R_jenkins-XXXXXX-61 }
Name: abc
Version: %{_version}
Release: %{_release}
these macros _version
and _release
are not standard and can be defined from outside your spec file.
Solution 2:[2]
try adding --define name <name> --define release <number>
to the rpmbuild command.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | StephenW |