kornelski / cargo-deb

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

Add warning for missing maintainer scripts files #70

Open ltabis opened 1 year ago

ltabis commented 1 year ago

Regarding #69

When the maintainer-scripts field is set and a script is not found, cargo deb will emit a warning telling the user that it will supply the script itself.

This generates the following logs for the vsmtp project: (which provides postinst, postrm and prerm)

info: Determining augmentations needed for systemd unit vsmtp.service
info: Maintainer script postinst will be augmented with autoscript postinst-systemd-enable
info: Maintainer script postrm will be augmented with autoscript postrm-systemd
info: Maintainer script postinst will be augmented with autoscript postinst-systemd-restartnostart
info: Maintainer script prerm will be augmented with autoscript prerm-systemd-restart
info: Maintainer script postrm will be augmented with autoscript postrm-systemd-reload-only
info: Augmenting maintainer script /vSMTP/tools/install/deb/postinst
info: Augmenting maintainer script /vSMTP/tools/install/deb/prerm
info: Augmenting maintainer script /vSMTP/tools/install/deb/postrm
+warning: maintainer script config was not found at location "/vSMTP/tools/install/deb", generating defaults instead.
+warning: maintainer script preinst was not found at location "/vSMTP/tools/install/deb", generating defaults instead.
+warning: maintainer script templates was not found at location "/vSMTP/tools/install/deb", generating defaults instead.

I failed to run the test suite on the following tests because there is a missing test-resources/testroot/testchild/debian directory.

control::tests::generate_scripts_archives_user_supplied_maintainer_scripts_in_root_package
control::tests::generate_scripts_archives_user_supplied_maintainer_scripts_in_workspace_package
control::tests::generate_scripts_augments_maintainer_scripts_for_unit_in_root_package
control::tests::generate_scripts_augments_maintainer_scripts_for_unit_in_workspace_package
control::tests::generate_scripts_generates_missing_maintainer_scripts_for_unit_in_root_package
control::tests::generate_scripts_generates_missing_maintainer_scripts_for_unit_in_workspace_package

How can I get it ?

kornelski commented 1 year ago

The tests are they way they are. If they don't run out of the box, figure out whether that's an incompatible change or wrong tests.

ximon18 commented 1 year ago

I think that the warning isn't strictly correct because it doesn't generate a default script in the absence of a particular script, this isn't even a reason to warn is it? I can imagine it being useful to warn if zero scripts were found, rather than just some. (update: What I was trying to say is that scripts are not required to exist, it is valid to provide only some rather than all possible scripts)

When I wrote the systemd unit maintainer script fragment injection stuff at the time cargo-deb had no concept of debug logging, but I wanted and still think there would be value in adding "debug" level logging to show where the logic is looking for and failing to find files, to help with the case that it doesn't do as you expect.

janrueth commented 1 year ago

Just wanted to encourage to make this a hard failure instead of a warning.

After https://github.com/kornelski/cargo-deb/pull/11 was merged and our tooling picked those changes up (which seems to have taken some time :)) we discovered that the maintainer scripts were not included anymore as we were still specifying paths relative to the workspace.

I think cargo-deb should not only emit a warning but an error and stop processing when this happens (of course explaining nicely what the problem is :)). I'm not sure we would have noticed a warning among the tons of output from CI.