Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flatpak] Capture details about branch #3406

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

jcastill
Copy link
Member

@jcastill jcastill commented Nov 3, 2023

Gather details about branch, so it complements
the version number (which can be empty sometimes).

Fixes: #3404


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname [email protected]?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?

Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3406
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

pkg = line.split()
name, version = pkg[0], pkg[1]
yield (name, version, None)
for line in pkg_list.splitlines()[1:]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the [1:]? The flatpak list does not start with a header, the very first line already contains a package - at least in my case..

Copy link
Member Author

Choose a reason for hiding this comment

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

It does in my case, but if I recall correctly, the output is different when called from sos, and there's no header there. I've fixed this in the next version.

Comment on lines 27 to 32
name, branch = pkg[0], pkg[2]
if not pkg[1]:
version = ''
else:
version = pkg[1]
yield (name, version, branch)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simple yield (pkg[0], pkg[1], pkg[2]) ? (maybe worth checking len(pkg)>2, just in case of truncated output (or that is over-paranoic..?))

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me try this and see if it covers the empty version case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Checking the length of pkg and then yielding either pkg[1] or None seems better than just yielding pkg[1] regardless of it being there or not:

        if len(pkg) > 2:
            yield (pkg[0], pkg[1], pkg[2])
        else:
            yield (pkg[0], None, pkg[2])

Unless yielding pkg[1] when doesn't exist changes it to None on the yield, which then may simply the code a lot. But I saw in the other sources in package_managers that we explicitly set to None.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, I am not sure now if the split returns None or empty string. But can we pass None as version? Does not we expect a string value later on?

Copy link
Member Author

Choose a reason for hiding this comment

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

Later on I'm not sure, but if that's the case, we can fail back to "" instead of None. Let me see if I can test with packages with empty value and see what happens with None.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, split returns empty string and not None (which is in fact obvious, it returns list of strings):

>>> "name\tvers\tbranch".split("\t")
['name', 'vers', 'branch']
>>> "name\t\tbranch".split("\t")
['name', '', 'branch']
>>> 

And as far as I checked, we assume strings there.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I just checked what we get with yield (pkg[0], pkg[1], pkg[2]) without checking pkg lenght, from _generate_pkg_list, and it is an empty string. So just that line should be enough.

Gather details about branch, so it complements
the version number (which can be empty sometimes).

Fixes: sosreport#3404

Signed-off-by: Jose Castillo <[email protected]>
@TurboTurtle TurboTurtle merged commit ca2e293 into sosreport:main Nov 7, 2023
30 checks passed
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.

[flatpak] Missing flatpak versions break sos execution
3 participants