|
|
@@ -122,17 +122,23 @@ pub fn tick_async_script(st: &mut StationState) {
|
|
|
|| lower_out.contains("is not a directory");
|
|
|
let has_dir_listing =
|
|
|
lower_out.contains("directory of:") || lower_out.contains("file(s)");
|
|
|
- let found_118 = !not_found
|
|
|
+ let target_base = st
|
|
|
+ .async_script
|
|
|
+ .extra_meta
|
|
|
+ .get_str("probe_efi_basename")
|
|
|
+ .unwrap_or("118.efi")
|
|
|
+ .to_ascii_lowercase();
|
|
|
+ let found_efi = !not_found
|
|
|
&& has_dir_listing
|
|
|
&& out_str.lines().any(|ln| {
|
|
|
let t = ln.trim().to_ascii_lowercase();
|
|
|
let after_prompt = t.rsplit_once('>').map(|(_, r)| r.trim()).unwrap_or(t.as_str());
|
|
|
!t.starts_with("ls ")
|
|
|
&& !after_prompt.starts_with("ls ")
|
|
|
- && t.contains("118.efi")
|
|
|
- && (t.ends_with("118.efi") || t.contains(" 118.efi"))
|
|
|
+ && t.contains(&target_base)
|
|
|
+ && (t.ends_with(&target_base) || t.contains(&format!(" {}", target_base)))
|
|
|
});
|
|
|
- if found_118 {
|
|
|
+ if found_efi {
|
|
|
if let Some(cand) = st.async_script.step_sent_line.strip_prefix("ls ") {
|
|
|
let mut resolved = cand.trim().to_string();
|
|
|
if let Some(colon) = resolved.find(':') {
|
|
|
@@ -251,7 +257,7 @@ pub fn tick_async_script(st: &mut StationState) {
|
|
|
"responses",
|
|
|
JsonVal::Arr(st.async_script.collected_responses.clone()),
|
|
|
);
|
|
|
- fail_res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ fail_res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
st.last_uip_apply = Some(fail_res);
|
|
|
}
|
|
|
if let Some(tx) = st.async_script.completion_tx.take() {
|
|
|
@@ -361,7 +367,7 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
"unsupported_commands",
|
|
|
JsonVal::Arr(st.unsupported_commands.clone()),
|
|
|
);
|
|
|
- uip_res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ uip_res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
st.last_uip_apply = Some(uip_res);
|
|
|
}
|
|
|
|
|
|
@@ -382,7 +388,7 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
"unsupported_commands",
|
|
|
JsonVal::Arr(st.unsupported_commands.clone()),
|
|
|
);
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
st.last_uip_apply = Some(res.clone());
|
|
|
}
|
|
|
"interactive_continue_uip" => {
|
|
|
@@ -393,7 +399,7 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
JsonVal::Arr(lines.into_iter().map(JsonVal::Str).collect()),
|
|
|
);
|
|
|
res.set("responses", JsonVal::Arr(responses));
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
st.last_phase_action = Some(res.clone());
|
|
|
}
|
|
|
"interactive_amt" => {
|
|
|
@@ -403,7 +409,7 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
JsonVal::Arr(lines.into_iter().map(JsonVal::Str).collect()),
|
|
|
);
|
|
|
res.set("responses", JsonVal::Arr(responses));
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
st.last_amt_apply = Some(res.clone());
|
|
|
}
|
|
|
"interactive_amt_cmd" => {
|
|
|
@@ -421,7 +427,7 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
"prompt_observed",
|
|
|
JsonVal::Bool(first_resp.get_bool("prompt_observed").unwrap_or(false)),
|
|
|
);
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
}
|
|
|
"interactive_start_amt" => {
|
|
|
let test_cmd = meta.get_str_or("test_command", "amemdiag 1");
|
|
|
@@ -432,13 +438,13 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
JsonVal::Arr(lines.into_iter().map(JsonVal::Str).collect()),
|
|
|
);
|
|
|
res.set("responses", JsonVal::Arr(responses));
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
st.last_amt_start = Some(res.clone());
|
|
|
}
|
|
|
"interactive_start_mt" => {
|
|
|
res.set("confirmation", JsonVal::Str("submitted".to_string()));
|
|
|
res.set("command", JsonVal::Str(meta.get_str_or("command", "FS0:\\EFI\\118.efi")));
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
}
|
|
|
"interactive_uefi_ls" => {
|
|
|
let path = meta.get_str_or("path", "");
|
|
|
@@ -498,11 +504,11 @@ fn finish_async_script(st: &mut StationState, now: i64) {
|
|
|
res.set("filesystems", JsonVal::Arr(filesystems));
|
|
|
res.set("complete", JsonVal::Bool(complete));
|
|
|
res.set("evidence", JsonVal::Str(out));
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
}
|
|
|
_ => {
|
|
|
res.set("confirmation", JsonVal::Str(confirmation.to_string()));
|
|
|
- res.set("observed_unix_ms", JsonVal::Num(now as f64));
|
|
|
+ res.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|
|
|
}
|
|
|
}
|
|
|
let _ = tx.send(Ok(res));
|
|
|
@@ -671,17 +677,41 @@ pub fn control_boot_plan_impl(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+pub fn normalize_uefi_efi_path(raw: &str) -> String {
|
|
|
+ let trimmed = raw.trim().replace('/', "\\");
|
|
|
+ if trimmed.is_empty() {
|
|
|
+ return "FS0:\\EFI\\118.efi".to_string();
|
|
|
+ }
|
|
|
+ if !trimmed.contains('\\') && !trimmed.contains(':') && trimmed.to_ascii_lowercase().ends_with(".efi") {
|
|
|
+ return format!("FS0:\\EFI\\{}", trimmed);
|
|
|
+ }
|
|
|
+ trimmed
|
|
|
+}
|
|
|
+
|
|
|
+pub fn extract_efi_basename(norm_path: &str) -> String {
|
|
|
+ norm_path
|
|
|
+ .rsplit('\\')
|
|
|
+ .next()
|
|
|
+ .filter(|s| !s.trim().is_empty())
|
|
|
+ .unwrap_or("118.efi")
|
|
|
+ .trim()
|
|
|
+ .to_string()
|
|
|
+}
|
|
|
+
|
|
|
pub fn needs_uefi_efi_probe(st: &StationState, sel: &JsonVal) -> bool {
|
|
|
if st.efi_probe_done || st.resolved_mt_efi_path.is_some() {
|
|
|
return false;
|
|
|
}
|
|
|
- let raw_path = sel
|
|
|
+ let raw_cfg = sel
|
|
|
.get_str("efi_path")
|
|
|
.filter(|s| !s.trim().is_empty())
|
|
|
- .unwrap_or("FS0:\\EFI\\118.efi")
|
|
|
- .trim()
|
|
|
- .replace('/', "\\");
|
|
|
- if raw_path.to_ascii_uppercase() != "FS0:\\EFI\\118.EFI" {
|
|
|
+ .unwrap_or("FS0:\\EFI\\118.efi");
|
|
|
+ let norm_path = normalize_uefi_efi_path(raw_cfg);
|
|
|
+ if !norm_path.to_ascii_uppercase().ends_with(".EFI") {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let explicit_non_fs0 = norm_path.contains(':') && !norm_path.to_ascii_uppercase().starts_with("FS0:\\EFI\\");
|
|
|
+ if explicit_non_fs0 {
|
|
|
return false;
|
|
|
}
|
|
|
let cur_prompt = st.prompt_evidence.to_ascii_uppercase();
|
|
|
@@ -691,16 +721,27 @@ pub fn needs_uefi_efi_probe(st: &StationState, sel: &JsonVal) -> bool {
|
|
|
st.uefi_fs_candidates.len() > 1 || (!already_in_efi && !cur_prompt.contains("\\EFI"))
|
|
|
}
|
|
|
|
|
|
-pub fn build_uefi_efi_probe_steps(st: &StationState) -> Vec<AsyncScriptStep> {
|
|
|
+pub fn build_uefi_efi_probe_steps_for(st: &StationState, sel: &JsonVal) -> (Vec<AsyncScriptStep>, String) {
|
|
|
+ let raw_cfg = sel
|
|
|
+ .get_str("efi_path")
|
|
|
+ .filter(|s| !s.trim().is_empty())
|
|
|
+ .unwrap_or("FS0:\\EFI\\118.efi");
|
|
|
+ let base_efi = extract_efi_basename(&normalize_uefi_efi_path(raw_cfg));
|
|
|
let mut cands: Vec<String> = st.uefi_fs_candidates.clone();
|
|
|
if cands.is_empty() {
|
|
|
cands.push("FS0:".to_string());
|
|
|
cands.push("FS1:".to_string());
|
|
|
+ } else {
|
|
|
+ for fallback in ["FS0:", "FS1:"] {
|
|
|
+ if !cands.iter().any(|c| c.eq_ignore_ascii_case(fallback)) {
|
|
|
+ cands.push(fallback.to_string());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
let mut steps = Vec::new();
|
|
|
for fs in &cands {
|
|
|
steps.push(AsyncScriptStep {
|
|
|
- line: format!("ls {}\\EFI\\118.efi", fs.to_ascii_lowercase()),
|
|
|
+ line: format!("ls {}\\EFI\\{}", fs.to_ascii_lowercase(), base_efi),
|
|
|
expected_prompt_kind: "uefi".to_string(),
|
|
|
timeout_ms: 2500,
|
|
|
reject_on_fw_error: false,
|
|
|
@@ -708,26 +749,32 @@ pub fn build_uefi_efi_probe_steps(st: &StationState) -> Vec<AsyncScriptStep> {
|
|
|
}
|
|
|
for fs in &cands {
|
|
|
steps.push(AsyncScriptStep {
|
|
|
- line: format!("ls {}\\118.efi", fs.to_ascii_lowercase()),
|
|
|
+ line: format!("ls {}\\{}", fs.to_ascii_lowercase(), base_efi),
|
|
|
expected_prompt_kind: "uefi".to_string(),
|
|
|
timeout_ms: 2500,
|
|
|
reject_on_fw_error: false,
|
|
|
});
|
|
|
}
|
|
|
- steps
|
|
|
+ (steps, base_efi)
|
|
|
+}
|
|
|
+
|
|
|
+pub fn build_uefi_efi_probe_steps(st: &StationState) -> Vec<AsyncScriptStep> {
|
|
|
+ build_uefi_efi_probe_steps_for(st, &st.mt_selection).0
|
|
|
}
|
|
|
|
|
|
pub fn build_uefi_mt_steps(st: &StationState, sel: &JsonVal) -> Vec<AsyncScriptStep> {
|
|
|
- let configured_path = sel
|
|
|
+ let raw_cfg = sel
|
|
|
.get_str("efi_path")
|
|
|
.filter(|s| !s.trim().is_empty())
|
|
|
- .unwrap_or("FS0:\\EFI\\118.efi")
|
|
|
- .trim()
|
|
|
- .replace('/', "\\");
|
|
|
- let raw_path = if configured_path.to_ascii_uppercase() == "FS0:\\EFI\\118.EFI" {
|
|
|
- st.resolved_mt_efi_path
|
|
|
- .clone()
|
|
|
- .unwrap_or(configured_path)
|
|
|
+ .unwrap_or("FS0:\\EFI\\118.efi");
|
|
|
+ let configured_path = normalize_uefi_efi_path(raw_cfg);
|
|
|
+ let configured_base = extract_efi_basename(&configured_path);
|
|
|
+ let raw_path = if let Some(ref resolved) = st.resolved_mt_efi_path {
|
|
|
+ if extract_efi_basename(resolved).eq_ignore_ascii_case(&configured_base) {
|
|
|
+ resolved.clone()
|
|
|
+ } else {
|
|
|
+ configured_path
|
|
|
+ }
|
|
|
} else {
|
|
|
configured_path
|
|
|
};
|
|
|
@@ -738,7 +785,12 @@ pub fn build_uefi_mt_steps(st: &StationState, sel: &JsonVal) -> Vec<AsyncScriptS
|
|
|
|| cur_prompt.contains("\\EFI>");
|
|
|
let upper_raw = raw_path.to_ascii_uppercase();
|
|
|
|
|
|
- if upper_raw.ends_with("118.EFI") {
|
|
|
+ if upper_raw.ends_with(".EFI") {
|
|
|
+ let efi_basename = extract_efi_basename(&raw_path);
|
|
|
+ let efi_stem = efi_basename
|
|
|
+ .strip_suffix(".efi")
|
|
|
+ .or_else(|| efi_basename.strip_suffix(".EFI"))
|
|
|
+ .unwrap_or("118");
|
|
|
let target_fs = raw_path
|
|
|
.split('\\')
|
|
|
.next()
|
|
|
@@ -771,7 +823,8 @@ pub fn build_uefi_mt_steps(st: &StationState, sel: &JsonVal) -> Vec<AsyncScriptS
|
|
|
reject_on_fw_error: false,
|
|
|
});
|
|
|
}
|
|
|
- let cfg_lines: Vec<String> = render_mt86_cfg_text(sel, "")
|
|
|
+ let tftp_ip = sel.get_str_or("pxe_server_ip", "192.168.0.10");
|
|
|
+ let cfg_lines: Vec<String> = render_mt86_cfg_text(sel, &tftp_ip)
|
|
|
.lines()
|
|
|
.map(|l| l.trim().to_string())
|
|
|
.filter(|l| !l.is_empty())
|
|
|
@@ -785,8 +838,13 @@ pub fn build_uefi_mt_steps(st: &StationState, sel: &JsonVal) -> Vec<AsyncScriptS
|
|
|
reject_on_fw_error: false,
|
|
|
});
|
|
|
}
|
|
|
- // Mirror mt86.cfg to common MemTest86 v11.x candidate config filenames inside \EFI\
|
|
|
- for cand in ["118.cfg", "memtest86.cfg", "\"Default string-mt86.cfg\""] {
|
|
|
+ // Mirror mt86.cfg to common MemTest86 v11.x candidate config filenames inside target directory
|
|
|
+ let stem_cfg = format!("{}.cfg", efi_stem);
|
|
|
+ let mut cands = vec!["118.cfg".to_string(), "memtest86.cfg".to_string(), "\"Default string-mt86.cfg\"".to_string()];
|
|
|
+ if !stem_cfg.eq_ignore_ascii_case("118.cfg") && !stem_cfg.eq_ignore_ascii_case("mt86.cfg") {
|
|
|
+ cands.insert(0, stem_cfg);
|
|
|
+ }
|
|
|
+ for cand in cands {
|
|
|
steps.push(AsyncScriptStep {
|
|
|
line: format!("cp -q mt86.cfg {}", cand),
|
|
|
expected_prompt_kind: "uefi".to_string(),
|
|
|
@@ -794,8 +852,14 @@ pub fn build_uefi_mt_steps(st: &StationState, sel: &JsonVal) -> Vec<AsyncScriptS
|
|
|
reject_on_fw_error: false,
|
|
|
});
|
|
|
}
|
|
|
+ let args_tail = sel.get_str_or("arguments", "");
|
|
|
+ let launch_line = if args_tail.trim().is_empty() {
|
|
|
+ efi_basename
|
|
|
+ } else {
|
|
|
+ format!("{} {}", efi_basename, args_tail.trim())
|
|
|
+ };
|
|
|
steps.push(AsyncScriptStep {
|
|
|
- line: "118.efi".to_string(),
|
|
|
+ line: launch_line,
|
|
|
expected_prompt_kind: String::new(),
|
|
|
timeout_ms: 2000,
|
|
|
reject_on_fw_error: false,
|
|
|
@@ -1155,14 +1219,16 @@ pub fn step_boot_plan(st: &mut StationState, contract: &FirmwareContract) {
|
|
|
"uefi" => {
|
|
|
if mt_enabled && !st.plan_mt_started {
|
|
|
if needs_uefi_efi_probe(st, &st.mt_selection) {
|
|
|
- let probe_steps = build_uefi_efi_probe_steps(st);
|
|
|
+ let (probe_steps, base_efi) = build_uefi_efi_probe_steps_for(st, &st.mt_selection);
|
|
|
+ let mut pmeta = JsonVal::obj();
|
|
|
+ pmeta.set("probe_efi_basename", JsonVal::Str(base_efi));
|
|
|
start_async_script(
|
|
|
st,
|
|
|
"probe_mt_efi",
|
|
|
probe_steps,
|
|
|
false,
|
|
|
Vec::new(),
|
|
|
- JsonVal::Null,
|
|
|
+ pmeta,
|
|
|
None,
|
|
|
);
|
|
|
return;
|
|
|
@@ -1237,14 +1303,16 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
|
|
|
}
|
|
|
}
|
|
|
if needs_uefi_efi_probe(st, &preview_sel) {
|
|
|
- let probe_steps = build_uefi_efi_probe_steps(st);
|
|
|
+ let (probe_steps, base_efi) = build_uefi_efi_probe_steps_for(st, &preview_sel);
|
|
|
+ let mut pmeta = JsonVal::obj();
|
|
|
+ pmeta.set("probe_efi_basename", JsonVal::Str(base_efi));
|
|
|
start_async_script(
|
|
|
st,
|
|
|
"probe_mt_efi",
|
|
|
probe_steps,
|
|
|
false,
|
|
|
Vec::new(),
|
|
|
- JsonVal::Null,
|
|
|
+ pmeta,
|
|
|
None,
|
|
|
);
|
|
|
return;
|
|
|
@@ -1835,7 +1903,9 @@ fn emit_complete_signal(
|
|
|
sig.set("stage_completions", st.stage_completions_json());
|
|
|
sig.set(
|
|
|
"summary_path",
|
|
|
- JsonVal::Str(summary_obj.get_str_or("log_clean_path", "")),
|
|
|
+ JsonVal::Str(
|
|
|
+ summary_obj.get_str_or("summary_path", &summary_obj.get_str_or("log_clean_path", "")),
|
|
|
+ ),
|
|
|
);
|
|
|
let now = now_ms();
|
|
|
sig.set("observed_unix_ms", JsonVal::Str(now.to_string()));
|