Skip to content

Commit

Permalink
implement --prepare-only flag on rust-installer generator
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Dec 10, 2023
1 parent f536185 commit 9829b76
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/tools/rust-installer/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ actor! {
/// The formats used to compress the tarball
#[arg(value_name = "FORMAT", default_value_t)]
compression_formats: CompressionFormats,

/// Indicate whether to leave the prepared directories without generating tarballs
prepare_only: bool,
}
}

Expand Down Expand Up @@ -105,17 +108,19 @@ impl Generator {
.output_script(path_to_str(&output_script)?.into());
scripter.run()?;

// Make the tarballs
create_dir_all(&self.output_dir)?;
let output = Path::new(&self.output_dir).join(&self.package_name);
let mut tarballer = Tarballer::default();
tarballer
.work_dir(self.work_dir)
.input(self.package_name)
.output(path_to_str(&output)?.into())
.compression_profile(self.compression_profile)
.compression_formats(self.compression_formats);
tarballer.run()?;
if !self.prepare_only {
// Make the tarballs
create_dir_all(&self.output_dir)?;
let output = Path::new(&self.output_dir).join(&self.package_name);
let mut tarballer = Tarballer::default();
tarballer
.work_dir(self.work_dir)
.input(self.package_name)
.output(path_to_str(&output)?.into())
.compression_profile(self.compression_profile)
.compression_formats(self.compression_formats);
tarballer.run()?;
}

Ok(())
}
Expand Down

0 comments on commit 9829b76

Please sign in to comment.