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)
| 450 | /// Expects a reference to the root of the filesystem, or the root |
| 451 | /// of a mounted EROFS |
| 452 | pub 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 | |
| 478 | struct BLSEntryPath { |
| 479 | /// Where to write vmlinuz/initrd |
no test coverage detected