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

feat: add support for datadir in rpm spec #308

Conversation

pmengelbert
Copy link
Contributor

What this PR does / why we need it:

Users have requested the ability to put read-only architecture-independent data files under /usr/share.

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):
Related #242 (does not completely resolve)

Special notes for your reviewer:

@pmengelbert pmengelbert requested a review from a team as a code owner July 3, 2024 16:07
"bin": {},
},
DataFiles: map[string]dalec.ArtifactConfig{
"data_dir": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be good to add a test with a subpath in the artifact config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks!

Copy link
Contributor

@adamperlin adamperlin left a comment

Choose a reason for hiding this comment

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

I think this looks fine to me. One thing to consider is, it likely would not be good practice to install directly under %{_datadir} as in %{_datadir}/my_file.data, I believe there should pretty much always be at least one directory level of nesting to specify the package the data applies to. That being said, I'm not sure here is the place to validate that necessarily.

@cpuguy83
Copy link
Member

cpuguy83 commented Jul 3, 2024

@adamperlin Agreed I was going to comment the same thing but yeah I don't think there's really anything we can do here other than provide guidance that it should be namespaced.

Looks like you need to go generate ./...

@pmengelbert
Copy link
Contributor Author

pmengelbert commented Jul 3, 2024

@adamperlin Agreed I was going to comment the same thing but yeah I don't think there's really anything we can do here other than provide guidance that it should be namespaced.

Looks like you need to go generate ./...

@cpuguy83 @adamperlin
We could require a subpath for this artifact type and drop the parent directory if the DataFile in question is a Directory. Happy to change it to that if y'all think it would be better.

Example:

# layout of /build src directory:
# /build/src/
#  L my_data_dir/
#   L my_data_file

# ...

artifacts:
  data_dirs:
    my_data_dir:
      subpath: my_namespace

# layout of /usr/share in final container:
# /usr/share/
#  L my_namespace/
#    L my_data_file
  • Should also rename DataFile to DataDir.

Also, add an integration test harness for development.

Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
@pmengelbert pmengelbert force-pushed the pmengelbert/add_support_for_datadir_in_rpm_spec/1 branch from ff9e497 to d8816d7 Compare July 3, 2024 18:06
@pmengelbert
Copy link
Contributor Author

After discussion with @cpuguy83, we decided to allow placing files directly under /usr/share, since the RPM build process allows it.

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

This can also use a squash.

spec.go Outdated
@@ -128,6 +128,8 @@ type Artifacts struct {
Binaries map[string]ArtifactConfig `yaml:"binaries,omitempty" json:"binaries,omitempty"`
// Manpages is the list of manpages to include in the package.
Manpages map[string]ArtifactConfig `yaml:"manpages,omitempty" json:"manpages,omitempty"`
// DataDirs is a list of read-only architecture-independent data files, to be placed in /usr/share/
DataDirs map[string]ArtifactConfig `yaml:"data_files,omitempty" json:"data_files,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Nit we have DataDirs as the field and data_files as the yaml.
Can we coalesce this?

Copy link
Contributor Author

@pmengelbert pmengelbert Jul 3, 2024

Choose a reason for hiding this comment

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

done, will merge when tests pass

Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
@pmengelbert pmengelbert force-pushed the pmengelbert/add_support_for_datadir_in_rpm_spec/1 branch from 2084544 to 0c26660 Compare July 3, 2024 18:57
@cpuguy83 cpuguy83 enabled auto-merge (squash) July 3, 2024 19:08
@cpuguy83 cpuguy83 merged commit 4b09d96 into Azure:main Jul 3, 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.

3 participants