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

Add handling for docs files and license files #256

Merged
merged 5 commits into from
May 17, 2024

Conversation

jeremyrickard
Copy link
Contributor

@jeremyrickard jeremyrickard commented May 17, 2024

What this PR does / why we need it:

This PR adds the ability to add files to the package and have them represented by the %doc directive or the %license directive within the %files list.

There isn't a corresponding install entry, because RPM handles this already:

When the package is installed, RPM creates a directory in the documentation directory named the same as the package and copies the file there

The same happens with license files.

I thought that a slice of strings made more sense than using ArtifactConfig here, since we don't really need to provide any other real options. It seems like you can specify a full path with the %doc directive (%license as well), but I think we can go with this for now? It feels cleaner/more organized.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
fixes #241

Special notes for your reviewer:

Signed-off-by: Jeremy Rickard <jrickard@microsoft.com>
Signed-off-by: Jeremy Rickard <jrickard@microsoft.com>
@jeremyrickard jeremyrickard changed the title Add handling for docs files Add handling for docs files and license files May 17, 2024
spec.go Show resolved Hide resolved
Signed-off-by: Jeremy Rickard <jrickard@microsoft.com>
spec.go Outdated
@@ -131,6 +131,10 @@ type Artifacts struct {
Directories *CreateArtifactDirectories `yaml:"createDirectories,omitempty" json:"createDirectories,omitempty"`
// ConfigFiles is a list of files that should be marked as config files in the package.
ConfigFiles map[string]ArtifactConfig `yaml:"configFiles,omitempty" json:"configFiles,omitempty"`
// DocFiles is a list of doc files included in the package
DocFiles []string `yaml:"docFiles,omitempty" json:"docFiles,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

The reason I like to make these structs is so that it is not a breaking change to add additional options.
I also think subdir is a thing relavent for these files (and licenses).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it to work. I needed to handle the copy myself for the subpaths and emit the full path inside the %files section.

spec.go Outdated
@@ -131,6 +131,10 @@ type Artifacts struct {
Directories *CreateArtifactDirectories `yaml:"createDirectories,omitempty" json:"createDirectories,omitempty"`
// ConfigFiles is a list of files that should be marked as config files in the package.
ConfigFiles map[string]ArtifactConfig `yaml:"configFiles,omitempty" json:"configFiles,omitempty"`
// DocFiles is a list of doc files included in the package
DocFiles []string `yaml:"docFiles,omitempty" json:"docFiles,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Also can we name these docs and licenses in the yaml/json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I updated. I also changed the struct fields to Docs and Licenses, that seemed like better naming to me.

Signed-off-by: Jeremy Rickard <jrickard@microsoft.com>
spec.go Outdated
@@ -131,6 +131,10 @@ type Artifacts struct {
Directories *CreateArtifactDirectories `yaml:"createDirectories,omitempty" json:"createDirectories,omitempty"`
// ConfigFiles is a list of files that should be marked as config files in the package.
ConfigFiles map[string]ArtifactConfig `yaml:"configFiles,omitempty" json:"configFiles,omitempty"`
// DocFiles is a list of doc files included in the package
Copy link
Member

Choose a reason for hiding this comment

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

These doc strings are not correct anymore 🙈

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// DocFiles is a list of doc files included in the package
// Docs is a list of doc files included in the package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL sorry

spec.go Outdated
@@ -131,6 +131,10 @@ type Artifacts struct {
Directories *CreateArtifactDirectories `yaml:"createDirectories,omitempty" json:"createDirectories,omitempty"`
// ConfigFiles is a list of files that should be marked as config files in the package.
ConfigFiles map[string]ArtifactConfig `yaml:"configFiles,omitempty" json:"configFiles,omitempty"`
// DocFiles is a list of doc files included in the package
Docs map[string]ArtifactConfig `yaml:"docs,omitempty" json:"docs,omitempty"`
// LicenseFiles is a list of doc files included in the package
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// LicenseFiles is a list of doc files included in the package
// Licenses is a list of doc files included in the package

Signed-off-by: Jeremy Rickard <jrickard@microsoft.com>
@cpuguy83 cpuguy83 merged commit 6673acd into Azure:main May 17, 2024
9 checks passed
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.

[REQ] Support providing doc and license files for the resulting RPM spec
3 participants