#40 spectool -R does not understand %_sourcedir %{_topdir}/SOURCES/%{name}
Closed 3 years ago by ngompa. Opened 5 years ago by nim.

My ~/.rpmmacros contains

%_sourcedir %{_topdir}/SOURCES/%{name}

Which is pretty much mandatory nowadays to avoid drowning in file collisions in SOURCES (many upstreams have stopped checking their archive naming is unique)

Unfortunately spectool -R seems not to understand this syntax and wants to download files into a %{name} subdirectory.


The spectool implementation has been completely replaced. Please try the new implementation and see if it solves your problems!

Unfortunately, that is still broken in the new implementation, even when sources are set in %sourcelist, after the preamble that sets%{name}

Probably RPM evaluates _sourcedir before it evaluates the .spec file, and hence name is undefined?

Yes, probably rpm evaluates things at a point where they do not need evaluation, and does not re-evaluate at the point the evaluation is needed and all variables has been set

https://github.com/rpm-software-management/rpm/issues/1234

All that would not matter if rpm devs had not created a situation where there is a single evaluation point for this stuff, without checking the evaluation point was the right one.

If this is broken, then does rpmbuild even evaluate those macros correctly? E.g. if you run rpmbuild -bs path.to.spec?

https://pagure.io/rpmdevtools/blob/master/f/rpmdev-spectool#_394 is not going to fly. You try to expand some macro, but do not define any necessary macro for that. You should be able to gather this info from somewhere inside RPM, but not sure how to do this off top of my head.

In [1]: import rpm                                                                                                                                                                                                                            

In [2]: rpm.expandMacro("%_sourcedir")                                                                                                                                                                                                        
Out[2]: '/home/brain/rpmbuild/SOURCES/%{name}'

In [3]: spec = rpm.spec("rust-procinfo.spec")                                                                                                                                                                                                 

In [4]: rpm.expandMacro("%_sourcedir")                                                                                                                                                                                                        
Out[4]: '/home/brain/rpmbuild/SOURCES/rust-procinfo'

Instead of shelling out to RPM, just call expandMacro() after parsing a spec.

Metadata Update from @ngompa:
- Issue status updated to: Closed (was: Open)

3 years ago

The new implementation works fine with the few specs I tested it with, thank you very much.

The new implementation works fine with the few specs I tested it with, thank you very much.

All it takes is just providing reproducer without saying shitty words about people.

All it takes is reading reports and PRs without saying shitty words about reporters.

FYI between the report and your question my whole dev stack broke once because the latest rpm 4.15 workaround was not solid enough.

And, the warning you had to workaround in the rpm codebase, was added by Panu to make clear he wanted people who reported this problem to get lost.

Thanks a lot for actually fixing rpm,

This all could have been dealt with gracefully a month ago when I started reporting those instead of attacking the reporter.

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #56 Merged 3 years ago