2

I have a build support script for building my packages. Now I want to automatically set the Version in my spec files. I use the macro %{auto_version} for that. In my script I want to invoke rpmbuild -D 'auto_version 1.1' packet.spec for example.

#!/bin/bash
version=$(version.sh)
#snip
define="'auto_version ${version}'"

build_spec () {
    spec=$1
    define=$2
    #snip
    build_output=$(rpmbuild -D "$define" $spec)
    # snip
}

build_spec $build_spec "$define"

However this generates the error error: Macro % has illegal name (%define)

I've tried different escaping, quoting and making define an array, handled with ${define[@]}.

2
  • version.sh correctly outputs a version number e.g. 0.1
    – sahisb
    May 15, 2017 at 16:02
  • 4
    Basically copied from my answer to your previous, now-deleted question: pretty sure you really want define="auto_version ${version}" without the single quotes (though not familiar with RPM; but requiring literal quotes in the value would be very weird indeed).
    – tripleee
    May 15, 2017 at 18:02

1 Answer 1

2

As @tripleee right points, the reason of error: Macro % has illegal name (%define) is extra quotes in -D|--define directives like:

-D "\"_gpg_name $gpgname\""

the right version is:

-D "_gpg_name $gpgname"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .