Skip to content

Commit d7598fd

Browse files
authored
Merge pull request #1054 from HuijingHei/fix-update-RPi3
blockdev: support bootloader update on `MBR`
2 parents 02617b7 + ea67b9f commit d7598fd

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

Cargo.lock

Lines changed: 28 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ path = "src/main.rs"
2121

2222
[dependencies]
2323
anyhow = "1.0"
24-
bootc-internal-blockdev = "0.0.0"
25-
bootc-internal-utils = "0.0.0"
24+
bootc-internal-blockdev = "0.1.0"
25+
bootc-internal-utils = "0.1.0"
2626
cap-std-ext = "4.0.7"
2727
camino = "1.2.2"
2828
chrono = { version = "0.4.42", features = ["serde"] }

src/blockdev.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@ pub fn get_devices<P: AsRef<Path>>(target_root: P) -> Result<Vec<String>> {
3939
/// Find esp partition on the same device
4040
/// using sfdisk to get partitiontable
4141
pub fn get_esp_partition(device: &str) -> Result<Option<String>> {
42-
const ESP_TYPE_GUID: &str = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B";
4342
let device_info: PartitionTable =
4443
bootc_internal_blockdev::partitions_of(Utf8Path::new(device))?;
45-
let esp = device_info
46-
.partitions
47-
.into_iter()
48-
.find(|p| p.parttype.as_str() == ESP_TYPE_GUID);
49-
if let Some(esp) = esp {
50-
return Ok(Some(esp.node));
51-
}
52-
Ok(None)
44+
let esp = device_info.find_partition_of_esp()?;
45+
Ok(esp.map(|v| v.node.clone()))
5346
}
5447

5548
/// Find all ESP partitions on the devices

src/efi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl Efi {
111111
std::process::Command::new("mount")
112112
.arg(&esp_device)
113113
.arg(&mnt)
114-
.run()
114+
.run_inherited()
115115
.with_context(|| format!("Failed to mount {:?}", esp_device))?;
116116
log::debug!("Mounted at {mnt:?}");
117117
mountpoint = Some(mnt);
@@ -139,7 +139,7 @@ impl Efi {
139139
if let Some(mount) = self.mountpoint.borrow_mut().take() {
140140
Command::new("umount")
141141
.arg(&mount)
142-
.run()
142+
.run_inherited()
143143
.with_context(|| format!("Failed to unmount {mount:?}"))?;
144144
log::trace!("Unmounted");
145145
}
@@ -688,7 +688,7 @@ pub(crate) fn clear_efi_target(target: &str) -> Result<()> {
688688
let mut cmd = Command::new(EFIBOOTMGR);
689689
cmd.args(["-b", entry.id.as_str(), "-B"]);
690690
println!("Executing: {cmd:?}");
691-
cmd.run_with_cmd_context()?;
691+
cmd.run_inherited_with_cmd_context()?;
692692
}
693693
}
694694

@@ -716,7 +716,7 @@ pub(crate) fn create_efi_boot_entry(
716716
target,
717717
]);
718718
println!("Executing: {cmd:?}");
719-
cmd.run_with_cmd_context()
719+
cmd.run_inherited_with_cmd_context()
720720
}
721721

722722
#[context("Find target file recursively")]

src/filetree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ where
386386
.arg(src)
387387
.arg(dst)
388388
.pre_exec(move || rustix::process::fchdir(rootfd).map_err(Into::into))
389-
.run()?
389+
.run_inherited()?
390390
};
391391
log::debug!("Copy {src} to {dst}");
392392
Ok(())

src/grubconfigs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn write_grubenv(bootdir: &openat::Dir) -> Result<()> {
153153
std::process::Command::new(editenv)
154154
.args([GRUBENV, "create"])
155155
.current_dir(format!("/proc/self/fd/{}", grubdir.as_raw_fd()))
156-
.run_with_cmd_context()
156+
.run_inherited_with_cmd_context()
157157
}
158158

159159
#[cfg(test)]

0 commit comments

Comments
 (0)