Packagers files are OK if any one executor succeed
This commit is contained in:
parent
e0fe3620ca
commit
8d424e6c6a
@ -16,3 +16,14 @@ executors:
|
|||||||
params:
|
params:
|
||||||
- apt
|
- apt
|
||||||
- autoremove
|
- autoremove
|
||||||
|
- name: Zypper
|
||||||
|
pre_install:
|
||||||
|
- exe: sudo
|
||||||
|
params:
|
||||||
|
- zypper
|
||||||
|
- refresh
|
||||||
|
install:
|
||||||
|
exe: sudo
|
||||||
|
params:
|
||||||
|
- zypper
|
||||||
|
- dup
|
||||||
|
7
example_configs/cargo.yaml
Normal file
7
example_configs/cargo.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
executors:
|
||||||
|
- name: Cargo
|
||||||
|
install:
|
||||||
|
exe: cargo
|
||||||
|
params:
|
||||||
|
- install-update
|
||||||
|
- -a
|
@ -4,9 +4,3 @@ executors:
|
|||||||
exe: rustup
|
exe: rustup
|
||||||
params:
|
params:
|
||||||
- update
|
- update
|
||||||
- name: Cargo
|
|
||||||
install:
|
|
||||||
exe: cargo
|
|
||||||
params:
|
|
||||||
- install-update
|
|
||||||
- -a
|
|
||||||
|
@ -98,7 +98,7 @@ pub fn get_packages_folder(opt: &Opt) -> io::Result<PathBuf> {
|
|||||||
impl Updater {
|
impl Updater {
|
||||||
fn new() -> Updater {
|
fn new() -> Updater {
|
||||||
Updater {
|
Updater {
|
||||||
packagers: BTreeMap::from([(String::new(), Packager { executors: vec![] })]),
|
packagers: BTreeMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +218,23 @@ impl Updater {
|
|||||||
|
|
||||||
// XXX: We may parallelise (iter_par from rayon?) this loop. But the UI will be problematic to handle
|
// XXX: We may parallelise (iter_par from rayon?) this loop. But the UI will be problematic to handle
|
||||||
for (_packager_name, packager) in &self.packagers {
|
for (_packager_name, packager) in &self.packagers {
|
||||||
|
// TODO: default status should be an error, but… in the same time we should not have en empty list
|
||||||
|
let mut stat = (String::from("No command"), Ok(()).into());
|
||||||
|
|
||||||
|
assert!(!packager.executors.is_empty());
|
||||||
|
|
||||||
for pkg in &packager.executors {
|
for pkg in &packager.executors {
|
||||||
status.push((pkg.name.clone(), self.update(&pkg, opt).into()));
|
let u = self.update(&pkg, opt);
|
||||||
|
let is_ok = u.is_ok();
|
||||||
|
|
||||||
|
stat = (pkg.name.clone(), u.into());
|
||||||
|
|
||||||
|
if is_ok {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status.push(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
Summary { status }
|
Summary { status }
|
||||||
@ -256,7 +270,7 @@ impl Executor {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
if !exit_status.success() {
|
if !exit_status.success() {
|
||||||
return Err(Error::Execution {
|
return Result::Err(Error::Execution {
|
||||||
source: io::Error::new(io::ErrorKind::Other, format!("{}", exit_status)),
|
source: io::Error::new(io::ErrorKind::Other, format!("{}", exit_status)),
|
||||||
step: UpdateSteps::PreInstall,
|
step: UpdateSteps::PreInstall,
|
||||||
cmd,
|
cmd,
|
||||||
|
@ -8,6 +8,26 @@ use thiserror::Error;
|
|||||||
|
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
|
/// Result wrapper used to easily `Display` the Status of an execution
|
||||||
|
pub struct Status {
|
||||||
|
result: Result<()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for Status {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Status { result: Ok(_) } => write!(f, "Ok"),
|
||||||
|
Status { result: Err(e) } => write!(f, "Error: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Result<()>> for Status {
|
||||||
|
fn from(result: Result<()>) -> Self {
|
||||||
|
Status { result }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An error that can occur in this crate.
|
/// An error that can occur in this crate.
|
||||||
///
|
///
|
||||||
/// Generally, this error corresponds to problems with underlying process.
|
/// Generally, this error corresponds to problems with underlying process.
|
||||||
|
30
src/lib.rs
30
src/lib.rs
@ -21,35 +21,7 @@ pub struct Opt {
|
|||||||
pub steps: Vec<UpdateSteps>,
|
pub steps: Vec<UpdateSteps>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Status {
|
|
||||||
/// All steps asked were successful
|
|
||||||
Ok,
|
|
||||||
Err(Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for Status {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Status::Ok => write!(f, "Ok"),
|
|
||||||
Status::Err(e) => write!(f, "Error: {}", e),
|
|
||||||
// State::Fetch(e) => write!(f, "Fetch error: {}", e),
|
|
||||||
// State::Compile(e) => write!(f, "Compile error: {}", e),
|
|
||||||
// State::Install(e) => write!(f, "Install error: {}", e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> From<Result<T>> for Status {
|
|
||||||
fn from(value: Result<T>) -> Self {
|
|
||||||
match value {
|
|
||||||
Ok(_) => Status::Ok,
|
|
||||||
Err(e) => Status::Err(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Summary {
|
pub struct Summary {
|
||||||
// TODO: Go back to vectors to keep order?
|
|
||||||
status: Vec<(String, Status)>,
|
status: Vec<(String, Status)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +46,7 @@ pub fn run(opt: &Opt) -> io::Result<Summary> {
|
|||||||
return Err(io::Error::new(
|
return Err(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
format!(
|
format!(
|
||||||
"No package found in configuration folder. Add them in: {}",
|
"No package found in configuration folder. Add them in: '{}'",
|
||||||
package_folder.display()
|
package_folder.display()
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user