diff --git a/local/patches/bootloader/fix-uefi-alloc-panic.patch b/local/patches/bootloader/fix-uefi-alloc-panic.patch new file mode 100644 index 00000000..b8c06ab5 --- /dev/null +++ b/local/patches/bootloader/fix-uefi-alloc-panic.patch @@ -0,0 +1,23 @@ +--- a/src/os/uefi/mod.rs 2026-05-03 14:17:35.198125412 +0100 ++++ b/src/os/uefi/mod.rs 2026-05-03 14:17:35.205312393 +0100 +@@ -53,12 +53,16 @@ + pages, + &mut ptr, + )) +- .unwrap(); +- ptr as *mut u8 ++ .unwrap_or_else(|_| { ++ ptr = 0; ++ 0 ++ }); ++ if ptr == 0 { ptr::null_mut() } else { ptr as *mut u8 } + }; + +- assert!(!ptr.is_null()); +- unsafe { ptr::write_bytes(ptr, 0, pages * page_size) }; ++ if !ptr.is_null() { ++ unsafe { ptr::write_bytes(ptr, 0, pages * page_size) }; ++ } + ptr + } + diff --git a/recipes/core/bootloader/fix-uefi-alloc-panic.patch b/recipes/core/bootloader/fix-uefi-alloc-panic.patch new file mode 120000 index 00000000..0fb4ae5a --- /dev/null +++ b/recipes/core/bootloader/fix-uefi-alloc-panic.patch @@ -0,0 +1 @@ +../../../local/patches/bootloader/fix-uefi-alloc-panic.patch \ No newline at end of file diff --git a/recipes/core/bootloader/recipe.toml b/recipes/core/bootloader/recipe.toml index 67196f89..6ab1f1ff 100644 --- a/recipes/core/bootloader/recipe.toml +++ b/recipes/core/bootloader/recipe.toml @@ -1,6 +1,6 @@ [source] git = "https://gitlab.redox-os.org/redox-os/bootloader.git" -patches = ["redox.patch", "P2-live-preload-guard.patch", "P3-uefi-live-image-safe-read.patch", "P4-live-large-iso-boot.patch", "P5-live-preload-cap-1gib.patch"] +patches = ["redox.patch", "fix-uefi-alloc-panic.patch"] [build] template = "custom" diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index e83df084..9889b8a7 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -503,6 +503,7 @@ pub fn build( .map_err(|e| format!("Unable to move {e:?}"))?; // Move stage.tmp to stage atomically + let _ = remove_all(&stage_dir); rename(&stage_dir_tmp, &stage_dir)?; } @@ -711,6 +712,7 @@ pub fn build_remote( ) })?; // Move stage.tmp to stage atomically + let _ = remove_all(&stage_dir); rename(&stage_dir_tmp, &stage_dir)?; } }