Rpmbuild –define | Some Rpm Sorcerer Around?

Home » CentOS » Rpmbuild –define | Some Rpm Sorcerer Around?
CentOS 7 Comments

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

7 thoughts on - Rpmbuild –define | Some Rpm Sorcerer Around?

  • 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}”‘

  • none of of these work for me, like I said earlier I fiddle a bit with it. I was hoping someone could confirm this and then maybe it’s a bug?

  • This sounds like you’re running into bash quoting issues, not a bug in rpmbuild. Are you running these commands in a shell script? Is it executed from a non-interactive service?

  • Everything in bash script. It actually might be working. What I did was I was looking for a confirmation like this:

    $ ps -FC rpmbuild –cols 9999
    UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
    appmgr 24855 24835 0 44512 6772 16 17:33 pts/0 00:00:00 rpmbuild
    –define “_MKL 1” –define “_mic 1”

    waiting to see those quotation marks(single or double) in there, but.. it turns out that it works actually when ps is not showing them, like:

    $ ps -FC rpmbuild –cols 9999
    UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
    appmgr 24855 24835 0 44512 6772 16 17:33 pts/0 00:00:00 rpmbuild
    –define _MKL 1 –define _mic 1

    and then vars(in a bash script, all in such a script) are simply declared:
    … export _definition1=’_MKL 1′
    rpmbuild –define “${_definition1}” –define “${_definition2}”

    without! any escaping of quotes.

  • Most of the time, bash will not replace variables inside single quotes, so I am not sure that would work. I use for my mock script:

    mock –configdir=$configdir -D “dist $dist” -r $mock_cfg

    It seems not to get confused with double quotes there .. but it puts in the literal value $dist if I use single quotes.