Run etc-update (fix #72)

This commit is contained in:
Roey Darwish Dror
2018-10-02 13:25:02 +03:00
parent 3875f973d1
commit e9e743ab45
3 changed files with 29 additions and 1 deletions

View File

@@ -27,11 +27,12 @@ distribution which ships the latest version of Rust, such as Arch Linux.
## Usage
Just run `topgrade`. It will run the following steps:
* Run the system package manager:
* *Linux*: Run the system package manager:
* *Arch*: Run [yay](https://github.com/Jguer/yay) or fall back to pacman
* *CentOS/RHEL*: Run `yum upgrade`
* *Fedora* - Run `dnf upgrade`
* *Debian/Ubuntu*: Run `apt update && apt dist-upgrade`
* *Linux*: Run [etc-update](https://dev.gentoo.org/~zmedico/portage/doc/man/etc-update.1.html):
* *Unix*: Run `brew update && brew upgrade`. This should handle both Homebrew and Linuxbrew
* *Windows*: Upgrade Powershell modules
* *Windows*: Upgrade all [Chocolatey](https://chocolatey.org/) packages

View File

@@ -263,3 +263,26 @@ pub fn run_snap(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool)
None
}
#[must_use]
pub fn run_etc_update(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
if let Some(sudo) = sudo {
if let Some(etc_update) = which("etc-update") {
terminal.print_separator("etc-update");
let success = || -> Result<(), failure::Error> {
Executor::new(&sudo, dry_run)
.arg(&etc_update.to_str().unwrap())
.spawn()?
.wait()?
.check()?;
Ok(())
}().is_ok();
return Some(("snap", success));
}
}
None
}

View File

@@ -126,6 +126,10 @@ fn run() -> Result<(), Error> {
println!("Error detecting current distribution: {}", e);
}
}
report.push_result(execute(
|terminal| linux::run_etc_update(&sudo, terminal, opt.dry_run),
&mut terminal,
));
}
}