## Sumamry
`%define` macro is not evaluated, the value is not set when building a RPM spec
file with rpm-4.11.3-40 and `%bcond_without git` is executed.
## Context
I was trying to build a `ruby.spec` file on RHEL7, that is based on the Fedora
rawhide current latest `ruby.spec`
[URL](https://src.fedoraproject.org/rpms/ruby/blob/345ce0e5b8a3a6d9c962807da12e80bdaee9fb90/f/ruby.spec#_25).
But the built RPM was `ruby-2.7.0-%{release_string}.x86_64.rpm`. The
`%{release_string}` value was not set. On Fedora rawhide, the value was set.
The `ruby.spec` code is like this.
```
...
%global release 126
%{!?release_string:%define release_string
%{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}}
...
%bcond_without git
...
Release: %{release_string}
...
```
So, I prepared the simple example to reproduce this issue, with GitHub and
Travis CI.
Here is [the reproducing
example](https://github.com/junaruga/report-rpm-macro-define), and the [Travis
CI
result](https://travis-ci.org/junaruga/report-rpm-macro-define/builds/639514301).
Using very simple RPM spec file
[foo.spec](https://github.com/junaruga/report-rpm-macro-define/blob/master/foo.spec),
and building it by `rpmbuild -ba foo.spec`.
Here is the result. See above Travis CI result.
1. fedora:rawhide / rpm-4.15.1-2.fc32.x86_64 : OK
2. fedora:31 / rpm-4.15.1-1.fc31.x86_64 : OK
3. centos:8.1 / rpm-4.14.2-25.el8.x86_64 : OK
4. centos:7.7 / rpm-4.11.3-40.el7.x86_64 : NG
5. centos:7.7 / rpm-4.11.3-40.el7.x86_64 does not execute `%bcond_without git`:
interestingly this case is OK
## Result
### OK case
https://travis-ci.org/junaruga/report-rpm-macro-define/jobs/639514306#L510
```
+ echo 'release_string: 2.el7.el7'
release_string: 2.el7.el7
+ echo 'bbb: 2'
bbb: 2
+ echo 'ddd: 2'
ddd: 2
+ echo 'fff: 2'
fff: 2
```
https://travis-ci.org/junaruga/report-rpm-macro-define/jobs/639514306#L556
```
+ find /root/rpmbuild/ -type f
/root/rpmbuild/SRPMS/foo-2.7.0-2.el7.src.rpm
/root/rpmbuild/RPMS/x86_64/foo-2.7.0-2.el7.x86_64.rpm
/root/rpmbuild/BUILD/foo
```
### NG case
https://travis-ci.org/junaruga/report-rpm-macro-define/jobs/639514305#L506
```
+ echo 'release_string: %{release_string}'
release_string: %{release_string}
+ echo 'bbb: %{bbb}'
bbb: %{bbb}
+ echo 'ddd: 2'
ddd: 2
+ echo 'fff: %{fff}'
fff: %{fff}
```
https://travis-ci.org/junaruga/report-rpm-macro-define/jobs/639514305#L552
```
+ find /root/rpmbuild/ -type f
/root/rpmbuild/SRPMS/foo-2.7.0-%{release_string}.src.rpm
/root/rpmbuild/RPMS/x86_64/foo-2.7.0-%{release_string}.x86_64.rpm
/root/rpmbuild/BUILD/foo
```
## Questions
1. Why this issue happens on rpm 4.11.3 when only `%bcond_without git` is
executed?
2. When Fedora's `ruby.spec` has to consider backward ccompatibility on
CentOS7, what is the best pracitce dealing with `%define` macro? We should not
use `%define` macro?
Thank you.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1013___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint