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

Add warning for missing maintainer scripts files #70

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'l, W: Write> ControlArchiveBuilder<'l, W> {
/// should be inserted.
fn generate_scripts(&mut self, option: &Config) -> CDResult<()> {
if let Some(ref maintainer_scripts_dir) = option.maintainer_scripts {
let maintainer_scripts_dir = option.package_manifest_dir.as_path().join(maintainer_scripts_dir);
let maintainer_scripts_dir = option.package_manifest_dir.as_path().join(maintainer_scripts_dir).canonicalize()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When maintainer_scripts is set to a directory that does not exist this line caused the following output for me:

cargo-deb: I/O error: No such file or directory (os error 2)
  because: No such file or directory (os error 2)

I had no idea which part of the code was throwing it or which directory it was looking for.

let mut scripts = ScriptFragments::with_capacity(0);

if let Some(systemd_units_config_vec) = &option.systemd_units {
Expand Down Expand Up @@ -101,6 +101,8 @@ impl<'l, W: Write> ControlArchiveBuilder<'l, W> {
let script_path = maintainer_scripts_dir.join(name);
if is_path_file(&script_path) {
script = Some(read_file_to_bytes(&script_path)?);
} else {
self.listener.warning(format!("maintainer script '{name}' was not found at location {maintainer_scripts_dir:?}, generating defaults instead."));
}
}

Expand Down