-
I know that this option is not mentioned anywhere in documentation however IMO it should be present to be able not only define from command line macro using More interesting is that on use test-define.specSummary: test --define
Name: test-define
Version: 1
License: foo
Release: 2%{?dist}
%description
Test --define.
%prep
%if 0%{?test}
echo "test defined"
%endif
%check
echo "%{name} package has no test suite"
%files test-undefine.spec%define test 1
Summary: test --undefine
Name: test-undefine
Version: 1
License: foo
Release: 2%{?dist}
%description
Test --undefine.
%prep
%if 0%{?test}
echo "test defined"
%endif
%check
echo "%{name} package has no test suite"
%files And here are results: [tkloczko@pers-jacek SPECS]$ rpmbuild -bp test-define.spec
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.ySytzr
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ RPM_EC=0
++ jobs -p
+ exit 0
RPM build warnings:
source_date_epoch_from_changelog set but %changelog is missing
[tkloczko@pers-jacek SPECS]$ rpmbuild -bp test-define.spec --define "test 1"
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.PANGwI
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ echo 'test defined'
test defined
+ RPM_EC=0
++ jobs -p
+ exit 0
RPM build warnings:
source_date_epoch_from_changelog set but %changelog is missing So it works as expected. [tkloczko@pers-jacek SPECS]$ rpmbuild -bp test-undefine.spec
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.GM3NF2
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ echo 'test defined'
test defined
+ RPM_EC=0
++ jobs -p
+ exit 0
RPM build warnings:
source_date_epoch_from_changelog set but %changelog is missing
[tkloczko@pers-jacek SPECS]$ rpmbuild -bp test-undefine.spec --undefine test
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.2kdiZT
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ echo 'test defined'
test defined
+ RPM_EC=0
++ jobs -p
+ exit 0
RPM build warnings:
source_date_epoch_from_changelog set but %changelog is missing So |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
--define and --undefine execute long before the spec is parsed, so while they can affect the way a spec is parsed, neither can affect a macro defined inside a spec. |
Beta Was this translation helpful? Give feedback.
-
Please have look one more time on my examples. |
Beta Was this translation helpful? Give feedback.
-
No, read what I wrote more carefully. Neither --define or --undefine can affect a macro defined inside a spec. |
Beta Was this translation helpful? Give feedback.
-
Please have look ONE MORE time on specs example which disproves what you just wrote. |
Beta Was this translation helpful? Give feedback.
-
Can you show your executios of commands executions which I've provided? |
Beta Was this translation helpful? Give feedback.
-
Your "test-define" example is also not working like you expect. If you add
at the top of the specfile and add "%test" to your echo statement, you'll see that it echos "2" even if you call rpmbuild with Basically --define and --undefine work similar to adding define/undefine to the top of the spec file. So it is not possible to change a %define that comes later on. |
Beta Was this translation helpful? Give feedback.
--define and --undefine execute long before the spec is parsed, so while they can affect the way a spec is parsed, neither can affect a macro defined inside a spec.