kornelski / cargo-deb

Make Debian packages directly from Rust/Cargo projects
https://lib.rs/cargo-deb
MIT License
408 stars 48 forks source link

Create empty dirs in package #40

Closed Flowneee closed 1 year ago

Flowneee commented 2 years ago

Hi.

I am trying to create an empty folder in my package (my case - prepare folders for logs, something like /var/log/), but I didn't found any way to do that rather than in postinst, but this approach have a problem - package doesn't own folder and won't remove them on uninstall. And there is no way to modify rules to run https://man7.org/linux/man-pages/man1/dh_installdirs.1.html.

In RPM:

%install
mkdir -p %{buildroot}/var/log/service

%files
%dir %attr(755, user, group) /var/log/service-name/

I think it should be cool to have some way to hack rules, however right now I can't imagine how it might look.

kornelski commented 2 years ago

Can you use the same trick as for git and put an empty useless file in the directory?

Flowneee commented 2 years ago

This could be a solution, but not good IMO. I think people could find other usage for this feature.

If I come up with PR, will you consider it or you against hacking rules at all? If latter, I'll close this issue.

kornelski commented 2 years ago

How do other packages do it?

I'd rather not add a "hacky" solution, but something that's accepted as standard in Debian and Ubuntu.

WGH- commented 1 year ago

For systemd-based distros, you should probably use directives like LogsDirectory= in a unit, or, in more complex cases, install a file describing wanted directories into /usr/lib/tmpfiles.d.

EDIT: that won't solve directory deletion on uninstall, but neither apt-get remove nor apt-get purge deletes logs for any existing package I can think of.

Flowneee commented 1 year ago

I'm gonna close this issue since I didn't come up to non-hacky way and it was quite some time. We actually did what @WGH- recommended - just don't delete existing logs, this is actually correct I think, so thanks for recommendation. Also systemd-based solutions is worth the shot, although we didn't try it yet.

I still think that alternating rules could be useful, but at this time I don't have an actual case to demonstrate that necessity)