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

Fix importing module metadata from REMI's repositories #9003

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/spacewalk/satellite_tools/appstreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _parse_rpm_name(nevra):
pattern = re.compile(
r"(?P<name>[a-zA-Z0-9._+-]+)-"
r"(?P<epoch>\d+:)?"
r"(?P<version>[a-zA-Z0-9._-]+)-"
r"(?P<version>[a-zA-Z0-9._-~]+)-"
Copy link
Member

Choose a reason for hiding this comment

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

Is a hyphen/dash inside the version string valid? openSUSE's packaging documentation says it's not available, does that differ in the RH world?

RPM uses the dash to separate the package name, the package version and the distro-level re-issue ("release") counter. (rpm -qa for example emits coreutils-9.0-1.x86_64.) The dash itself is unavailable for use within the version or release substring, as are a few other characters like the asterisk. [...]

https://en.opensuse.org/openSUSE:Package_versioning_guidelines#Unusual_characters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The real problem is that there's no actual standard between distros and like also mentioned there in the document, some distros are pretty liberal with this.

For "hyphens in version" case, Ubuntu/Debian is the offender. Here are some examples:

ipxe-qemu-256k-compat-efi-roms-1.0.0+git-20150424.a25a16d-0ubuntu4.all-deb.deb
ipxe-1.0.0+git-20190109.133f4c4-0ubuntu3.all-deb.deb
ipxe-qemu-1.0.0+git-20190109.133f4c4-0ubuntu3.all-deb.deb
grub-ipxe-1.0.0+git-20190109.133f4c4-0ubuntu3.all-deb.deb
lib32gcc1-10-20200411-0ubuntu1.amd64-deb.deb
libx32gcc1-10-20200411-0ubuntu1.amd64-deb.deb

I should probably add some more test cases reflecting this.

Copy link
Member

Choose a reason for hiding this comment

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

Is appstreams.py also used by Debian repos? I thought this was RPM-only.

Package version schemas definitely differ between packaging formats and we can't have one way to handle all of them. The same applies to version comparisons, where has their own rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

libsolv has some version comparison algorithms from which maybe some reasonable expectations for a version string can be extracted:

https://github.com/openSUSE/libsolv/blob/master/src/evr.c

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 can have a look at it if it covers all the necessary formats. But in any case, further changes are not in scope for this fix and I don't want to risk any regressions without testing extensively. So I'm just going to merge this one as is.

r"(?P<release>[a-zA-Z0-9._+-]+)\."
r"(?P<arch>[a-zA-Z0-9._-]+)"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Support more NEVRA types when importing module metadata
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ def test_get_modules(importer):
"396.module_el8.1.0+6019+b22674e1",
"noarch",
),
(
"php-pecl-gmagick-0:2.0.5~RC1-4.el8.remi.7.2.x86_64",
"php-pecl-gmagick",
"0",
"2.0.5~RC1",
"4.el8.remi.7.2",
"x86_64",
),
],
)
def test_parse_rpm_name(nevra_input, name, epoch, version, release, arch):
Expand Down