Skip to content

Commit

Permalink
Support symlinking in bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy authored and zaibon committed Jan 30, 2020
1 parent f77f78a commit fdfb58a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bootstrap/bootstrap/src/zfs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use failure::Error;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::{Child, Command};
use walkdir::WalkDir;
Expand Down Expand Up @@ -66,10 +67,21 @@ impl Zfs {
let mut dst = PathBuf::new();
dst.push(&target);
dst.push(src.strip_prefix(&self.target)?);
if entry.file_type().is_dir() {

let typ = entry.file_type();
if typ.is_dir() {
debug!("creating directory {:?}", dst);
std::fs::create_dir_all(dst)?;
} else {
} else if typ.is_file() {
debug!("installing file {:?}", dst);
std::fs::copy(&src, &dst)?;
} else if typ.is_symlink() {
let _ = fs::remove_file(&dst); // we don't care if file does not exist
let target = fs::read_link(src)?;
debug!("linking file {:?} -> {:?}", dst, target);
std::os::unix::fs::symlink(&dst, target)?;
} else {
error!("unsupported file type: ({:?}): {:?}", src, typ)
}
}

Expand Down

0 comments on commit fdfb58a

Please sign in to comment.