Support Void (fix #95)

This commit is contained in:
Roey Darwish Dror 2018-11-20 14:38:23 +02:00
parent 30259018c5
commit 5a7ec65545
2 changed files with 21 additions and 0 deletions

View File

@ -36,6 +36,7 @@ Just run `topgrade`. It will run the following steps:
* *Debian/Ubuntu*: Run `apt update && apt dist-upgrade`
* *Gentoo*: Run `layman -s ALL && emerge --sync -q && eix-update && emerge -uDNa world`
* *openSUSE*: Run `zypper refresh && zypper dist-upgrade`
* *Void*: Run `xbps-install -Su`
* *Linux*: Run [etc-update](https://dev.gentoo.org/~zmedico/portage/doc/man/etc-update.1.html):
* *FreeBSD*: Upgrade and audit packages
* *Unix*: Run `brew update && brew upgrade`. This should handle both Homebrew and Linuxbrew

View File

@ -16,6 +16,7 @@ pub enum Distribution {
Ubuntu,
Gentoo,
OpenSuse,
Void,
}
#[derive(Debug, Fail)]
@ -54,6 +55,10 @@ impl Distribution {
return Ok(Distribution::OpenSuse);
}
if content.contains("void") {
return Ok(Distribution::Void);
}
if PathBuf::from("/etc/gentoo-release").exists() {
return Ok(Distribution::Gentoo);
}
@ -77,6 +82,7 @@ impl Distribution {
Distribution::Ubuntu | Distribution::Debian => upgrade_debian(&sudo, terminal, dry_run),
Distribution::Gentoo => upgrade_gentoo(&sudo, terminal, dry_run),
Distribution::OpenSuse => upgrade_opensuse(&sudo, terminal, dry_run),
Distribution::Void => upgrade_void(&sudo, terminal, dry_run),
};
Some(("System update", success.is_ok()))
@ -170,6 +176,20 @@ fn upgrade_opensuse(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bo
Ok(())
}
fn upgrade_void(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Executor::new(&sudo, dry_run)
.args(&["/usr/bin/xbps-install", "-Su"])
.spawn()?
.wait()?
.check()?;
} else {
terminal.print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
fn upgrade_fedora(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool) -> Result<(), failure::Error> {
if let Some(sudo) = &sudo {
Executor::new(&sudo, dry_run)