Hide Forgot
Created attachment 489737 [details] Source RPM that illustrates the problem Description of problem: "rpm -q --specfile" on a spec file that only produces subpackages lists the main package. Version-Release number of selected component (if applicable): rpm-build-4.8.1-5.fc14.x86_64 How reproducible: Always Steps to Reproduce: Using the attached src rpm. $ rpm2cpio test-case-1-1.src.rpm | cpio --extract test-case.spec 22 blocks $ cat test-case.spec # Make sure test case doesn't eat babies $ rpm -q --specfile test-case.spec test-case-1-1.noarch test-case-subpackage-1-1.noarch # Note that test-case-1-1.noarch is listed $ rpmbuild --rebuild test-case-1-1.src.rpm Installing test-case-1-1.src.rpm <snip> + exit 0 $ find ~/rpmbuild/RPMS -type f /home/andy/rpmbuild/RPMS/noarch/test-case-subpackage-1-1.noarch.rpm # Note how test-case-1-1.noarch was not generated
Fixed in upstream. rpm -q --specfile <a spec> will no more list the not-generated package while assuming the spec syntax is sane. writeRPM() won't write the packages in case of broken scriplets + other possible cases. The --specfile query should display all written packages if the build passes. Closing this UPSTREAM as it's not too critical bug. However thanks for the perfect bug report, description + reproducer ;)
A side effect is that it breaks fedpkg for these packages. We were querying the spec file to figure out the base package name, and now I don't think we have a query left. I'm going to look and see if we can get at that info by using a python binding to parse the spec file, but in the mean time this is going to break rawhide builds. Can we revert this for a period of time until fedpkg is ready?
I think this is what you need to do it from the python bindings import rpm s = rpm.spec('file.spec') module = s.sourceHeader['name']
Ugh, I didn't realize this breaks fedpkg. The source header is available to python only in rpm >= 4.9.0 currently, so that's probably not an option yet. OTOH the binary headers are available in rpm >= 4.8.0 so it's possible to do the same as with rpm --specfile query: the first package is always the main package, eg >>> import rpm >>> spec = rpm.spec('glib2.spec') >>> mpkg = spec.packages[0] >>> mpkg.header['name'] 'glib2' >>> Another wrinkle comes in the form of macros: fedpkg uses pile of --defines to rpm, with python you need to use rpm.addMacro() etc, but the bigger gotcha is that when using the python bindings, any macros defined in the spec carry into fedpkg itself, which you probably dont want. Might be simplest to have a fedpkg-specific helper script to query the specfiles... In the meanwhile, I'll revert the change from Fedora (rawhide + f15 updates).
I don't suppose there is anything that works all the way back to RHEL5 (rpm-4.6.0)? Right now my code works all the way back, I don't really want to fracture it.
I suspect there isn't, the python bindings don't have anything that would help this in rpm < 4.8.0. We might need to make the old behavior default in upstream too and instead have some kind of option to enable the new behavior (adding options is much more feasible now with rpmspec being it's own separate utility) Meanwhile I've pulled out the patch from Fedora so you don't need to worry about it for now.