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

Expand ensure_dir to allow copying subdirectories #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smklein
Copy link

@smklein smklein commented Mar 3, 2023

No description provided.

Comment on lines +2588 to +2613
ensure::directory(log, &dst, owner, group, mode)?;

if let Some(extsrc) = &extsrc {
if extsrc.starts_with('/') {
bail!("external source directory must be a relative path");
}
let dst = PathBuf::from(dst);

// "src" is the absolute path to a directory to be copied.
let src = ib.external_src_dir(extsrc)?;

for entry in walkdir::WalkDir::new(&src) {
let entry = entry?;
let from = entry.path();
let to = dst.join(from.strip_prefix(&src)?);
if entry.file_type().is_dir() {
if let Err(e) = std::fs::create_dir(to) {
if !matches!(e.kind(), std::io::ErrorKind::AlreadyExists) {
return Err(e.into());
}
}
} else if entry.file_type().is_file() {
std::fs::copy(from, to)?;
}
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the meat of this PR - I more-or-less mimicked how ensure_file seems to work with pulling extsrc files, but expanded that to work for directories too.

smklein added a commit to oxidecomputer/omicron that referenced this pull request Mar 7, 2023
My expectation is that we'll:

1. Download `global-zone-packages.tar.gz` in the `helios` repo
2. Unpack the contents into a staging directory
3. Use [image builder to copy the contents of these services into the
host OS image](illumos/image-builder#4)

Additionally, I made the list of artifacts a bit more explicit.
*Eventually* we could parse the package manifest to access this info,
but for now, I don't want to include any "intermediate" artifacts that
shouldn't be installed on a system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant