Skip to content

Commit 3ec5405

Browse files
authored
Merge branch 'coreos:main' into firmware-copy
2 parents 8df5030 + 383903f commit 3ec5405

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

src/bios.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ impl Component for Bios {
161161
&self,
162162
rootcxt: &RootContext,
163163
update: &ContentMetadata,
164-
) -> Result<InstalledContent> {
164+
) -> Result<Option<InstalledContent>> {
165165
let bios_devices = blockdev::find_colocated_bios_boot(&rootcxt.devices)?;
166166
let Some(meta) = self.query_adopt(&bios_devices)? else {
167-
anyhow::bail!("Failed to find adoptable system")
167+
return Ok(None);
168168
};
169169

170170
let mut parent_devices = rootcxt.devices.iter();
@@ -179,11 +179,11 @@ impl Component for Bios {
179179
}
180180
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
181181
log::debug!("Installed grub modules on {parent}");
182-
Ok(InstalledContent {
182+
Ok(Some(InstalledContent {
183183
meta: update.clone(),
184184
filetree: None,
185185
adopted_from: Some(meta.version),
186-
})
186+
}))
187187
}
188188

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

src/bootupd.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ pub(crate) fn update(name: &str, rootcxt: &RootContext) -> Result<ComponentUpdat
258258
}
259259

260260
/// daemon implementation of component adoption
261-
pub(crate) fn adopt_and_update(name: &str, rootcxt: &RootContext) -> Result<ContentMetadata> {
261+
pub(crate) fn adopt_and_update(
262+
name: &str,
263+
rootcxt: &RootContext,
264+
) -> Result<Option<ContentMetadata>> {
262265
let sysroot = &rootcxt.sysroot;
263266
let mut state = SavedState::load_from_disk("/")?.unwrap_or_default();
264267
let component = component::new_from_name(name)?;
@@ -278,10 +281,15 @@ pub(crate) fn adopt_and_update(name: &str, rootcxt: &RootContext) -> Result<Cont
278281
let inst = component
279282
.adopt_update(&rootcxt, &update)
280283
.context("Failed adopt and update")?;
281-
state.installed.insert(component.name().into(), inst);
282-
283-
state_guard.update_state(&state)?;
284-
Ok(update)
284+
if let Some(inst) = inst {
285+
state.installed.insert(component.name().into(), inst);
286+
state_guard.update_state(&state)?;
287+
return Ok(Some(update));
288+
} else {
289+
// Nothing adopted, skip
290+
log::info!("Component '{}' skipped adoption", component.name());
291+
return Ok(None);
292+
}
285293
}
286294

287295
/// daemon implementation of component validate
@@ -492,9 +500,10 @@ pub(crate) fn client_run_update() -> Result<()> {
492500
}
493501
for (name, adoptable) in status.adoptable.iter() {
494502
if adoptable.confident {
495-
let r: ContentMetadata = adopt_and_update(name, &rootcxt)?;
496-
println!("Adopted and updated: {}: {}", name, r.version);
497-
updated = true;
503+
if let Some(r) = adopt_and_update(name, &rootcxt)? {
504+
println!("Adopted and updated: {}: {}", name, r.version);
505+
updated = true;
506+
}
498507
} else {
499508
println!("Component {} requires explicit adopt-and-update", name);
500509
}
@@ -512,8 +521,9 @@ pub(crate) fn client_run_adopt_and_update() -> Result<()> {
512521
println!("No components are adoptable.");
513522
} else {
514523
for (name, _) in status.adoptable.iter() {
515-
let r: ContentMetadata = adopt_and_update(name, &rootcxt)?;
516-
println!("Adopted and updated: {}: {}", name, r.version);
524+
if let Some(r) = adopt_and_update(name, &rootcxt)? {
525+
println!("Adopted and updated: {}: {}", name, r.version);
526+
}
517527
}
518528
}
519529
Ok(())

src/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) trait Component {
3636
&self,
3737
rootcxt: &RootContext,
3838
update: &ContentMetadata,
39-
) -> Result<InstalledContent>;
39+
) -> Result<Option<InstalledContent>>;
4040

4141
/// Implementation of `bootupd install` for a given component. This should
4242
/// gather data (or run binaries) from the source root, and install them

src/efi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ impl Component for Efi {
250250
&self,
251251
rootcxt: &RootContext,
252252
updatemeta: &ContentMetadata,
253-
) -> Result<InstalledContent> {
253+
) -> Result<Option<InstalledContent>> {
254254
let esp_devices = blockdev::find_colocated_esps(&rootcxt.devices)?;
255255
let Some(meta) = self.query_adopt(&esp_devices)? else {
256-
anyhow::bail!("Failed to find adoptable system")
256+
return Ok(None);
257257
};
258258

259259
let esp_devices = esp_devices.unwrap_or_default();
@@ -282,11 +282,11 @@ impl Component for Efi {
282282
log::trace!("applying adoption diff: {}", &diff);
283283
filetree::apply_diff(&updated, &destdir, &diff, None)
284284
.context("applying filesystem changes")?;
285-
Ok(InstalledContent {
285+
Ok(Some(InstalledContent {
286286
meta: updatemeta.clone(),
287287
filetree: Some(updatef),
288288
adopted_from: Some(meta.version),
289-
})
289+
}))
290290
}
291291

292292
fn install(

0 commit comments

Comments
 (0)