|
62 | 62 | //! 2. **Secondary**: Currently booted deployment (rollback option) |
63 | 63 |
|
64 | 64 | use std::fs::create_dir_all; |
| 65 | +use std::io::Read; |
65 | 66 | use std::io::Write; |
66 | 67 | use std::path::Path; |
67 | 68 | use std::sync::Arc; |
@@ -422,19 +423,21 @@ fn write_bls_boot_entries_to_disk( |
422 | 423 | } |
423 | 424 |
|
424 | 425 | /// Parses /usr/lib/os-release and returns (id, title, version) |
425 | | -fn parse_os_release(mounted_fs: &Dir) -> Result<Option<(String, Option<String>, Option<String>)>> { |
| 426 | +/// Expects a reference to the root of the filesystem, or the root |
| 427 | +/// of a mounted EROFS |
| 428 | +pub fn parse_os_release(root: &Dir) -> Result<Option<(String, Option<String>, Option<String>)>> { |
426 | 429 | // Every update should have its own /usr/lib/os-release |
427 | | - let file_contents = match mounted_fs.read_to_string("usr/lib/os-release") { |
428 | | - Ok(c) => c, |
429 | | - Err(e) if e.kind() == std::io::ErrorKind::NotFound => { |
430 | | - return Ok(None); |
431 | | - } |
432 | | - Err(e) => { |
433 | | - tracing::warn!("Could not read /usr/lib/os-release: {e:?}"); |
434 | | - return Ok(None); |
435 | | - } |
| 430 | + let file = root |
| 431 | + .open_optional("usr/lib/os-release") |
| 432 | + .context("Opening usr/lib/os-release")?; |
| 433 | + |
| 434 | + let Some(mut os_rel_file) = file else { |
| 435 | + return Ok(None); |
436 | 436 | }; |
437 | 437 |
|
| 438 | + let mut file_contents = String::new(); |
| 439 | + os_rel_file.read_to_string(&mut file_contents)?; |
| 440 | + |
438 | 441 | let parsed = OsReleaseInfo::parse(&file_contents); |
439 | 442 |
|
440 | 443 | let os_id = parsed |
@@ -551,13 +554,13 @@ pub(crate) fn setup_composefs_bls_boot( |
551 | 554 | // Remove "root=" from kernel cmdline as systemd-auto-gpt-generator should use DPS |
552 | 555 | // UUID |
553 | 556 | if bootloader == Bootloader::Systemd { |
554 | | - cmdline_refs.remove(&ParameterKey::from("root")); |
| 557 | + cmdline_refs.remove(&ParameterKey::from("root") as &ParameterKey); |
555 | 558 | } |
556 | 559 |
|
557 | 560 | let is_upgrade = matches!(setup_type, BootSetupType::Upgrade(..)); |
558 | 561 |
|
559 | 562 | let current_root = if is_upgrade { |
560 | | - Some(&Dir::open_ambient_dir("/", ambient_authority()).context("Opening root")?) |
| 563 | + Some(&Dir::open_ambient_dir("/", ambient_authority()).context("Opening root")? as &Dir) |
561 | 564 | } else { |
562 | 565 | None |
563 | 566 | }; |
@@ -1222,7 +1225,7 @@ pub(crate) async fn setup_composefs_boot( |
1222 | 1225 | let id = composefs_oci::generate_boot_image(&repo, &pull_result.manifest_digest) |
1223 | 1226 | .context("Generating bootable EROFS image")?; |
1224 | 1227 |
|
1225 | | - // Get boot entries from the OCI filesystem (untransformed). |
| 1228 | + // Reconstruct the OCI filesystem to discover boot entries (kernel, initramfs, etc.). |
1226 | 1229 | let fs = composefs_oci::image::create_filesystem(&*repo, &pull_result.config_digest, None) |
1227 | 1230 | .context("Creating composefs filesystem for boot entry discovery")?; |
1228 | 1231 | let entries = |
|
0 commit comments