Gentoo support
This commit is contained in:
@@ -32,6 +32,7 @@ Just run `topgrade`. It will run the following steps:
|
|||||||
* *CentOS/RHEL*: Run `yum upgrade`
|
* *CentOS/RHEL*: Run `yum upgrade`
|
||||||
* *Fedora* - Run `dnf upgrade`
|
* *Fedora* - Run `dnf upgrade`
|
||||||
* *Debian/Ubuntu*: Run `apt update && apt dist-upgrade`
|
* *Debian/Ubuntu*: Run `apt update && apt dist-upgrade`
|
||||||
|
* *Gentoo*: Run `layman -s ALL && emerge --sync -q && eix-update && emerge -uDNa world`
|
||||||
* *Linux*: Run [etc-update](https://dev.gentoo.org/~zmedico/portage/doc/man/etc-update.1.html):
|
* *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
|
* *Unix*: Run `brew update && brew upgrade`. This should handle both Homebrew and Linuxbrew
|
||||||
* *Unix*: Run `nix upgrade-nix && nix --upgrade`.
|
* *Unix*: Run `nix upgrade-nix && nix --upgrade`.
|
||||||
|
|||||||
42
src/linux.rs
42
src/linux.rs
@@ -13,6 +13,7 @@ pub enum Distribution {
|
|||||||
Fedora,
|
Fedora,
|
||||||
Debian,
|
Debian,
|
||||||
Ubuntu,
|
Ubuntu,
|
||||||
|
Gentoo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
@@ -47,6 +48,10 @@ impl Distribution {
|
|||||||
return Ok(Distribution::Debian);
|
return Ok(Distribution::Debian);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if PathBuf::from("/etc/gentoo-release").exists() {
|
||||||
|
return Ok(Distribution::Gentoo);
|
||||||
|
}
|
||||||
|
|
||||||
Err(UnknownLinuxDistribution.into())
|
Err(UnknownLinuxDistribution.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +69,7 @@ impl Distribution {
|
|||||||
Distribution::CentOS => upgrade_redhat(&sudo, terminal, dry_run),
|
Distribution::CentOS => upgrade_redhat(&sudo, terminal, dry_run),
|
||||||
Distribution::Fedora => upgrade_fedora(&sudo, terminal, dry_run),
|
Distribution::Fedora => upgrade_fedora(&sudo, terminal, dry_run),
|
||||||
Distribution::Ubuntu | Distribution::Debian => upgrade_debian(&sudo, terminal, dry_run),
|
Distribution::Ubuntu | Distribution::Debian => upgrade_debian(&sudo, terminal, dry_run),
|
||||||
|
Distribution::Gentoo => upgrade_gentoo(&sudo, terminal, dry_run),
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(("System update", success.is_ok()))
|
Some(("System update", success.is_ok()))
|
||||||
@@ -151,6 +157,42 @@ fn upgrade_fedora(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn upgrade_gentoo(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool) -> Result<(), failure::Error> {
|
||||||
|
if let Some(sudo) = &sudo {
|
||||||
|
if let Some(layman) = which("layman") {
|
||||||
|
Executor::new(&sudo, dry_run)
|
||||||
|
.arg(layman)
|
||||||
|
.args(&["-s", "ALL"])
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Syncing portage");
|
||||||
|
Executor::new(&sudo, dry_run)
|
||||||
|
.arg("/usr/bin/emerge")
|
||||||
|
.args(&["-q", "--sync"])
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
|
|
||||||
|
if let Some(eix_update) = which("eix-update") {
|
||||||
|
Executor::new(&sudo, dry_run).arg(eix_update).spawn()?.wait()?.check()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Executor::new(&sudo, dry_run)
|
||||||
|
.arg("/usr/bin/emerge")
|
||||||
|
.args(&["-uDNa", "world"])
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
|
} else {
|
||||||
|
terminal.print_warning("No sudo detected. Skipping system upgrade");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn upgrade_debian(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool) -> Result<(), failure::Error> {
|
fn upgrade_debian(sudo: &Option<PathBuf>, terminal: &mut Terminal, dry_run: bool) -> Result<(), failure::Error> {
|
||||||
if let Some(sudo) = &sudo {
|
if let Some(sudo) = &sudo {
|
||||||
Executor::new(&sudo, dry_run)
|
Executor::new(&sudo, dry_run)
|
||||||
|
|||||||
Reference in New Issue
Block a user