Closed hroncok closed 1 month ago
It's not just Lua state, spec parsing also affects global macro state so parsing specs without resetting the entire rpm context in between can and will yield different results. So, rpm.reloadConfig() before another parse (whether the same spec or different) is the right thing to do, as blunt as that hammer may seem.
I would love to have a have the entire spec parse context isolated to the spec object itself, but that's a long road.
Come to think of it, this little fact that you need to call rpm.reloadConfig() probably isn't documented anywhere...
Good catch, thanks for digging into the problem and implementing a solution!
So, I recently discovered a weird sitation.
Consider https://src.fedoraproject.org/rpms/fedora-obsolete-packages with this:
Regular RPM passing errors like this -- this is expected and correct:
However, rpmautospec (e.g. via
fedpkg verrel
) errors like this:This is certainly unexpected: gimp-save-for-web is not obsoleted multiple times.
Adding this to the beginning of the spec:
Makes the problem go away.
What happens is that the specfile does not suspect it will be parsed twice with the same Lua state. But rpmautospec does that in https://github.com/fedora-infra/rpmautospec/blob/31978b4832bda151652332bc298c4b59a065f426/rpmautospec/pkg_history.py#L158
...which is kinda my doing :/
The easy solution is to move the macro definitions into the for:
https://github.com/fedora-infra/rpmautospec/blob/31978b4832bda151652332bc298c4b59a065f426/rpmautospec/pkg_history.py#L133-L140
And call
rpm.reloadConfig()
after each attempt.However, that might be overkill. I will see if we can "restart" the Lua state somehow.