add copy function
This commit is contained in:
parent
681a38987a
commit
2761cf1676
5 changed files with 494 additions and 5 deletions
|
|
@ -1,12 +1,14 @@
|
|||
// Simplify build
|
||||
// -
|
||||
|
||||
use std::fs::File;
|
||||
use std::{fs::File, path::PathBuf};
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use rayon::iter::{IntoParallelIterator, ParallelBridge, ParallelIterator};
|
||||
use tar::Archive;
|
||||
|
||||
use uu_cp::copy;
|
||||
|
||||
use crate::recipe_functions::common::{self, EnumAsValue};
|
||||
|
||||
pub type DefaultResult = Result<(), Box<dyn std::error::Error>>;
|
||||
|
|
@ -348,4 +350,39 @@ impl XBuilder {
|
|||
|
||||
result
|
||||
}
|
||||
|
||||
/// Used in build process
|
||||
/// BS -> `cp <src> <dest>`
|
||||
pub fn copy(src: PathBuf, dest: PathBuf) -> DefaultResult {
|
||||
let options = uu_cp::Options {
|
||||
attributes: uu_cp::Attributes::NONE,
|
||||
attributes_only: false,
|
||||
copy_contents: false,
|
||||
cli_dereference: false,
|
||||
copy_mode: uu_cp::CopyMode::Copy,
|
||||
dereference: true,
|
||||
one_file_system: false,
|
||||
parents: false,
|
||||
update: uu_cp::UpdateMode::All,
|
||||
debug: false,
|
||||
verbose: false,
|
||||
strip_trailing_slashes: false,
|
||||
reflink_mode: uu_cp::ReflinkMode::Auto,
|
||||
sparse_mode: uu_cp::SparseMode::Auto,
|
||||
backup: uu_cp::BackupMode::None,
|
||||
backup_suffix: "~".to_owned(),
|
||||
no_target_dir: false,
|
||||
overwrite: uu_cp::OverwriteMode::Clobber(uu_cp::ClobberMode::Standard),
|
||||
recursive: true, // !
|
||||
target_dir: None,
|
||||
progress_bar: true,
|
||||
set_selinux_context: false,
|
||||
context: None,
|
||||
};
|
||||
|
||||
match copy(&[src], dest.as_path(), &options) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(format!("{}", e.to_string()).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,2 @@
|
|||
pub mod recipe;
|
||||
pub mod recipev2;
|
||||
// pub mod ui;
|
||||
// pub mod x2engine;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue