Skip to content

Commit

Permalink
Thread sysroot through adopt+update flow
Browse files Browse the repository at this point in the history
More prep for #108
Similar to the previous PR for updates.
  • Loading branch information
cgwalters authored and openshift-merge-robot committed Nov 18, 2020
1 parent 6e1c089 commit 968b86c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/bootupd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ pub(crate) fn adopt_and_update(name: &str) -> Result<ContentMetadata> {
} else {
anyhow::bail!("Component {} has no available update", name);
};
let mut state_guard = SavedState::acquire_write_lock(openat::Dir::open("/")?)
.context("Failed to acquire write lock")?;

let inst = component
.adopt_update(&update)
.adopt_update(&state_guard.sysroot, &update)
.context("Failed adopt and update")?;
state.installed.insert(component.name().into(), inst);

let sysroot = openat::Dir::open("/")?;
let mut state_guard =
SavedState::acquire_write_lock(sysroot).context("Failed to acquire write lock")?;
state_guard.update_state(&state)?;
Ok(update)
}
Expand Down
6 changes: 5 additions & 1 deletion src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ pub(crate) trait Component {
fn query_adopt(&self) -> Result<Option<Adoptable>>;

/// Given an adoptable system and an update, perform the update.
fn adopt_update(&self, update: &ContentMetadata) -> Result<InstalledContent>;
fn adopt_update(
&self,
sysroot: &openat::Dir,
update: &ContentMetadata,
) -> Result<InstalledContent>;

/// Implementation of `bootupd install` for a given component. This should
/// gather data (or run binaries) from the source root, and install them
Expand Down
11 changes: 8 additions & 3 deletions src/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ impl Component for EFI {
}

/// Given an adoptable system and an update, perform the update.
fn adopt_update(&self, updatemeta: &ContentMetadata) -> Result<InstalledContent> {
fn adopt_update(
&self,
sysroot: &openat::Dir,
updatemeta: &ContentMetadata,
) -> Result<InstalledContent> {
let meta = if let Some(meta) = self.query_adopt()? {
meta
} else {
Expand All @@ -83,8 +87,9 @@ impl Component for EFI {

let esp = self.open_esp()?;
validate_esp(&esp)?;
let updated =
openat::Dir::open(&component_updatedir("/", self)).context("opening update dir")?;
let updated = sysroot
.sub_dir(&component_updatedirname(self))
.context("opening update dir")?;
let updatef = filetree::FileTree::new_from_dir(&updated).context("reading update dir")?;
// For adoption, we should only touch files that we know about.
let diff = updatef.relative_diff_to(&esp)?;
Expand Down

0 comments on commit 968b86c

Please sign in to comment.