Skip to content

Conversation

@rebornplusplus
Copy link

@rebornplusplus rebornplusplus commented Feb 8, 2024

This PR adds support for package names with a minimum length of two. Previously chisel only supported a minimum length of 3. The limit on the slice name is kept unchanged.

Fixes #119.

@rebornplusplus rebornplusplus changed the title fix: package names can be of length two feat: package names can be of length two Feb 8, 2024
@rebornplusplus rebornplusplus force-pushed the fix/package-name-length branch from a195268 to 0701528 Compare February 8, 2024 09:29
This commit adds support for package names with a minimum length of two.
Previously chisel only supported a minimum length of 3. The limit on the
slice name is kept unchanged.

Fixes canonical#119.
@cjdcordeiro cjdcordeiro added the Simple Nice for a quick look on a minute or two label Feb 8, 2024
Copy link
Collaborator

@letFunny letFunny left a comment

Choose a reason for hiding this comment

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

Can you link the naming requirements for debian packages if you have them? I want to see them to check the tests + regexp.

@letFunny
Copy link
Collaborator

letFunny commented Feb 8, 2024

If this is the correct definition (copied from the issue):

Package names (both source and binary, see Package) must consist only of lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.). They must be at least two characters long and must start with an alphanumeric character.

Then "a-", "a+" and "a." are valid names not captured by the regexp.

@rebornplusplus
Copy link
Author

If this is the correct definition (copied from the issue):

Package names (both source and binary, see Package) must consist only of lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.). They must be at least two characters long and must start with an alphanumeric character.

Then "a-", "a+" and "a." are valid names not captured by the regexp.

I only have that reference for now. I am planning to go through the Debian Policy Manual again, today. But yes, based on the definition above, you should be right. But I am not sure if a-, a+, or a. are permitted or not.

@rebornplusplus
Copy link
Author

rebornplusplus commented Feb 14, 2024

So yeah, the current regex does support package names like foo+ and foo. (a+ and a. now too). But it does not support foo- (or a-).

There are packages like foo+ though:

$ grep "^Package:\s.*+$" Packages 
Package: bonnie++
Package: g++
Package: libdb5.3++
Package: memtest86+

I didn't find occurrences like foo- and foo. yet. Let me know if you spot them!

Add pkg and slice name expression string variables to remove duplication
and increase test coverage.
@rebornplusplus rebornplusplus changed the title feat: package names can be of length two fix: package names can be of length two Feb 14, 2024
@lwnexgen
Copy link

lwnexgen commented Mar 6, 2024

It would be nice if this could be merged soon :) I have some weird hacks to get a static jq copied into the chiseled image.

@rebornplusplus rebornplusplus requested a review from niemeyer March 8, 2024 01:00
Copy link
Collaborator

@letFunny letFunny left a comment

Choose a reason for hiding this comment

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

I still think some way of tying the three regexps together would be nice (#120 (comment)) but let's keep it simple for this bugfix.


var fnameExp = regexp.MustCompile(`^([a-z0-9](?:-?[.a-z0-9+]){2,})\.yaml$`)
// fnameExp matches the slice definition file basename.
var fnameExp = regexp.MustCompile(`^([a-z0-9](?:-?[.a-z0-9+]){1,})\.yaml$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for missing this earlier, but why do we have a dot (.) in that second group? That doesn't look right.

Same question below.

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Let's actually go ahead with this for now. Alberto just pointed out that this is part of the package rules, and this is already in the code, so arguably an independent issue.

Let's please follow up on it, though, and agree on the path forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Simple Nice for a quick look on a minute or two

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support package names shorter than 3 characters

5 participants