Skip to content

ui: update_report: fix source/binary confusion (LP: #2102147)#464

Open
schopin-pro wants to merge 2 commits intocanonical:mainfrom
schopin-pro:apport-collect
Open

ui: update_report: fix source/binary confusion (LP: #2102147)#464
schopin-pro wants to merge 2 commits intocanonical:mainfrom
schopin-pro:apport-collect

Conversation

@schopin-pro
Copy link
Contributor

Rather than relying on binary packages being named the same as their
source package, we actually split the two of them. There's an underlying
assumption that we're reporting to a backend that cares about source
packages, so that's what we're basing it all on, by adding a field to
list the binary packages actually installed from that source package.

It might not work perfectly (the Package field will be marked with "not
installed" for glibc, for instance), but it's still much better than the
current state.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/apport/+bug/2102147

Rather than relying on binary packages being named the same as their
source package, we actually split the two of them. There's an underlying
assumption that we're reporting to a backend that cares about source
packages, so that's what we're basing it all on, by adding a field to
list the binary packages actually installed from that source package.

It might not work perfectly (the Package field will be marked with "not
installed" for glibc, for instance), but it's still much better than the
current state.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/apport/+bug/2102147
@schopin-pro schopin-pro requested a review from bdrung March 12, 2025 17:24
@schopin-pro
Copy link
Contributor Author

Ugh, apparently the tests assume that -p is for the source package. This entire thing is just sooooo confusing.

return {
pkg.name
for pkg in self._cache()
if pkg.installed and (source_package == pkg.installed.source_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if pkg.installed and (source_package == pkg.installed.source_name)
if pkg.installed and source_package == pkg.installed.source_name

self.cur_package = src
self.report["SourcePackage"] = src
self.report["Package"] = src # Slight abuse of the field but it's mandatory
self.report["InstalledBinaries"] = " ".join(sorted(binaries))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably also want to collect the version of those packages (similar to what Dependencies does).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to answer that we don't need it since it's already known, but actually that's a really good point, that would show mixed-version weirdness.

# hook available to collect sensible information
try:
packaging.get_version(p)
packaging.get_version(next(iter(binaries)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will only return one of the binary packages and is not stable.

try:
packaging.get_version(p)
packaging.get_version(next(iter(binaries)))
except ValueError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Can we still reach that exception?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants