[CentOS] rpmbuild --define | some rpm sorcerer around?

Sat Jun 9 12:13:51 UTC 2018
Phil Perry <pperry at elrepo.org>

On 08/06/18 22:54, lejeczek wrote:
> 
> 
> On 08/06/18 19:38, Phil Perry wrote:
>> On 08/06/18 15:54, lejeczek wrote:
>>> hi
>>>
>>> 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 the command line do not believe it, because later as it executes 
>>> %if you will see process does not see these definitions.
>>>
>>> many thanks, L
>>
>> I'm not sure what you are trying to define above.
>>
>> Normal convention where one wishes to define _foobar as "foo" for 
>> example would be:
>>
>> rpmbuild --define '_foobar foo'
>>
>> or generically
>>
>> rpmbuild --define 'SomeVariable SomeValue'
>>
>> Hope that helps
> 
> Try to pass bash var to rpmbuild, eg:
> 
> $ _def1="_me no"
> $ rpmbuild --define ${_def1}
> 
> 

I assume you are doing this in a bash script?

${_def1} may need to be quoted as it contains a space.

But for that I would do the following to make it more readable:

ME="no"
rpmbuild --define '_me ${ME}'


or if ${ME} contains spaces:

rpmbuild --define '_me "${ME}"'