Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread sysroot through adopt+update flow #110

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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