Discussion:
error: Macro % has illegal name (%define) ?
Patrick
2007-10-24 18:43:12 UTC
Permalink
Hi all,

If I try to run the following script on a Fedora 7 box with rpm version
4.4.2.1.

#!/bin/bash
cd ~/redhat/SPECS
BUILDOPTS_libsupertone='--define "_smp_mflags -j1"'
rpmbuild -ba --target=i386 libsupertone.spec ${BUILDOPTS_libsupertone}

I get this error:

error: Macro % has illegal name (%define)
error: Macro % has illegal name (%define)
error: Macro % has illegal name (%define)
-j1": unknown option

Google gave no solution. Anyone know how I can make this work?

Thanks and regards,
Patrick
Marius Feraru
2007-10-25 11:09:26 UTC
Permalink
If I try to run the following script [...]
#!/bin/bash
cd ~/redhat/SPECS
BUILDOPTS_libsupertone='--define "_smp_mflags -j1"'
rpmbuild -ba --target=i386 libsupertone.spec ${BUILDOPTS_libsupertone}
error: Macro % has illegal name (%define)
Not really a RPM issue, but a bash one (and a quite reiterated one on bash
"forums", I may say). Let's rewrite your script:

#!/bin/bash
cd ~/redhat/SPECS

# avoid word splitting on "space"
IFS=$'\n'

# skip quotes, as popt (obviously) won't "dequote" arguments
BUILDOPTS_libsupertone='--define _smp_mflags -j1'

rpmbuild -ba --target=i386 libsupertone.spec ${BUILDOPTS_libsupertone}

# EOF

In the future, when you have bash troubles, try the "easy" debug way:
add "-x" to the shellbang (i.e.: #!/bin/bash -x). It usually helps :)
Try it on your script, you'll see how bash expands your variables.

cheers
- --
Marius Feraru
Patrick
2007-10-25 12:18:12 UTC
Permalink
Hi Marius,

On Thu, 2007-10-25 at 14:09 +0300, Marius Feraru wrote:
[snip]
Post by Marius Feraru
Post by Patrick
error: Macro % has illegal name (%define)
Not really a RPM issue, but a bash one (and a quite reiterated one on bash
Thanks for the tip. Clearly I used the wrong search terms on Google.
Post by Marius Feraru
#!/bin/bash
cd ~/redhat/SPECS
# avoid word splitting on "space"
IFS=$'\n'
Found this one in my Bash book. Will read up on it.
Post by Marius Feraru
# skip quotes, as popt (obviously) won't "dequote" arguments
Found docs about popt. More reading to do.
Post by Marius Feraru
BUILDOPTS_libsupertone='--define _smp_mflags -j1'
rpmbuild -ba --target=i386 libsupertone.spec ${BUILDOPTS_libsupertone}
# EOF
add "-x" to the shellbang (i.e.: #!/bin/bash -x). It usually helps :)
Try it on your script, you'll see how bash expands your variables.
Excellent suggestion. All makes sense now and the snippet works.
Many thanks for your help!

Regards,
Patrick

Loading...