2018-06-17 11:43:25 +03:00
|
|
|
use super::utils::Check;
|
2018-06-06 15:32:38 +03:00
|
|
|
use failure;
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
|
|
const EMACS_UPGRADE: &str = include_str!("emacs.el");
|
|
|
|
|
|
|
|
|
|
pub fn run_zplug(zsh: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(zsh)
|
|
|
|
|
.args(&["-c", "source ~/.zshrc && zplug update"])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_tpm(tpm: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&tpm).arg("all").spawn()?.wait()?.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_cargo_update(cargo_update: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&cargo_update)
|
2018-06-11 15:45:26 +03:00
|
|
|
.args(&["install-update", "--git", "--all"])
|
2018-06-06 15:32:38 +03:00
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_emacs(emacs: &PathBuf, init: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&emacs)
|
|
|
|
|
.args(&[
|
|
|
|
|
"--batch",
|
|
|
|
|
"-l",
|
|
|
|
|
init.to_str().unwrap(),
|
|
|
|
|
"--eval",
|
|
|
|
|
EMACS_UPGRADE,
|
|
|
|
|
])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
2018-06-07 08:51:16 +03:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_vim(
|
|
|
|
|
vim: &PathBuf,
|
|
|
|
|
vimrc: &PathBuf,
|
|
|
|
|
upgrade_command: &str,
|
|
|
|
|
) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&vim)
|
|
|
|
|
.args(&[
|
|
|
|
|
"-N",
|
|
|
|
|
"-u",
|
|
|
|
|
vimrc.to_str().unwrap(),
|
|
|
|
|
"-c",
|
|
|
|
|
upgrade_command,
|
|
|
|
|
"-c",
|
|
|
|
|
"quitall",
|
|
|
|
|
"-e",
|
|
|
|
|
"-s",
|
|
|
|
|
"-V1",
|
|
|
|
|
])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
2018-06-06 15:32:38 +03:00
|
|
|
|
2018-06-09 20:52:42 +03:00
|
|
|
println!("");
|
|
|
|
|
|
2018-06-06 15:32:38 +03:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_apm(apm: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&apm)
|
|
|
|
|
.args(&["upgrade", "--confirm=false"])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_needrestart(sudo: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&sudo)
|
|
|
|
|
.arg("needrestart")
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_fwupdmgr(fwupdmgr: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&fwupdmgr)
|
|
|
|
|
.arg("refresh")
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Command::new(&fwupdmgr)
|
|
|
|
|
.arg("get-updates")
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-07 22:36:32 +03:00
|
|
|
pub fn run_rustup(rustup: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(rustup).arg("update").spawn()?.wait()?.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-06 15:32:38 +03:00
|
|
|
pub fn upgrade_macos() -> Result<(), failure::Error> {
|
|
|
|
|
Command::new("softwareupdate")
|
|
|
|
|
.args(&["--install", "--all"])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_homebrew(homebrew: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&homebrew)
|
|
|
|
|
.arg("update")
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Command::new(&homebrew)
|
|
|
|
|
.arg("upgrade")
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-08 18:19:07 +03:00
|
|
|
pub fn run_custom_command(command: &str) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new("sh")
|
|
|
|
|
.arg("-c")
|
|
|
|
|
.arg(command)
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
2018-06-14 13:10:52 +03:00
|
|
|
|
|
|
|
|
pub fn run_flatpak(flatpak: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&flatpak)
|
|
|
|
|
.arg("update")
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
2018-06-14 13:24:52 +03:00
|
|
|
|
|
|
|
|
pub fn run_snap(sudo: &PathBuf, snap: &PathBuf) -> Result<(), failure::Error> {
|
|
|
|
|
Command::new(&sudo)
|
|
|
|
|
.args(&[snap.to_str().unwrap(), "refresh"])
|
|
|
|
|
.spawn()?
|
|
|
|
|
.wait()?
|
|
|
|
|
.check()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|