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 install flow #112

Merged
merged 1 commit into from
Nov 20, 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
3 changes: 2 additions & 1 deletion src/bootupd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) enum ClientRequest {
}

pub(crate) fn install(source_root: &str, dest_root: &str) -> Result<()> {
let source_root = openat::Dir::open(source_root)?;
SavedState::ensure_not_present(dest_root)
.context("failed to install, invalid re-install attempted")?;

Expand All @@ -35,7 +36,7 @@ pub(crate) fn install(source_root: &str, dest_root: &str) -> Result<()> {
let mut state = SavedState::default();
for component in components.values() {
let meta = component
.install(source_root, dest_root)
.install(&source_root, dest_root)
.with_context(|| format!("installing component {}", component.name()))?;
state.installed.insert(component.name().into(), meta);
}
Expand Down
2 changes: 1 addition & 1 deletion src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub(crate) trait Component {
/// of a filesystem root, the component should query the mount point to
/// determine the block device.
/// This will be run during a disk image build process.
fn install(&self, src_root: &str, dest_root: &str) -> Result<InstalledContent>;
fn install(&self, src_root: &openat::Dir, dest_root: &str) -> Result<InstalledContent>;

/// Implementation of `bootupd generate-update-metadata` for a given component.
/// This expects to be run during an "image update build" process. For CoreOS
Expand Down
17 changes: 9 additions & 8 deletions src/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use std::collections::{BTreeMap, BTreeSet};
use std::io::prelude::*;
use std::os::unix::io::AsRawFd;
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -102,27 +103,27 @@ impl Component for EFI {
})
}

fn install(&self, src_root: &str, dest_root: &str) -> Result<InstalledContent> {
let src_rootd = openat::Dir::open(src_root)?;
let meta = if let Some(meta) = get_component_update(&src_rootd, self)? {
fn install(&self, src_root: &openat::Dir, dest_root: &str) -> Result<InstalledContent> {
let meta = if let Some(meta) = get_component_update(&src_root, self)? {
meta
} else {
anyhow::bail!("No update metadata for component {} found", self.name());
};
let srcdir = component_updatedir(src_root, self);
let srcd = openat::Dir::open(&srcdir)
.with_context(|| format!("opening src dir {}", srcdir.display()))?;
let ft = crate::filetree::FileTree::new_from_dir(&srcd)?;
let srcdir_name = component_updatedirname(self);
let ft = crate::filetree::FileTree::new_from_dir(&src_root.sub_dir(&srcdir_name)?)?;
let destdir = Path::new(dest_root).join(MOUNT_PATH);
{
let destd = openat::Dir::open(&destdir)
.with_context(|| format!("opening dest dir {}", destdir.display()))?;
validate_esp(&destd)?;
}
// TODO - add some sort of API that allows directly setting the working
// directory to a file descriptor.
let r = std::process::Command::new("cp")
.args(&["-rp", "--reflink=auto"])
.arg(&srcdir)
.arg(&srcdir_name)
.arg(&destdir)
.current_dir(format!("/proc/self/fd/{}", src_root.as_raw_fd()))
.status()?;
if !r.success() {
anyhow::bail!("Failed to copy");
Expand Down