MCPcopy Create free account
hub / github.com/bootc-dev/bootc / parse_os_release

Function parse_os_release

crates/lib/src/bootc_composefs/boot.rs:452–476  ·  view source on GitHub ↗

Parses /usr/lib/os-release and returns (id, title, version) Expects a reference to the root of the filesystem, or the root of a mounted EROFS

(root: &Dir)

Source from the content-addressed store, hash-verified

450/// Expects a reference to the root of the filesystem, or the root
451/// of a mounted EROFS
452pub fn parse_os_release(root: &Dir) -> Result<Option<(String, Option<String>, Option<String>)>> {
453 // Every update should have its own /usr/lib/os-release
454 let file = root
455 .open_optional("usr/lib/os-release")
456 .context("Opening usr/lib/os-release")?;
457
458 let Some(mut os_rel_file) = file else {
459 return Ok(None);
460 };
461
462 let mut file_contents = String::new();
463 os_rel_file.read_to_string(&mut file_contents)?;
464
465 let parsed = OsReleaseInfo::parse(&file_contents);
466
467 let os_id = parsed
468 .get_value(&["ID"])
469 .unwrap_or_else(|| "bootc".to_string());
470
471 Ok(Some((
472 os_id,
473 parsed.get_pretty_name(),
474 parsed.get_version(),
475 )))
476}
477
478struct BLSEntryPath {
479 /// Where to write vmlinuz/initrd

Callers 3

setup_composefs_bls_bootFunction · 0.70
setup_composefs_bootFunction · 0.70
stage_bls_entry_changesFunction · 0.50

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected