Skip to content

rpm: Refine prefix matching for sub RPMs to reduce fragility#879

Merged
aiuto merged 3 commits intobazelbuild:mainfrom
kellyma2:subrpm-prefix-match
Sep 2, 2024
Merged

rpm: Refine prefix matching for sub RPMs to reduce fragility#879
aiuto merged 3 commits intobazelbuild:mainfrom
kellyma2:subrpm-prefix-match

Conversation

@kellyma2
Copy link
Copy Markdown
Contributor

@kellyma2 kellyma2 commented Aug 1, 2024

The current prefix matching for sub RPMs can potentially fail in two ways:

  • if we have two overlapping prefixes we may match the shorter prefix against the wrong RPM
  • the shorter prefix will match repeatedly even after finding its target

This change keeps track of which sub RPMs have already match so avoid
double matching a shorter prefix. Additionally, we sort the sub RPM
list by name length in reverse order. This ensures that we prefer to
match the longest prefixes first and avoid double matching with the
same prefix.

fixes: #875

The current prefix matching for sub RPMs can potentially fail in two
ways:

- if we have two overlapping prefixes we may match the shorter prefix
  against the wrong RPM

- the shorter prefix will match repeatedly even after finding its
  target

This change keeps track of which sub RPMs have already match so avoid
double matching a shorter prefix.  Additionally, we sort the sub RPM
list by name length in reverse order.  This ensures that we prefer to
match the longest prefixes first and avoid double matching with the
same prefix.
@kellyma2 kellyma2 force-pushed the subrpm-prefix-match branch from a17bf3d to 6ff64d5 Compare August 1, 2024 20:50
@kellyma2
Copy link
Copy Markdown
Contributor Author

kellyma2 commented Aug 1, 2024

This fixes #875

@cgrindel
Copy link
Copy Markdown
Collaborator

cgrindel commented Aug 1, 2024

Can we add a test that verifies the behavior being fixed is fixed?

Copy link
Copy Markdown
Collaborator

@aiuto aiuto left a comment

Choose a reason for hiding this comment

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

Looks good, but it could use a test.

@kellyma2
Copy link
Copy Markdown
Contributor Author

Can we add a test that verifies the behavior being fixed is fixed?

Yes. I'll try to get back to that this week.

kellyma2 and others added 2 commits August 30, 2024 14:38
This change expands the basic subrpm test to account for multiple
subrpms that have matching prefixes.
@kellyma2
Copy link
Copy Markdown
Contributor Author

Looks good, but it could use a test.

Done

@cgrindel
Copy link
Copy Markdown
Collaborator

cgrindel commented Sep 1, 2024

LGTM. I will let @aiuto merge it after he has had a final look.

Copy link
Copy Markdown
Collaborator

@aiuto aiuto left a comment

Choose a reason for hiding this comment

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

Thanks

@aiuto aiuto merged commit ec08e7f into bazelbuild:main Sep 2, 2024
@kellyma2 kellyma2 deleted the subrpm-prefix-match branch September 3, 2024 17:58
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.

Multiple subrpms with common prefix lead to conflicts, errors, "output xxx was not created"

3 participants