Skip to content
Merged
Show file tree
Hide file tree
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
52 changes: 26 additions & 26 deletions src/commands/stone/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ pub fn create_command(
log_info(&format!("Processing storage device '{device_name}'."));

// Copy fwup template file if device has fwup build args
if let Some(build_args) = &device.build_args {
if let Some(template) = build_args.fwup_template() {
let input_path = input_dir.join(template);
let output_path = output_dir.join(template);
if let Err(e) = copy_file(&input_path, &output_path, verbose) {
errors.push(format!(
"Failed to copy fwup template '{template}' for device '{device_name}': {e}"
));
}
if let Some(build_args) = &device.build_args
&& let Some(template) = build_args.fwup_template()
{
let input_path = input_dir.join(template);
let output_path = output_dir.join(template);
if let Err(e) = copy_file(&input_path, &output_path, verbose) {
errors.push(format!(
"Failed to copy fwup template '{template}' for device '{device_name}': {e}"
));
}
}

Expand Down Expand Up @@ -192,15 +192,15 @@ fn process_image(
log_info(&format!("Processing image '{image_name}'."));

// Copy fwup template file if image has fwup build args
if let Some(build_args) = image.build_args() {
if let Some(template) = build_args.fwup_template() {
let input_path = input_dir.join(template);
let output_path = output_dir.join(template);
if let Err(e) = copy_file(&input_path, &output_path, verbose) {
return Err(format!(
"Failed to copy fwup template '{template}' for image '{image_name}': {e}"
));
}
if let Some(build_args) = image.build_args()
&& let Some(template) = build_args.fwup_template()
{
let input_path = input_dir.join(template);
let output_path = output_dir.join(template);
if let Err(e) = copy_file(&input_path, &output_path, verbose) {
return Err(format!(
"Failed to copy fwup template '{template}' for image '{image_name}': {e}"
));
}
}

Expand Down Expand Up @@ -259,14 +259,14 @@ fn copy_file(input_path: &Path, output_path: &Path, verbose: bool) -> Result<(),
}

// Create output directory if it doesn't exist
if let Some(parent) = output_path.parent() {
if let Err(e) = fs::create_dir_all(parent) {
return Err(format!(
"Failed to create output directory '{}': {}",
parent.display(),
e
));
}
if let Some(parent) = output_path.parent()
&& let Err(e) = fs::create_dir_all(parent)
{
return Err(format!(
"Failed to create output directory '{}': {}",
parent.display(),
e
));
}

// Copy the file
Expand Down
22 changes: 11 additions & 11 deletions src/commands/stone/provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,17 +658,17 @@ fn execute_provision_with_profile(
verbose: bool,
) -> Result<(), String> {
// First check for legacy provision script in runtime
if let Some(provision_file) = &manifest.runtime.provision {
if manifest.provision.is_none() {
log_info("Using legacy provision script from runtime.provision.");
return execute_provision_script(
provision_file,
input_dir,
build_dir,
verbose,
&HashMap::new(),
);
}
if let Some(provision_file) = &manifest.runtime.provision
&& manifest.provision.is_none()
{
log_info("Using legacy provision script from runtime.provision.");
return execute_provision_script(
provision_file,
input_dir,
build_dir,
verbose,
&HashMap::new(),
);
}

// If no provision configuration exists, skip provision execution
Expand Down
57 changes: 27 additions & 30 deletions src/commands/stone/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,18 @@ pub fn validate_command(manifest_path: &Path, input_dir: &Path) -> Result<(), St
}

// Check if provision_default references a valid profile
if let Some(default_profile_name) = &manifest.runtime.provision_default {
if manifest
if let Some(default_profile_name) = &manifest.runtime.provision_default
&& manifest
.get_provision_profile(default_profile_name)
.is_none()
{
missing_provision_files.push((
"Default profile reference".to_string(),
format!("Profile '{default_profile_name}' not found in provision.profiles"),
));
}
// Note: We don't check if the default profile's script exists here
// because that will already be caught when validating all profiles above
{
missing_provision_files.push((
"Default profile reference".to_string(),
format!("Profile '{default_profile_name}' not found in provision.profiles"),
));
}
// Note: We don't check if the default profile's script exists here
// because that will already be caught when validating all profiles above
} else if manifest.runtime.provision_default.is_some() {
missing_provision_files.push((
"Default profile reference".to_string(),
Expand All @@ -93,12 +92,12 @@ pub fn validate_command(manifest_path: &Path, input_dir: &Path) -> Result<(), St
// Process each storage device
for (device_name, device) in &manifest.storage_devices {
// Check fwup template file if device has fwup build args
if let Some(build_args) = &device.build_args {
if let Some(template) = build_args.fwup_template() {
let template_path = input_dir.join(template);
if !template_path.exists() {
missing_device_files.push((device_name.clone(), template.to_string()));
}
if let Some(build_args) = &device.build_args
&& let Some(template) = build_args.fwup_template()
{
let template_path = input_dir.join(template);
if !template_path.exists() {
missing_device_files.push((device_name.clone(), template.to_string()));
}
}

Expand All @@ -114,20 +113,18 @@ pub fn validate_command(manifest_path: &Path, input_dir: &Path) -> Result<(), St
}

// For fwup builds, check if template file exists
if let Some(build_type) = image.build() {
if build_type == "fwup" {
if let Some(build_args) = image.build_args() {
if let Some(template) = build_args.fwup_template() {
let template_path = input_dir.join(template);
if !template_path.exists() {
missing_files.push((
device_name.clone(),
image_name.clone(),
template.to_string(),
));
}
}
}
if let Some(build_type) = image.build()
&& build_type == "fwup"
&& let Some(build_args) = image.build_args()
&& let Some(template) = build_args.fwup_template()
{
let template_path = input_dir.join(template);
if !template_path.exists() {
missing_files.push((
device_name.clone(),
image_name.clone(),
template.to_string(),
));
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/fwup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ pub fn create_firmware_package(options: &FwupOptions) -> Result<(), String> {
}

// Create output directory if it doesn't exist
if let Some(parent) = options.output_file.parent() {
if let Err(e) = std::fs::create_dir_all(parent) {
return Err(format!(
"Failed to create output directory '{}': {}",
parent.display(),
e
));
}
if let Some(parent) = options.output_file.parent()
&& let Err(e) = std::fs::create_dir_all(parent)
{
return Err(format!(
"Failed to create output directory '{}': {}",
parent.display(),
e
));
}

// Build the fwup command
Expand Down