Skip to content

Support Gentoo package slot syntax and wildcard versions - #217

Open
Adnan9-63 wants to merge 1 commit into
aboutcode-org:mainfrom
Adnan9-63:fix/gentoo-slots-and-wildcards
Open

Adnan9-63 wants to merge 1 commit into
aboutcode-org:mainfrom
Adnan9-63:fix/gentoo-slots-and-wildcards

Conversation

@Adnan9-63

Copy link
Copy Markdown

What this PR does / why we need it:

Adds support for Gentoo ebuild versions containing package slot syntax (:3, :6, :0/2.4, :3=) and wildcard suffixes (1.3*, 7.3*, 7.4*).

Previously, versions such as 1.3* and 3.24.48:3 raised an InvalidVersion exception in downstream tools (such as VulnerableCode's GentooImporter when parsing GLSA advisories):

InvalidVersion constraints version: 1.3* error:'1.3*' is not a valid <class 'univers.versions.GentooVersion'>

Changes:

  1. Slot & Wildcard Parsing (src/univers/gentoo.py):
    • Added regex and parse_parts() helper to extract package slot qualifiers and wildcard suffixes.
    • Updated parse_version_and_revision() to strip slot and wildcard tokens so Portage PMS Section 3.3 vercmp evaluates without crashes.
    • Updated is_valid() to accept valid slotted and wildcard ebuild versions while rejecting invalid tokens (*, 1.3**, :3, 3.24.48:invalid!slot).
  2. Properties on GentooVersion (src/univers/versions.py):
    • Added .slot property returning the slot string (or None).
    • Added .is_wildcard boolean property indicating if the version contains a trailing wildcard.
      (Note: Kept comparison operators strictly focused on </>/== to avoid overlap with open PR Implement __le__ and __ge__ for GentooVersion #211).
  3. Comprehensive Tests (tests/test_gentoo.py):
    • Verified parsing and validity for reported issue versions (1.3*, 3.24.48:3, 6.9.3:6, 7.3*, 7.4*).
    • Added round-trip serialization tests with VersionConstraint and EbuildVersionRange (vers:ebuild/1.3*|>3.24.47:3).

Fixes #182

Checklist:

  • Unit tests added/updated (pytest tests/test_gentoo.py tests/test_gentoo_pkgcore.py)
  • Code style checked with black -l 100
  • Commit is signed off (git commit -s)

Copilot AI balanced review requested due to automatic review settings November 4, 2026 22:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A moderate active issue remains in src/univers/gentoo.py because the parser accepts a bare trailing colon as an empty slot, violating the requirement that slot qualifiers be non-empty.

1 open issue

Review effort: Lite

Comment thread src/univers/gentoo.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The change still has a critical active issue because stripping the Gentoo wildcard causes valid matching patch versions such as 1.3.1 to be rejected.

1 open issue
1 resolved since last review

Review effort: Lite

Comment thread src/univers/gentoo.py Resolved
Adds support for parsing and validating Gentoo ebuild versions with package
slots (e.g., 3.24.48:3, 6.9.3:6, 2.4.52:0/2.4) and wildcard suffixes
(e.g., 1.3*, 7.3*).

Extracts package slot qualifiers and wildcard markers while preserving
standard PMS (Package Manager Specification Section 3.3) vercmp ordering.
Also exposes .slot and .is_wildcard properties on GentooVersion, and
implements component-prefix wildcard matching per PMS Section 8.2.

Closes aboutcode-org#182

Assisted-by: Antigravity
Signed-off-by: Adnan9-63 <muhammad1414114@gmail.com>
@Adnan9-63
Adnan9-63 force-pushed the fix/gentoo-slots-and-wildcards branch from 505ebbd to 77a7cda Compare November 12, 2026 08:57

This branch has not been deployed

No deployments
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.

Unsupported gentoo versions

2 participants