lejeczek via users wrote: > On 08/06/18 16:39, Todd Zullinger wrote: >> lejeczek via users wrote: >>> how do you pass vars to rpmbuild for definition? eg >>> >>> rpmbuild --define \'"${_definition2}"\' >>> >>> I've been fiddling with ways to escape, but none is fricking working.. >>> I mean, rpmbuild rushes to work(no errors nor failure) so if you try just >>> command line do not believe it, because later as it executes %if you will >>> see process does not see these definitions. >> The format would be --define '_definition2 value'. The you >> would use %{_definition2} in your spec file, (which I'm >> presuming you already have, it's just not being defined). >> >> The man page explains is this way: >> >> -D, --define='MACRO EXPR' >> Defines MACRO with value EXPR. >> >> > > Try to pass bash var to rpmbuild, eg: > > $ _def1="_me 1" > $ rpmbuild --define=${_def1} > > %if does not seem to catch/see these definitions. Like I said rpmbuild will > run but you should see it is not there as .spec gets digested & processed. It's hard to guess what error you get since you have not included the output or a more complete example. But my guess is that you've not quoted the variable you're passing to --define. Here's an example spec and some example output: $ cat test.spec Name: test Version: 1.0 Release: 1%{?dist} Summary: Test spec License: MIT %description %{summary}. %prep %if 0%{?_me} echo "_me == %{_me}" %else echo "_me != 1" %endif # # Running without --define shows the %else clause is reached # $ rpmbuild -bp test.spec Executing(%prep): /bin/sh -e /home/tmz/src/packages/tmp/rpm-tmp.po8R74 + umask 022 + cd /home/tmz/src/packages/test + echo '_me != 1' _me != 1 + exit 0 # # Running with --define unquoted shows a failure # $ (_def1="_me 1"; rpmbuild -bp --define=$_def1 test.spec) error: Macro %_me has empty body # # Running with --define quoted shows the %if clause is reached # $ (_def1="_me 1"; rpmbuild -bp --define="$_def1" test.spec) Executing(%prep): /bin/sh -e /home/tmz/src/packages/tmp/rpm-tmp.jcPyKb + umask 022 + cd /home/tmz/src/packages/test + echo '_me == 1' _me == 1 + exit 0 If you're experiencing some other sort of failure, it would be useful if you included a shortened spec file and the rpmbuild commands and output. -- Todd ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Honesty may be the best policy, but it's important to remember that apparently, by elimination, dishonesty is the second-best policy. -- George Carlin
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx/message/RKWZW3FVMUSCBUS5URLV44FKTUF2KAWJ/