RPM API: parseSpec and macroContext

Panu Matilainen pmatilai at redhat.com
Wed Feb 12 07:39:15 UTC 2020


On 2/11/20 8:04 PM, Matwey V. Kornilov wrote:
> Hello,
> 
> I would like to read a number of spec files in a row in my
> application. However, I've found that RPM maintains global macro
> context inside rpmSpec type.
> This way, a macro from the first spec are visible for other spec
> files, leading to parsing issues. What should be a proper way to
> revert macro context to the initial state before subsequent calling
> parseSpec()?
> 

Being quite familiar with this problem, I was about to point you to 
rpmspec.c source for an example, but seems I never actually got to fix 
the problem there :(

So I'll have to point you to a freshly created pull-request instead:
https://github.com/rpm-software-management/rpm/pull/1067

But to summarise, simply call rpmFreeMacros() and rpmReadConfigFiles() 
after each attempted spec parse. This is a shotgun solution of course 
but there's no better way to reset the state at the moment.

	- Panu -



More information about the Rpm-list mailing list