Bug 1741715

Summary: rpm-build: populate the %{sourcepkgid} tag
Product: [Fedora] Fedora Reporter: Vincent Batts <vbatts>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dennis, igor.raits, jkeating, kevin, mikem, mjw, packaging-team-maint, pmatilai, pmoravco, puiterwijk, rbarlow, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-28 11:21:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vincent Batts 2019-08-15 22:57:52 UTC
Description of problem:
when building rpms and populating the fields, the ${sourcerpm} field is populated, and that corresponding src.rpm has its ${pkgid} field populated, can we please populate the ${sourcepkgid} field to the rpms.

Version-Release number of selected component (if applicable):
rpm-4.11.3-35.el7.x86_64 and rpm-4.14.2.1-4.fc30.1.x86_64 

How reproducible:
always missing

Steps to Reproduce:
1.rpm -q --queryformat '%{name} %{pkgid} %{sourcepackage} %{sourcerpm} %{sourcepkgid}\n' bash
2. rpm -qp --queryformat '%{name} %{pkgid} %{sourcepackage} %{sourcerpm} %{sourcepkgid}\n' bash-4.2.46-31.el7.src.rpm
3.

Actual results:
bash ed4d986a9753c79474e6ab726f40d864 (none) bash-4.2.46-31.el7.src.rpm (none)
bash b43126f3f818c27557532d67d1a0da01 1 (none) (none)


Expected results:
bash ed4d986a9753c79474e6ab726f40d864 (none) bash-4.2.46-31.el7.src.rpm b43126f3f818c27557532d67d1a0da01
bash b43126f3f818c27557532d67d1a0da01 1 (none) (none)

Additional info:

Comment 1 Panu Matilainen 2019-08-16 08:25:41 UTC
Rpm only stores the sourcepkgid if the source rpm was built in the same run as the binary (that is, built with -ba), this is by design AFAICT.

When -ba is used, the pkgid of the source rpm is inserted to the binaries from that build as the sourcepkgid.
When no source package is built, there is no source id to insert.

That sourcepkgid is missing is a side-effect of how our build-system(s) work, not something that rpm can help with.
One could argue that --rebuild should insert the pkgid of the src.rpm being rebuilt, but that would break the contract of "built in the same run".

Comment 2 Panu Matilainen 2019-08-16 08:41:57 UTC
On a second thought, koji can't do anything about it either.

This is actually working as designed, to the effect that it shows how it was (not) built.
Even if mock+koji used -ba to build the resulting package, the resulting (source)pkgid would be specific to that architecture, yet we only ship one src.rpm per package. So it would still be different for all but one (random) architecture.

This would call for a different kind of id/hash altogether. Reassigning back to rpm for further consideration as an RFE.

Comment 3 Vincent Batts 2019-08-20 19:29:51 UTC
I could see where various architecture binary rpms point to the same `sourcepkgid`. That makes sense, and not a blocker.

As for some contract of "built in the same run", this seems a silly contract to hold. If I --rebuild a src.rpm, the resulting rpm should still point to it.

Comment 4 Panu Matilainen 2019-08-21 08:11:36 UTC
The contract is what it is, made long long time ago and we can't just go change it.
The thing is, if --rebuild were to produce an src.rpm, its id would differ from that of the one used to launch the build, because all sorts of timestamps and architecture-specific information is encoded in there.

I think the productive way out of this would be to generate a new kind of hash that is actually reproducable (basically, hash of the spec itself + all sources and patches) across different builds, and store that into binaries and sources similarly, but without the requirement of same run.

Comment 5 Panu Matilainen 2019-11-28 11:21:25 UTC
As explained above, the %{sourcepkgid} tag behavior is not a bug, closing.

I opened an upstream ticket to discuss alternative approaches though:
https://github.com/rpm-software-management/rpm/issues/957