kornelski / cargo-deb

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

Add directory permissions to assets array? #73

Open jamesadevine opened 1 year ago

jamesadevine commented 1 year ago

Hi!

I have the need to create a directory with read and write permissions as part of package set up. The directory is already created by the cargo-deb generated package as it is where the systemd unit binary (app) lives:

assets = [
    ["target/release/app", "etc/abcdef/", "755"],
    ["target/release/app-configure", "usr/bin/", "755"]
]

A separate configuration binary (app-configure) allows users to configure app and the configuration files reside in /etc/abcdef. Because the default permissions of /etc/abcdef are set to read only, I need to modify the directory permissions so that app-configure can write files to /etc/abcdef.

I've read that there are two ways this can be achieved:

  1. override_dh_fixperms/execute_after_dh_fixperms followed by chmod <perms> <some directory>
  2. Adding a step to the postinst script with chmod <perms> <some directory>

I've opted for (2), with this postinst script:

#DEBHELPER#
chmod 0777 /etc/abcdef

I have two questions:

  1. Is (2) the best approach with cargo-deb?
  2. Would a nicer interface be to allow directories to be specified in the assets array?
rajnishkumarX commented 1 year ago

Allowing to set permissions for the directories as well as adding empty directories like /var/lib/app is a need indeed. Right now, I'm looking for a hacky way to achieve this.

kornelski commented 1 year ago

I know it would be useful, but as far as I can tell, the deb format doesn't support this.

People use postinst script for this, and I'm not sure if cargo-deb should be generating bash scripts automatically. What if the package already has a postinst script?