Move linux steps to the linux model

This commit is contained in:
Roey Darwish Dror
2018-06-12 21:28:32 +03:00
parent 6c42073446
commit 109be4b756
3 changed files with 79 additions and 75 deletions

View File

@@ -1,5 +1,4 @@
use super::terminal::Terminal;
use super::{which, Check};
use super::Check;
use failure;
use std::path::PathBuf;
use std::process::Command;
@@ -143,75 +142,6 @@ pub fn run_homebrew(homebrew: &PathBuf) -> Result<(), failure::Error> {
Ok(())
}
pub fn upgrade_arch_linux(
sudo: &Option<PathBuf>,
terminal: &Terminal,
) -> Result<(), failure::Error> {
if let Ok(yay) = which("yay") {
Command::new(yay).spawn()?.wait()?.check()?;
} else {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["pacman", "-Syu"])
.spawn()?
.wait()?
.check()?;
} else {
terminal.print_warning("No sudo or yay detected. Skipping system upgrade");
}
}
Ok(())
}
pub fn upgrade_redhat(sudo: &Option<PathBuf>, terminal: &Terminal) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["yum", "upgrade"])
.spawn()?
.wait()?
.check()?;
} else {
terminal.print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
pub fn upgrade_fedora(sudo: &Option<PathBuf>, terminal: &Terminal) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["dnf", "upgrade"])
.spawn()?
.wait()?
.check()?;
} else {
terminal.print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
pub fn upgrade_debian(sudo: &Option<PathBuf>, terminal: &Terminal) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["apt", "update"])
.spawn()?
.wait()?
.check()?;
Command::new(&sudo)
.args(&["apt", "dist-upgrade"])
.spawn()?
.wait()?
.check()?;
} else {
terminal.print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
pub fn run_custom_command(command: &str) -> Result<(), failure::Error> {
Command::new("sh")
.arg("-c")