Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
HuijingHei committed Sep 12, 2024
1 parent b74840b commit 34d42da
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion src/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,38 @@ impl Component for Bios {
}

fn query_adopt(&self) -> Result<Option<Adoptable>> {
// This would be extended with support for other operating systems later
if let Some(coreos_aleph) = crate::coreos::get_aleph_version(Path::new("/"))? {
let meta = ContentMetadata {
timestamp: coreos_aleph.ts,
version: coreos_aleph.aleph.version,
};
log::trace!("BIOS adoptable: {:?}", &meta);
return Ok(Some(Adoptable {
version: meta,
confident: true,
}));
} else {
log::trace!("No CoreOS aleph detected");
}
// Don't adopt if the system is booted with systemd-boot or
// systemd-stub since those will be managed with bootctl.
if skip_systemd_bootloaders() {
return Ok(None);
}
let ostree_deploy_dir = Path::new("/ostree/deploy");
if ostree_deploy_dir.exists() {
let btime = ostree_deploy_dir.metadata()?.created()?;
let timestamp = chrono::DateTime::from(btime);
let meta = ContentMetadata {
timestamp,
version: "unknown".to_string(),
};
return Ok(Some(Adoptable {
version: meta,
confident: true,
}));
}
Ok(None)
}

Expand All @@ -131,7 +163,20 @@ impl Component for Bios {
sysroot: &openat::Dir,
update: &ContentMetadata,
) -> Result<InstalledContent> {
todo!();
let meta = if let Some(meta) = self.query_adopt()? {
meta
} else {
anyhow::bail!("Failed to find adoptable system");
};

let device = self.get_device()?;
let device = device.trim();
self.run_grub_install("/", device)?;
Ok(InstalledContent {
meta: update,
filetree: None,
adopted_from: Some(meta.version),
})
}

fn query_update(&self, sysroot: &openat::Dir) -> Result<Option<ContentMetadata>> {
Expand Down

0 comments on commit 34d42da

Please sign in to comment.