Bug 693338

Summary: rpmbuild --specfile lists main package when only subpackages would be generated
Product: [Fedora] Fedora Reporter: Andrew Parker <andy>
Component: rpmAssignee: Jindrich Novy <jnovy>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 14CC: dcantrell, ffesti, jnovy, pknirsch, pmatilai
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-04 14:13:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Source RPM that illustrates the problem none

Description Andrew Parker 2011-04-04 10:58:48 UTC
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

Comment 1 Jindrich Novy 2011-04-04 14:13:31 UTC
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 ;)

Comment 2 Jesse Keating 2011-04-07 04:53:02 UTC
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?

Comment 3 seth vidal 2011-04-07 05:10:36 UTC
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']

Comment 4 Panu Matilainen 2011-04-07 06:04:08 UTC
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).

Comment 5 Jesse Keating 2011-04-07 21:55:05 UTC
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.

Comment 6 Panu Matilainen 2011-04-08 05:36:38 UTC
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.