Adding Clear Linux update support (#256)

This commit is contained in:
Igor Petruk
2019-11-13 12:18:42 +00:00
committed by Roey Darwish Dror
parent ed5b7a2c66
commit 3c0f8a1ab0
3 changed files with 34 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ package manager. Topgrade is tested on and knows the following platforms:
* Arch based
* Red Hat based
* Debian based
* Clear Linux
* Gentoo
* NixOS
* openSUSE
@@ -67,6 +68,7 @@ Just run `topgrade`. It will run the following steps:
* **Arch based**: Run [yay](https://github.com/Jguer/yay) or fall back to pacman
* **Redhat based**: Run `yum upgrade` (or `dnf` if present)
* **Debian based**: Run `apt update && apt dist-upgrade`
* **Clear Linux**: Run `swupd update`
* **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`

View File

@@ -25,6 +25,7 @@ struct OsRelease {
pub enum Distribution {
Arch,
CentOS,
ClearLinux,
Fedora,
Debian,
Gentoo,
@@ -55,6 +56,7 @@ impl Distribution {
Ok(match id {
Some("centos") | Some("ol") => Distribution::CentOS,
Some("clear-linux-os") => Distribution::ClearLinux,
Some("fedora") => Distribution::Fedora,
Some("void") => Distribution::Void,
Some("debian") => Distribution::Debian,
@@ -87,6 +89,7 @@ impl Distribution {
match self {
Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, run_type, yes, &config.yay_arguments()),
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(&sudo, run_type, yes),
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type, yes),
Distribution::Gentoo => upgrade_gentoo(&sudo, run_type),
Distribution::Suse => upgrade_suse(&sudo, run_type),
@@ -302,6 +305,19 @@ fn upgrade_solus(sudo: &Option<PathBuf>, run_type: RunType) -> Result<(), Error>
Ok(())
}
fn upgrade_clearlinux(sudo: &Option<PathBuf>, run_type: RunType) -> Result<(), Error> {
if let Some(sudo) = &sudo {
run_type
.execute(&sudo)
.args(&["/usr/bin/swupd", "update"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
fn upgrade_exherbo(sudo: &Option<PathBuf>, cleanup: bool, run_type: RunType) -> Result<(), Error> {
if let Some(sudo) = &sudo {
run_type.execute(&sudo).args(&["/usr/bin/cave", "sync"]).check_run()?;
@@ -462,6 +478,11 @@ mod tests {
test_template(&include_str!("os_release/centos"), Distribution::CentOS);
}
#[test]
fn test_clearlinux() {
test_template(&include_str!("os_release/clearlinux"), Distribution::ClearLinux);
}
#[test]
fn test_debian() {
test_template(&include_str!("os_release/debian"), Distribution::Debian);

View File

@@ -0,0 +1,11 @@
NAME="Clear Linux OS"
VERSION=1
ID=clear-linux-os
ID_LIKE=clear-linux-os
VERSION_ID=31620
PRETTY_NAME="Clear Linux OS"
ANSI_COLOR="1;35"
HOME_URL="https://clearlinux.org"
SUPPORT_URL="https://clearlinux.org"
BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
PRIVACY_POLICY_URL="http://www.intel.com/privacy"