config reader start
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
use std::{fmt, path::{Path, PathBuf}};
|
||||
|
||||
mod ruport;
|
||||
mod portage;
|
||||
|
||||
use ruport::RuportConfigProvider;
|
||||
use portage::PortageConfigProvider;
|
||||
|
||||
use crate::features::Features;
|
||||
|
||||
trait ConfigProvider {
|
||||
fn new() -> Result<Self, ConfigError> where Self: Sized;
|
||||
fn parse_global(&mut self) -> Result<(), std::io::Error>;
|
||||
|
||||
// getter
|
||||
fn get_elog(&self) -> ELog;
|
||||
fn get_features(&self) -> Vec<Features>;
|
||||
|
||||
// display functions
|
||||
fn display_cflags(&self);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ConfigError {
|
||||
PortageConfigNotFound,
|
||||
RuportConfigNotFound,
|
||||
}
|
||||
impl fmt::Display for ConfigError {
|
||||
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
// portage paths
|
||||
pub(crate) struct PortagePaths {
|
||||
distdir: PathBuf,
|
||||
pkgdir: PathBuf,
|
||||
rpmdir: PathBuf,
|
||||
tmpdir: PathBuf,
|
||||
}
|
||||
|
||||
// elog classes
|
||||
#[derive(Debug,Clone)]
|
||||
enum ELogClasses {
|
||||
Log,
|
||||
Warn,
|
||||
Error,
|
||||
}
|
||||
impl ELogClasses {
|
||||
pub fn from(line: String) -> Vec<Self> {
|
||||
let mut ret = Vec::new();
|
||||
|
||||
let line = line.trim_matches('"')
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for v in line {
|
||||
match v {
|
||||
"log" => ret.push(ELogClasses::Log),
|
||||
"warn" => ret.push(ELogClasses::Warn),
|
||||
"error" => ret.push(ELogClasses::Error),
|
||||
|
||||
_ => eprintln!("unknown ELog Class: {v}"),
|
||||
}
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone)]
|
||||
pub(crate) struct ELog {
|
||||
classes: Vec<ELogClasses>,
|
||||
system: String,
|
||||
mail_uri: String,
|
||||
mail_subject: String,
|
||||
mail_from: String,
|
||||
}
|
||||
impl ELog {
|
||||
pub fn default() -> Self {
|
||||
Self {
|
||||
classes: vec![ELogClasses::Log, ELogClasses::Warn, ELogClasses::Error],
|
||||
system: "save_summary:log,warn,error,qa echo".to_string(),
|
||||
|
||||
mail_uri: "root".to_string(),
|
||||
mail_subject: "[portage] ebuild log for {pkg} on {host}".to_string(),
|
||||
mail_from: "portage@localhost".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This struct holds the current configuration.
|
||||
pub struct PortageConfig {
|
||||
provider: Box<dyn ConfigProvider>,
|
||||
|
||||
elog: ELog,
|
||||
features: Vec<Features>,
|
||||
}
|
||||
impl PortageConfig {
|
||||
pub fn new() -> Result<Self, std::io::Error> {
|
||||
let mut p: Box<dyn ConfigProvider> = match PortageConfigProvider::new() {
|
||||
Ok(prov) => Box::new(prov),
|
||||
Err(_) => {
|
||||
match RuportConfigProvider::new() {
|
||||
Ok(prov) => Box::new(prov),
|
||||
Err(_) => Box::new(RuportConfigProvider::default()),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
match p.parse_global() {
|
||||
Ok(r) => {},
|
||||
Err(e) => {},
|
||||
};
|
||||
|
||||
let elog = p.get_elog();
|
||||
let features = p.get_features();
|
||||
|
||||
Ok(Self {
|
||||
provider: p,
|
||||
elog: elog,
|
||||
features: features,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn display_config(&self) {
|
||||
self.provider.display_cflags();
|
||||
|
||||
// display active features
|
||||
println!("Active Features: {:?}", self.features);
|
||||
|
||||
// print elog information
|
||||
println!("ELOG: ");
|
||||
println!("\tClasses: {:?}", self.elog.classes);
|
||||
println!("\tSystem: {}", self.elog.system);
|
||||
println!("\tMail Subject: {}", self.elog.mail_subject);
|
||||
println!("\tMail From: ({}) {}", self.elog.mail_uri, self.elog.mail_from);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
|
||||
use std::{collections::HashMap, fs::File, io::{BufRead, BufReader, Error, ErrorKind}, path::{Path, PathBuf}};
|
||||
|
||||
use log::debug;
|
||||
|
||||
use crate::features::Features;
|
||||
|
||||
use super::ConfigProvider;
|
||||
use super::ConfigError;
|
||||
use super::PortagePaths;
|
||||
use super::{ELog,ELogClasses};
|
||||
|
||||
/// The Portage config provider.
|
||||
///
|
||||
/// It is the default configuration in "normal" gentoo system. Per default,
|
||||
/// Ruport try to read this configuration first.
|
||||
pub(crate) struct PortageConfigProvider{
|
||||
global_path: PathBuf,
|
||||
compile_flags: HashMap<String, String>,
|
||||
features: Vec<Features>,
|
||||
mirrors: Vec<String>,
|
||||
paths: PortagePaths,
|
||||
elog: ELog,
|
||||
}
|
||||
impl PortageConfigProvider {
|
||||
fn validate_data(&mut self, data: Vec<(String,String)>) -> std::io::Result<()> {
|
||||
for (key,value) in data {
|
||||
match key.as_str() {
|
||||
"CFLAGS" => self.compile_flags.insert("CFLAGS".to_string(), value),
|
||||
"CXXFLAGS" => self.compile_flags.insert("CXXFLAGS".to_string(), value),
|
||||
"FFLAGS" => self.compile_flags.insert("FFLAGS".to_string(), value),
|
||||
"FCFLAGS" => self.compile_flags.insert("FCFLAGS".to_string(), value),
|
||||
"LDFLAGS" => self.compile_flags.insert("LDFLAGS".to_string(), value),
|
||||
|
||||
"GENTOO_MIRRORS" => {
|
||||
let mirrors: Vec<&str> = value.split_whitespace().collect();
|
||||
for mirror in mirrors {
|
||||
self.mirrors.push(mirror.to_string());
|
||||
}
|
||||
},
|
||||
|
||||
"FEATURES" => {
|
||||
let features: Vec<&str> = value.split_whitespace().collect();
|
||||
for feature in features {
|
||||
let f = Features::from(feature);
|
||||
if f.is_some(){
|
||||
self.features.push(f.unwrap());
|
||||
}
|
||||
}
|
||||
},
|
||||
"DISTDIR" => {
|
||||
let dir = value.trim_matches('"');
|
||||
self.paths.distdir = PathBuf::from(dir);
|
||||
},
|
||||
"PKGDIR" => {
|
||||
let dir = value.trim_matches('"');
|
||||
self.paths.pkgdir = PathBuf::from(dir);
|
||||
},
|
||||
"RPMDIR" => {
|
||||
let dir = value.trim_matches('"');
|
||||
self.paths.rpmdir = PathBuf::from(dir);
|
||||
},
|
||||
"PORTAGE_TMPDIR" => {
|
||||
let dir = value.trim_matches('"');
|
||||
self.paths.tmpdir = PathBuf::from(dir);
|
||||
},
|
||||
|
||||
// ELog configuration
|
||||
"PORTAGE_ELOG_CLASSES" => {
|
||||
let classes = value.trim_matches('"')
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>();
|
||||
for class in classes {
|
||||
let c = match class {
|
||||
"log" => ELogClasses::Log,
|
||||
"warn" => ELogClasses::Warn,
|
||||
"error" => ELogClasses::Error,
|
||||
};
|
||||
self.elog.classes.push(c);
|
||||
}
|
||||
},
|
||||
"PORTAGE_ELOG_SYSTEM" => self.elog.system = value,
|
||||
"PORTAGE_ELOG_MAILURI" => self.elog.mail_uri = value,
|
||||
"PORTAGE_ELOG_MAILSUBJECT" => {
|
||||
let subject = value
|
||||
.replace("\\${PACKAGE", "{pkg}")
|
||||
.replace("\\${HOST}", "{host}");
|
||||
self.elog.mail_subject = subject;
|
||||
},
|
||||
"PORTAGE_ELOG_MAILFROM" => self.elog.mail_from = value,
|
||||
|
||||
&_ => todo!(),
|
||||
};
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ConfigProvider for PortageConfigProvider {
|
||||
fn new() -> Result<Self, ConfigError> {
|
||||
let global_path = Path::new("/usr/share/portage/config/make.globals");
|
||||
|
||||
if !global_path.exists() {
|
||||
return Err(ConfigError::PortageConfigNotFound);
|
||||
}
|
||||
|
||||
log::debug!("using portage config");
|
||||
|
||||
Ok(Self{
|
||||
global_path: global_path.to_path_buf(),
|
||||
compile_flags: HashMap::new(),
|
||||
features: Vec::new(),
|
||||
mirrors: Vec::new(),
|
||||
paths: PortagePaths {
|
||||
distdir: PathBuf::new(),
|
||||
pkgdir: PathBuf::new(),
|
||||
rpmdir: PathBuf::new(),
|
||||
tmpdir: PathBuf::new(),
|
||||
},
|
||||
elog: ELog::default(),
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_global(&mut self) -> Result<(), std::io::Error> {
|
||||
let file = File::open(self.global_path.clone())?;
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
let mut data: Vec<(String, String)> = Vec::new();
|
||||
|
||||
let mut current_key: Option<String> = None;
|
||||
let mut current_value = String::new();
|
||||
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
let line = line.trim();
|
||||
|
||||
// ignore empty line or comments
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// multiple line
|
||||
if current_key.is_some() {
|
||||
current_value.push(' ');
|
||||
current_value.push_str(&line.to_string());
|
||||
}
|
||||
|
||||
if let Some(index) = line.find('=') {
|
||||
let key = line[..index].trim().to_string();
|
||||
let value = line[index+1..].trim();
|
||||
|
||||
if value.starts_with('"') && !value.ends_with('"') {
|
||||
current_key = Some(key);
|
||||
current_value = value.to_string();
|
||||
} else {
|
||||
data.push((key, current_value.to_string()));
|
||||
current_value.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.validate_data(data)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// fn eparse_global(&mut self) -> std::io::Result<()> {
|
||||
// let file = File::open(self.global_path.clone())?;
|
||||
// let reader = BufReader::new(file);
|
||||
|
||||
// let mut data: HashMap<String, String> = HashMap::new();
|
||||
|
||||
// let mut current_key: Option<String> = None;
|
||||
// let mut current_value = String::new();
|
||||
|
||||
// for line in reader.lines() {
|
||||
// let line = line.unwrap();
|
||||
// let line = line.trim();
|
||||
|
||||
// // ignore empty line or comments
|
||||
// if line.is_empty() || line.starts_with('#') {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// // multiline option
|
||||
// if current_key.is_some() {
|
||||
// current_value.push(' ');
|
||||
// current_value.push_str(line);
|
||||
|
||||
// if line.ends_with('"') {
|
||||
// data.insert(
|
||||
// current_key.take().unwrap(),
|
||||
// current_value.clone(),
|
||||
// );
|
||||
// current_value.clear();
|
||||
// }
|
||||
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if let Some(index) = line.find('=') {
|
||||
// let key = line[..index].trim().to_string();
|
||||
// let value = line[index+1..].trim();
|
||||
|
||||
// if value.starts_with('"') && ! value.ends_with('"') {
|
||||
// current_key = Some(key);
|
||||
// current_value = value.to_string();
|
||||
// } else {
|
||||
// if current_value.contains("${*}") {
|
||||
|
||||
// }
|
||||
// data.insert(key, value.to_string());
|
||||
// }
|
||||
|
||||
// // data.insert(
|
||||
// // key.to_string(),
|
||||
// // value.to_string()
|
||||
// // );
|
||||
// }
|
||||
// }
|
||||
|
||||
// // now get the values from the buffer
|
||||
// let cflags = data.get("CFLAGS");
|
||||
// if cflags.is_some() {
|
||||
// self.compile_flags.insert("CFLAGS".to_string(), cflags.unwrap().to_string());
|
||||
// }
|
||||
// let cxxflags = data.get("CXXFLAGS");
|
||||
// if cxxflags.is_some() {
|
||||
// self.compile_flags.insert("CXXFLAGS".to_string(), cxxflags.unwrap().to_string());
|
||||
// }
|
||||
// let ldflags = data.get("LDFLAGS");
|
||||
// if ldflags.is_some() {
|
||||
// self.compile_flags.insert("LDFLAGS".to_string(), ldflags.unwrap().to_string());
|
||||
// }
|
||||
// let fflags = data.get("FFLAGS");
|
||||
// if fflags.is_some() {
|
||||
// self.compile_flags.insert("FFLAGS".to_string(), fflags.unwrap().to_string());
|
||||
// }
|
||||
// let fcflags = data.get("FCFLAGS");
|
||||
// if fcflags.is_some() {
|
||||
// self.compile_flags.insert("FCFLAGS".to_string(), fcflags.unwrap().to_string());
|
||||
// }
|
||||
// let mirrors = data.get("GENTOO_MIRRORS");
|
||||
// let mirrors: Vec<&str> = mirrors.unwrap().split_whitespace().collect();
|
||||
// for mirror in mirrors {
|
||||
// self.mirrors.push(mirror.to_string());
|
||||
// }
|
||||
|
||||
// let features = data.get("FEATURES");
|
||||
// if features.is_some() {
|
||||
// self.features = Features::from_line(features.unwrap().to_string())
|
||||
// }
|
||||
|
||||
// let distdir = data.get("DISTDIR");
|
||||
// let pkgdir = data.get("PKGDIR");
|
||||
// let rpmdir = data.get("RPMDIR");
|
||||
// let tmpdir = data.get("PORTAGE_TMPDIR");
|
||||
// if distdir.is_some() {
|
||||
// self.paths.distdir = PathBuf::from(distdir.unwrap().to_string());
|
||||
// }
|
||||
// if pkgdir.is_some() {
|
||||
// self.paths.pkgdir = PathBuf::from(pkgdir.unwrap().to_string());
|
||||
// }
|
||||
// if rpmdir.is_some() {
|
||||
// self.paths.rpmdir = PathBuf::from(rpmdir.unwrap().to_string());
|
||||
// }
|
||||
// if tmpdir.is_some() {
|
||||
// self.paths.tmpdir = PathBuf::from(tmpdir.unwrap().to_string())
|
||||
// }
|
||||
|
||||
// // elog settings
|
||||
// let elog_classes = data.get("PORTAGE_ELOG_CLASSES");
|
||||
// let elog_system = data.get("PORTAGE_ELOG_SYSTEM");
|
||||
// let elog_mailuri = data.get("PORTAGE_ELOG_MAILURI");
|
||||
// let elog_mailsubject = data.get("PORTAGE_ELOG_MAILSUBJECT");
|
||||
// let elog_mailfrom = data.get("PORTAGE_ELOG_MAILFROM");
|
||||
// if elog_classes.is_some() {
|
||||
// self.elog.classes = ELogClasses::from(elog_classes.unwrap().to_string());
|
||||
// }
|
||||
// if elog_system.is_some() {
|
||||
// self.elog.system = elog_system.unwrap().to_string();
|
||||
// }
|
||||
// if elog_mailuri.is_some() {
|
||||
// self.elog.mail_uri = elog_mailuri.unwrap().to_string();
|
||||
// }
|
||||
// if elog_mailsubject.is_some() {
|
||||
// let subject = elog_mailsubject.unwrap().to_string();
|
||||
// let _ = subject.replace("\\${PACKAGE}", "{pkg}")
|
||||
// .replace("\\${HOST}", "{host}");
|
||||
// self.elog.mail_subject = subject;
|
||||
// }
|
||||
// if elog_mailfrom.is_some() {
|
||||
// self.elog.mail_from = elog_mailfrom.unwrap().to_string();
|
||||
// }
|
||||
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
fn get_elog(&self) -> ELog {
|
||||
self.elog.clone()
|
||||
}
|
||||
fn get_features(&self) -> Vec<Features> {
|
||||
self.features.clone()
|
||||
}
|
||||
|
||||
fn display_cflags(&self) {
|
||||
println!("Compiler Flags:");
|
||||
for (k,v) in self.compile_flags.clone() {
|
||||
let v = v.trim_matches('"');
|
||||
println!("\t{k} = {v}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::features::Features;
|
||||
|
||||
use super::ConfigProvider;
|
||||
use super::ConfigError;
|
||||
use super::{ELog,ELogClasses};
|
||||
|
||||
/// The Ruport config provider.
|
||||
///
|
||||
/// It is used, then there is no current portage configuration available.
|
||||
/// It is also capable of, creating default configs, useful for embedded
|
||||
/// systems.
|
||||
pub(crate) struct RuportConfigProvider{
|
||||
global_path: PathBuf,
|
||||
elog: ELog,
|
||||
features: Vec<Features>,
|
||||
}
|
||||
|
||||
impl RuportConfigProvider {
|
||||
pub fn default() -> Self {
|
||||
let elog = ELog::default();
|
||||
|
||||
Self {
|
||||
global_path: PathBuf::from("/usr/share/ruport/config.ini"),
|
||||
elog,
|
||||
features: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ConfigProvider for RuportConfigProvider {
|
||||
fn new() -> Result<Self, ConfigError> {
|
||||
let global_path = Path::new("/usr/share/ruport/config.ini");
|
||||
if !global_path.exists() {
|
||||
return Err(ConfigError::RuportConfigNotFound);
|
||||
}
|
||||
|
||||
log::debug!("using ruport config.");
|
||||
Ok(Self{
|
||||
global_path: global_path.to_path_buf(),
|
||||
elog: ELog::default(),
|
||||
features: Vec::new(),
|
||||
})
|
||||
}
|
||||
fn parse_global(&mut self) -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_elog(&self) -> ELog {
|
||||
self.elog.clone()
|
||||
}
|
||||
fn get_features(&self) -> Vec<crate::features::Features> {
|
||||
self.features.clone()
|
||||
}
|
||||
|
||||
fn display_cflags(&self) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
|
||||
#[derive(Debug,Clone,Copy)]
|
||||
pub enum Features {
|
||||
AssumeDigests,
|
||||
BinPkgDoCompress,
|
||||
BinPkgDoStrip,
|
||||
BinPkgIgnoreSignature,
|
||||
BinPkgLogs,
|
||||
BinPkgMultiInstance,
|
||||
BinPkgRequestSignature,
|
||||
BinPkgSigning,
|
||||
BuildPkg,
|
||||
BuildPkgLive,
|
||||
BuildPkgProactive,
|
||||
BuildSysPkg,
|
||||
Candy,
|
||||
CaseInsensistiveFs,
|
||||
Ccache,
|
||||
Chflags,
|
||||
CleanLogs,
|
||||
CollisionProtect,
|
||||
CompressBuildLogs,
|
||||
CompressDebug,
|
||||
CompressIndex,
|
||||
ConfigProtectIfModified,
|
||||
DeDupDebug,
|
||||
Digest,
|
||||
DistCC,
|
||||
DistLocks,
|
||||
DowngradeBackup,
|
||||
EbuildLocks,
|
||||
FailClean,
|
||||
FakeRoot,
|
||||
FixLaFiles,
|
||||
ForceMirror,
|
||||
GetBinPkg,
|
||||
GpgKeepAlive,
|
||||
HomeDirTemplateCopy,
|
||||
IceCream,
|
||||
InstallSources,
|
||||
IpcSandbox,
|
||||
JobServerToken,
|
||||
KeepTemp,
|
||||
KeepWork,
|
||||
LMirror,
|
||||
MergeSync,
|
||||
MergeWait,
|
||||
MetadataTransfer,
|
||||
Mirror,
|
||||
MountSandbox,
|
||||
MultilibStrict,
|
||||
NetworkSandbox,
|
||||
NetworkSandboxProxy,
|
||||
News,
|
||||
NoAuto,
|
||||
NoClean,
|
||||
NoDoc,
|
||||
NoInfo,
|
||||
NoMan,
|
||||
NoStrip,
|
||||
NoTitles,
|
||||
PackDebug,
|
||||
ParallelFetch,
|
||||
ParallelInstall,
|
||||
PidSandbox,
|
||||
PkgdirIndexTrusted,
|
||||
PrelinkChecksums,
|
||||
PreserveLibs,
|
||||
ProtectOwned,
|
||||
PythonTrace,
|
||||
QAUnresolvedSonameDeps,
|
||||
Sandbox,
|
||||
SeLinux,
|
||||
SeSandbox,
|
||||
SFPerms,
|
||||
Sign,
|
||||
SkipRoCheck,
|
||||
SplitDebug,
|
||||
SplitElog,
|
||||
SplitLog,
|
||||
Strict,
|
||||
StrictKeepDir,
|
||||
Stricter,
|
||||
Suidctl,
|
||||
Test,
|
||||
TestFailContinue,
|
||||
UnknownFeaturesFilter,
|
||||
UnknownFeaturesWarn,
|
||||
UnmergeBackup,
|
||||
UnmergeLogs,
|
||||
UnmergeOrphans,
|
||||
Unprivileged,
|
||||
UserFetch,
|
||||
UserPriv,
|
||||
UserSandbox,
|
||||
UserSync,
|
||||
WarnOnLargeEnv,
|
||||
WebRsyncGpg,
|
||||
XATTR,
|
||||
}
|
||||
|
||||
impl Features {
|
||||
pub fn from(val: &str) -> Option<Self> {
|
||||
log::debug!("features val line: {val}");
|
||||
|
||||
match val {
|
||||
"assume-digests" => Some(Self::AssumeDigests),
|
||||
|
||||
"binpkg-docompress" => Some(Self::BinPkgDoCompress),
|
||||
"binpkg-dostrip" => Some(Self::BinPkgDoStrip),
|
||||
"binpkg-ignore-signature" => Some(Self::BinPkgIgnoreSignature),
|
||||
"binpkg-logs" => Some(Self::BinPkgLogs),
|
||||
"binpkg-multi-instance" => Some(Self::BinPkgMultiInstance),
|
||||
"binpkg-request-signature" => Some(Self::BinPkgRequestSignature),
|
||||
"binpkg-signing" => Some(Self::BinPkgSigning),
|
||||
|
||||
"buildpkg" => Some(Self::BuildPkg),
|
||||
"buildpkg-live" => Some(Self::BuildPkgLive),
|
||||
"buildpkg-proactive" => Some(Self::BuildPkgProactive),
|
||||
"buildsyspkg" => Some(Self::BuildSysPkg),
|
||||
|
||||
"candy" => Some(Self::Candy),
|
||||
"case-insensistive-fs" => Some(Self::CaseInsensistiveFs),
|
||||
"ccache" => Some(Self::Ccache),
|
||||
"chflags" => Some(Self::Chflags),
|
||||
"clean-logs" => Some(Self::CleanLogs),
|
||||
"collision-protect" => Some(Self::CollisionProtect),
|
||||
"compress-build-logs" => Some(Self::CompressBuildLogs),
|
||||
"compressdebug" => Some(Self::CompressDebug),
|
||||
"compress-index" => Some(Self::CompressIndex),
|
||||
"config-protect-if-modified" => Some(Self::ConfigProtectIfModified),
|
||||
"dedupdebug" => Some(Self::DeDupDebug),
|
||||
"digest" => Some(Self::Digest),
|
||||
"distcc" => Some(Self::DistCC),
|
||||
"distlocks" => Some(Self::DistLocks),
|
||||
"downgrade-backup" => Some(Self::DowngradeBackup),
|
||||
"ebuild-locks" => Some(Self::EbuildLocks),
|
||||
"fail-clean" => Some(Self::FailClean),
|
||||
"fakeroot" => Some(Self::FakeRoot),
|
||||
"fixlafiles" => Some(Self::FixLaFiles),
|
||||
"force-mirror" => Some(Self::ForceMirror),
|
||||
"getbinpkg" => Some(Self::GetBinPkg),
|
||||
"gpg-keepalive" => Some(Self::GpgKeepAlive),
|
||||
"home-dir-template-copy" => Some(Self::HomeDirTemplateCopy),
|
||||
"icecream" => Some(Self::IceCream),
|
||||
"installsources" => Some(Self::InstallSources),
|
||||
"ipc-sandbox" => Some(Self::IpcSandbox),
|
||||
"jobserver-token" => Some(Self::JobServerToken),
|
||||
"keeptemp" => Some(Self::KeepTemp),
|
||||
"keepwork" => Some(Self::KeepWork),
|
||||
"lmirror" => Some(Self::LMirror),
|
||||
"merge-sync" => Some(Self::MergeSync),
|
||||
"merge-wait" => Some(Self::MergeWait),
|
||||
"metadata-transfer" => Some(Self::MetadataTransfer),
|
||||
"mirror" => Some(Self::Mirror),
|
||||
"mount-sandbox" => Some(Self::MountSandbox),
|
||||
"multilib-strict" => Some(Self::MultilibStrict),
|
||||
"network-sandbox" => Some(Self::NetworkSandbox),
|
||||
"network-sandbox-proxy" => Some(Self::NetworkSandboxProxy),
|
||||
"news" => Some(Self::News),
|
||||
|
||||
"noauto" => Some(Self::NoAuto),
|
||||
"noclean" => Some(Self::NoClean),
|
||||
"nodoc" => Some(Self::NoDoc),
|
||||
"noinfo" => Some(Self::NoInfo),
|
||||
"noman" => Some(Self::NoMan),
|
||||
"nostrip" => Some(Self::NoStrip),
|
||||
"notitles" => Some(Self::NoTitles),
|
||||
|
||||
"packdebug" => Some(Self::PackDebug),
|
||||
"parallel-fetch" => Some(Self::ParallelFetch),
|
||||
"parallel-install" => Some(Self::ParallelInstall),
|
||||
"pid-sandbox" => Some(Self::PidSandbox),
|
||||
"pkgdir-index-trusted" => Some(Self::PkgdirIndexTrusted),
|
||||
"prelink-checksums" => Some(Self::PrelinkChecksums),
|
||||
"preserve-libs" => Some(Self::PreserveLibs),
|
||||
"protect-owned" => Some(Self::ProtectOwned),
|
||||
"python-trace" => Some(Self::PythonTrace),
|
||||
"qa-unresolved-soname-deps" => Some(Self::QAUnresolvedSonameDeps),
|
||||
"sandbox" => Some(Self::Sandbox),
|
||||
"selinux" => Some(Self::SeLinux),
|
||||
"sesandbox" => Some(Self::SeSandbox),
|
||||
"sfperms" => Some(Self::SFPerms),
|
||||
"sign" => Some(Self::Sign),
|
||||
"skiprocheck" => Some(Self::SkipRoCheck),
|
||||
"splitdebug" => Some(Self::SplitDebug),
|
||||
"split-elog" => Some(Self::SplitElog),
|
||||
"split-log" => Some(Self::SplitLog),
|
||||
|
||||
"strict" => Some(Self::Strict),
|
||||
"strict-keepdir" => Some(Self::StrictKeepDir),
|
||||
"stricter" => Some(Self::Stricter),
|
||||
"suidctl" => Some(Self::Suidctl),
|
||||
|
||||
"test" => Some(Self::Test),
|
||||
"test-fail-continue" => Some(Self::TestFailContinue),
|
||||
|
||||
"unknown-features-filter" => Some(Self::UnknownFeaturesFilter),
|
||||
"unknown-features-warn" => Some(Self::UnknownFeaturesWarn),
|
||||
|
||||
"unmerge-backup" => Some(Self::UnmergeBackup),
|
||||
"unmerge-logs" => Some(Self::UnmergeLogs),
|
||||
"unmerge-orphans" => Some(Self::UnmergeOrphans),
|
||||
|
||||
"unprivileged" => Some(Self::Unprivileged),
|
||||
|
||||
"userfetch" => Some(Self::UserFetch),
|
||||
"userpriv" => Some(Self::UserPriv),
|
||||
"usersandbox" => Some(Self::UserSandbox),
|
||||
"usersync" => Some(Self::UserSync),
|
||||
|
||||
"warn-on-large-env" => Some(Self::WarnOnLargeEnv),
|
||||
"webrsync-gpg" => Some(Self::WebRsyncGpg),
|
||||
"xattr" => Some(Self::XATTR),
|
||||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn from_line(line: String) -> Vec<Self> {
|
||||
let mut ret = Vec::new();
|
||||
for v in line.split_whitespace() {
|
||||
let f = Self::from(v);
|
||||
if f.is_some() {
|
||||
ret.push(f.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ use crate::repository::RepoConfig;
|
||||
pub mod config;
|
||||
pub mod util;
|
||||
pub mod repository;
|
||||
pub(crate) mod features;
|
||||
|
||||
|
||||
#[derive(Debug,Clone,ValueEnum)]
|
||||
pub enum Action {
|
||||
|
||||
@@ -3,6 +3,11 @@ use log::{Record, Level, Metadata, SetLoggerError, LevelFilter};
|
||||
struct SimpleLogger;
|
||||
|
||||
impl log::Log for SimpleLogger {
|
||||
#[cfg(debug_assertions)]
|
||||
fn enabled(&self, metadata: &Metadata) -> bool {
|
||||
metadata.level() <= Level::Debug
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn enabled(&self, metadata: &Metadata) -> bool {
|
||||
metadata.level() <= Level::Info
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user