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

Allow creating empty directories in RPMs #676

Closed
nhinds opened this issue May 16, 2018 · 5 comments · Fixed by #677
Closed

Allow creating empty directories in RPMs #676

nhinds opened this issue May 16, 2018 · 5 comments · Fixed by #677
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@nhinds
Copy link

nhinds commented May 16, 2018

Is your feature request related to a problem? Please describe.
I'm trying to build multiple RPMs which share a log and lib directory. These directories are initially empty.

With raw .spec files, this can be accomplished by something like this in each of the RPMs:

%install
mkdir -vp $RPM_BUILD_ROOT/var/log/myapp
mkdir -vp $RPM_BUILD_ROOT/var/lib/myapp

...
%files
/var/lib/myapp
/var/log/myapp

When either RPM is installed the directories are created, and the directories continue to exist until both RPMs are uninstalled.

Describe the solution you'd like
I would like an option in the nfpm section of .goreleaser.yaml for creating empty directories as part of the RPM.

This could perhaps be a parameter specifying a list of directories to create:

nfpm:
  ...
  files:
    build/something.init: /etc/init.d/something
  directories:
  - /var/lib/myapp
  - /var/log/myapp

...or by enhancing the existing files section to allow empty directories to be specified:

nfpm:
  ...
  files:
    build/something.init: /etc/init.d/something
    build/empty-dir-for-var-log: /var/log/myapp
    build/empty-dir-for-var-lib: /var/lib/myapp

Describe alternatives you've considered
I have attempted to create the empty directory by creating empty directories locally and specifying them in the nfpm files: ... directive. However, it seems like nfpm does not add directories to the .tar.gz if they have no files in them so the directories are not created under BUILDROOT and the build fails during RPM creation:

Processing files: myapp-0.0.0-1.x86_64
error: File not found: /tmp/myapp774619009/BUILDROOT/myapp-0.0.0-1.x86_64/var/lib/myapp
error: File not found: /tmp/myapp774619009/BUILDROOT/myapp-0.0.0-1.x86_64/var/log/myapp

I have attempted to create the empty directories as part of the RPM's postinstall script. However this does not result in the directory being managed by the RPM, so if the other existing RPM which also manages the directory is uninstalled, the /var/lib/myapp / /var/log/myapp directories are removed with it, breaking the RPM created from goreleaser. For now this is probably the workaround I'm going to use, along with a message asking users nicely to not uninstall the other RPM.

Additional context
Using goreleaser v0.73.2

@caarlos0
Copy link
Member

hi @nhinds

thanks for opening the issue!

as a workaround, have you tried adding a placeholder file in the folder and adding it using the files directive (for example, a .keep empty file or something like that)?

I think it could work while we don't fix this properly...

@caarlos0 caarlos0 added the bug Something isn't working label May 16, 2018
@caarlos0 caarlos0 added this to the v1.0.0 milestone May 16, 2018
@nhinds
Copy link
Author

nhinds commented May 16, 2018

Yes - that creates the folder and ensures it's managed by the RPM, but it creates the file on the destination system's filesystem. I suspect that each RPM would have to use a file with a different name to ensure they don't conflict, and I'd like to avoid creating these dummy files on the systems the RPM is installed on if possible

@caarlos0
Copy link
Member

either way, will try to fix this

@caarlos0
Copy link
Member

hey @nhinds, can you check goreleaser/nfpm#34 ?

@caarlos0 caarlos0 self-assigned this May 17, 2018
@caarlos0 caarlos0 added enhancement New feature or request and removed bug Something isn't working labels May 17, 2018
@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants