diff --git a/src/procdata.rs b/src/procdata.rs index 03c0d53..20ae3fb 100644 --- a/src/procdata.rs +++ b/src/procdata.rs @@ -84,6 +84,16 @@ impl TintProcessor { paths.extend(databuf); } + // Explicitly keep paths + // XXX: Support globbing + paths.extend(self.profile.get_keep_paths()); + + // Explicitly knock-out paths + // XXX: Support globbing + for p in self.profile.get_prune_paths() { + paths.remove(&p); + } + // Scan rootfs log::debug!("Scanning existing rootfs"); let mut p = rootfs::RootFS::new() diff --git a/src/profile.rs b/src/profile.rs index 5441598..3ac5fd8 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -1,11 +1,12 @@ use serde::{Deserialize, Serialize}; -use std::fmt::Debug; +use std::{fmt::Debug, path::PathBuf}; use std::{fs, io::Error, path::Path}; #[derive(Serialize, Deserialize, PartialEq, Debug)] pub struct PConfig { filters: Option>, prune: Option>, + keep: Option>, } #[derive(Serialize, Deserialize, PartialEq, Debug)] @@ -24,7 +25,8 @@ pub struct Profile { f_man: bool, f_dir: bool, f_log: bool, - f_prune: Vec, + f_expl_prune: Vec, + f_expl_keep: Vec, packages: Vec, targets: Vec, @@ -43,7 +45,8 @@ impl Profile { f_log: true, packages: vec![], targets: vec![], - f_prune: vec![], + f_expl_prune: vec![], + f_expl_keep: vec![], } } @@ -77,8 +80,13 @@ impl Profile { } } } + if let Some(prn) = cfg.prune { - self.f_prune.extend(prn); + self.f_expl_prune.extend(prn.iter().map(PathBuf::from).collect::>()); + } + + if let Some(keep) = cfg.keep { + self.f_expl_keep.extend(keep.iter().map(PathBuf::from).collect::>()); } } @@ -135,11 +143,35 @@ impl Profile { self } + /// Add path prune + #[allow(dead_code)] + pub fn prune_path(&mut self, pth: String) -> &mut Self { + self.f_expl_prune.push(PathBuf::from(pth)); + self + } + + /// Add path to be kept + #[allow(dead_code)] + pub fn keep_path(&mut self, pth: String) -> &mut Self { + self.f_expl_keep.push(PathBuf::from(pth)); + self + } + /// Get targets pub fn get_targets(&self) -> &Vec { &self.targets } + /// Get paths to be explicitly pruned + pub fn get_prune_paths(&self) -> Vec { + self.f_expl_prune.clone() + } + + /// Get paths to be explicitly kept + pub fn get_keep_paths(&self) -> Vec { + self.f_expl_keep.clone() + } + /// Returns true if localisation data needs to be removed pub fn filter_l10n(&self) -> bool { !self.f_l10n