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

boulder: Fix pattern matching #402

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

boulder: Fix pattern matching #402

wants to merge 1 commit into from

Conversation

ReillyBrogan
Copy link
Contributor

@ReillyBrogan ReillyBrogan commented Jan 9, 2025

Boulder had a needless check for starts_with which was causing erroneous package splitting in several cases. For instance, consider the following simplified patterns:

- llvm-libs:
  paths:
    - /usr/lib/libLLVM.so.*

- llvm-devel:
  paths:
    - /usr/lib/libLLVM.so

With this setup the file /usr/lib/libLLVM.so.18.1 should be patterned into llvm-libs, however since the starts_with match was checked first it would end up in llvm-devel. The point of this was to ensure that we could have "globs" that matched directories that matched subfiles/subdirectories and in order to preserve that behavior we instead match twice, once on the submitted pattern and again with /** appended to get a recursive glob.

Also while we're at it apply a minor adjustment to escape the directory so that all glob patterns work correctly.

@ReillyBrogan ReillyBrogan marked this pull request as draft January 9, 2025 22:56
@ReillyBrogan
Copy link
Contributor Author

Found another bug, figuring it out

@ikeycode
Copy link
Member

ikeycode commented Jan 9, 2025

are you sure..? check the manifest, the splitting appears fine, I had to fix some wild globs in it a while back

Boulder had a needless check for `starts_with` which was causing erroneous package splitting in several cases. For instance, consider the following simplified patterns:

```
- llvm-libs:
  paths:
    - /usr/lib/libLLVM.so.*

- llvm-devel:
  paths:
    - /usr/lib/libLLVM.so
```

With this setup the file `/usr/lib/libLLVM.so.18.1` should be patterned into `llvm-libs`, however since the `starts_with` match was checked first it would end up in `llvm-devel`. The point of this was to ensure that we could have "globs" that matched directories that matched subfiles/subdirectories and in order to preserve that behavior we instead match twice, once on the submitted pattern and again with `/**` appended to get a recursive glob.

Also while we're at it apply a minor adjustment to escape the directory so that all glob patterns work correctly.

Signed-off-by: Reilly Brogan <[email protected]>
@ermo
Copy link
Member

ermo commented Jan 15, 2025

@ikeycode From an engineering-led perspective, perhaps the smart thing to do here would be to set up a test suite for the pattern matching code, and having said test suite become the "specification" in a sense?

Would make the discussion very simple in that it'd simply be: "Well, what do the tests show?"

If you agree, I could put up an issue and then we could work on getting that part up to snuff with suitable test patterns in a separate PR?

@ikeycode
Copy link
Member

Yeah we do need to extend tests

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.

3 participants