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

Documentation does not match behavior of trailing slash #671

Open
2 tasks done
ursetto opened this issue Jun 6, 2023 · 0 comments
Open
2 tasks done

Documentation does not match behavior of trailing slash #671

ursetto opened this issue Jun 6, 2023 · 0 comments
Assignees
Labels
bug Something isn't working good-first-issue
Milestone

Comments

@ursetto
Copy link

ursetto commented Jun 6, 2023

What happened?

When using file (not tree) mode, the config documentation doesn't accurately describe what the lack of a trailing slash does.

# This will add all files in some/directory or in subdirectories at the
# same level under the directory /etc. This means the tree structure in
# some/directory will not be replicated.
- src: some/directory/
dst: /etc

The doc above claims all files in subdirectories will be added at the same level (flattened) with dest: /etc. This isn't correct; it doesn't flatten the result. It duplicates the directory structure like a tree would, but it does not take ownership of these directories like a tree would (at least with RPM). It should probably be documented as such, because that behavior is very useful when avoiding ownership of system directories like /usr/bin in rpms.

In order to get the effect described above where it flattens the directory, you need to add a trailing slash, /etc/:

- src: some/directory/ 
  dst: /etc/

I'm not sure the flattening with /etc/ is useful (it apparently came about via #576) but the point is, the lack of a trailing slash with /etc is definitely useful.

In tree mode, the trailing slash seems to have no effect; the structure is always duplicated and you take ownership of all directories. So that documentation can be left alone.

Relatedly, it is not documented how to duplicate a structure (without ownership) into the root directory. For example, with the source below:

root/usr/bin/foo
root/usr/libexec/foo

If you do the following now:

- src: ./root
  dst: /

you will get a conflict as / is considered a trailing slash and both foo are flattened into /foo. This used to work before #576. The solution is to use a blank destination:

- src: ./root
  dst: ""         # or leave this blank

which will create /usr/bin/foo and /usr/libexec/foo.

On the minus side, if you try dst: "" on an older version (before #576) -- say if your users are still on an older version of nfpm --- it packages instead

usr/bin/foo
usr/libexec/foo

without a leading slash, which creates a relative path RPM that is almost never what you want. So it may not be a good idea to officially document dst: "" after all as it could lead to bad results. In this case the following, more explicit destination would be safer:

- src: ./root/usr
  dst: /usr

because it removes the ambiguity of /.

How can we reproduce this?

See above.

nfpm version

nfpm version nfpm version 2.30.0
commit: af65ba8a60cf41e2f5e197c85d086f6696556055
built at: 2023-06-05T17:45:31Z
built by: goreleaser
module version: v2.30.0, checksum: h1:lx6mVLZPBjRDUn18SLxwF+VTq4TkhYkB2WULhXrXthA=

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@ursetto ursetto added the bug Something isn't working label Jun 6, 2023
@caarlos0 caarlos0 added this to the 2.38.0 milestone May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue
Projects
None yet
Development

No branches or pull requests

2 participants