RPM Community Forums

Mailing List Message of <rpm-users>

Re: Evaluating macros defined in specfiles

From: Eric MSP Veith <eveith@wwweb-library.net>
Date: Sun 03 May 2009 - 03:04:07 CEST
Message-Id: <200905030304.11768.eveith@wwweb-library.net>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

%{expand} is just what I was missing. I can put a construct using that into 
my own macros file to have it at hand. :-)

The only thing that still remains is the 8192b limit. I might be able to 
process the file linewise, though.

Thanks alot for the help!

		-- Eric


On Sunday 03 May 2009, Jeff Johnson <n3npq@mac.com> wrote:
> On May 2, 2009, at 6:38 PM, Eric MSP Veith wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hello list,
> >
> > if one defines a macro in a spec file, is there any way to evaluate
> > it from
> > a process started during/by rpmbuild?
> >
> > Background is: I wrote a little Perl script that translates macros
> > in files
> > for me. I use this for config or init files I supply with packages
> > and which
> > sometimes need a full path, and since I don't want to explicility
> > use sed
> > every time, I wrote this convenience script. I basically have lines
> > like
> >
> > "%{__cat} '%{SOURCE1}' | %{__m2rpath} > somefile'
> >
> > in my specfile, with '%{__m2rpath}' beeing my utility. It does
> > nothing more
> > than scanning each line for something that looks like a RPM macro
> > definition
> > (m/(%{\w+})/) and runs "rpm -E $1" against it. This works, of
> > course, well
> > with macros that are known to the whole build system, but fails with
> > new
> > definitions made in the spec file.
> >
> > Is there any way to catch those, too?
>
> Hmmm, I'm not quite sure what you are asking ... BUT ...
>
> you seem to want macros expanded in a text file.
>
> but you also want definitions from the spec file.
>
> which means that rpm -E isn't the right approach because its
> a whole different process context.
>
> you can expand macros in another file (there will be limits on buffer
> size ~8192b)
> if you do
>
> %{expand:%(cat %{SOURCE1})}
>
> All that %{expand:...} does is continue expansion from the begin
> point, not the
> end point, of the text added by %(cat %{SOURCE1}).
>
> So that achieves the expansion in the current process with the current
> defines.
>
> You can likely do something like (but it will be dependent on buried
> double quotes etc)
>
> echo "%{expand:%(cat %{SOURCE1})}" > somefile
>
> If you think a bit you might be able to use a construct like
>     cat << GO_SYSIN_DD > somefile
>     ...
>     GO_SYSIN_DD
> to avoid the embedded quote failures.
>
> hth
>
> 73 de Jeff
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> User Communication List                             rpm-users@rpm5.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkn87YcACgkQfkUtd7QNU/v7VQCgqLYZaKtwq0J2kO08s69b8rPx
FSgAnAtk3ofvCxodKs8yMSAGuL0JPlI8
=082N
-----END PGP SIGNATURE-----
Received on Sun May 3 03:04:42 2009
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.