Skip to content

[plugin/unpackaged] Improve output filename to reflect data source#4218

Open
pranlawate wants to merge 1 commit intososreport:mainfrom
pranlawate:issue-4216-improve-unpackaged-naming
Open

[plugin/unpackaged] Improve output filename to reflect data source#4218
pranlawate wants to merge 1 commit intososreport:mainfrom
pranlawate:issue-4216-improve-unpackaged-naming

Conversation

@pranlawate
Copy link
Copy Markdown


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@example.com?
  • Are any related Issues or existing PRs properly referenced
    via a Closes (Issue) or Resolved (PR) line?
  • Are all passwords or private data gathered by this PR obfuscated?

Summary

The unpackaged plugin output file was named simply 'unpackaged', which didn't indicate the collection methodology, making it difficult for users to reproduce outside of sos.

This PR changes the output filename to dynamically reflect the package manager's files_command (e.g., 'path_grep_v_rpm_qal' on RPM systems), making it clear that the file lists binaries in $PATH not tracked by the package manager.

Changes

  • Modified sos/report/plugins/unpackaged.py to generate dynamic filenames based on package manager's files_command
  • Fixed MultiPackageManager compatibility by accessing the primary package manager's files_command attribute
  • Updated tests in tests/report_tests/plugin_tests/collect_manual_tests.py to expect new filename format
  • Passes pylint with 10.00/10 score

Testing

  • ✅ Manually tested on Fedora with RPM package manager
  • ✅ Generates correct filename: path_grep_v_rpm_qal
  • ✅ File contains expected unpackaged binaries
  • ✅ Pylint: 10.00/10

Resolves: #4216

  The unpackaged plugin output file was named simply 'unpackaged',
  which didn't indicate the collection methodology, making it
  difficult for users to reproduce outside of sos.

  Changed to dynamically generate filename from the package manager's
  files_command (e.g., 'path_grep_v_rpm_qal' on RPM systems), clearly
  indicating that it lists files in $PATH not tracked by the  package
  manager (rpm -qal output).

  Also fixed MultiPackageManager compatibility by accessing the primary
  package manager's files_command attribute.
  Resolves: sosreport#4216

Signed-off-by: Pranav Lawate <pran.lawate@gmail.com>
@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/sosreport-sos-4218
  • And now you can install the packages.

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

Comment on lines +87 to +94
if pkg_mgr_cmd:
# Sanitize command to filename: 'rpm -qal' -> 'rpm_qal'
sanitized_cmd = pkg_mgr_cmd.replace(' ', '_').replace('-', '')
# Filename represents grep -v metaphor, not exact command
filename = f'path_grep_v_{sanitized_cmd}'
else:
# Fallback for package managers without a command
filename = 'path_grep_v_pkg_files'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I mentioned in #4216, since the package manager is what implements the all_files() logic and we cannot say that this will always be a single command execution, I don't think building the command into this filename is the right choice here. We'd introduce further churn if we onboard a package manager in the future where this is the case, as we then have to refactor this once again which could cause downstream tooling issues.

Further, I really don't think we should include grep, much less with options, in the filename since we aren't doing grep at all.

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.

Improve sos_commands/unpackaged/unpackaged for a better name.

2 participants