Fix detection of OpenSUSE (fix #219)
This commit is contained in:
@@ -37,21 +37,29 @@ impl Distribution {
|
|||||||
fn parse_os_release(os_release: &ini::Ini) -> Result<Self, Error> {
|
fn parse_os_release(os_release: &ini::Ini) -> Result<Self, Error> {
|
||||||
let section = os_release.general_section();
|
let section = os_release.general_section();
|
||||||
let id = section.get("ID").map(String::as_str);
|
let id = section.get("ID").map(String::as_str);
|
||||||
let id_like = section.get("ID_LIKE").map(String::as_str);
|
let id_like: Option<Vec<&str>> = section
|
||||||
Ok(match (id, id_like) {
|
.get("ID_LIKE")
|
||||||
(Some("debian"), _) | (_, Some("debian")) | (_, Some("ubuntu")) => Distribution::Debian,
|
.map(|s| String::as_str(s).split_whitespace().collect());
|
||||||
(_, Some("suse")) => Distribution::Suse,
|
|
||||||
(Some("arch"), _)
|
if let Some(id_like) = id_like {
|
||||||
| (Some("arch32"), _)
|
if id_like.contains(&"debian") || id_like.contains(&"ubuntu") {
|
||||||
| (_, Some("archlinux"))
|
return Ok(Distribution::Debian);
|
||||||
| (_, Some("arch"))
|
} else if id_like.contains(&"suse") {
|
||||||
| (_, Some("anarchylinux")) => Distribution::Arch,
|
return Ok(Distribution::Suse);
|
||||||
(Some("centos"), _) | (Some("ol"), _) => Distribution::CentOS,
|
} else if id_like.contains(&"arch") || id_like.contains(&"archlinux") {
|
||||||
(Some("fedora"), _) => Distribution::Fedora,
|
return Ok(Distribution::Arch);
|
||||||
(Some("void"), _) => Distribution::Void,
|
}
|
||||||
(Some("solus"), _) => Distribution::Solus,
|
}
|
||||||
(Some("gentoo"), _) => Distribution::Gentoo,
|
|
||||||
(Some("exherbo"), _) => Distribution::Exherbo,
|
Ok(match id {
|
||||||
|
Some("centos") | Some("ol") => Distribution::CentOS,
|
||||||
|
Some("fedora") => Distribution::Fedora,
|
||||||
|
Some("void") => Distribution::Void,
|
||||||
|
Some("debian") => Distribution::Debian,
|
||||||
|
Some("arch") | Some("anarchy") => Distribution::Arch,
|
||||||
|
Some("solus") => Distribution::Solus,
|
||||||
|
Some("gentoo") => Distribution::Gentoo,
|
||||||
|
Some("exherbo") => Distribution::Exherbo,
|
||||||
_ => Err(ErrorKind::UnknownLinuxDistribution)?,
|
_ => Err(ErrorKind::UnknownLinuxDistribution)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
NAME="openSUSE Leap"
|
NAME="openSUSE Leap"
|
||||||
VERSION="42.3"
|
VERSION="15.1 "
|
||||||
ID=opensuse
|
ID="opensuse-leap"
|
||||||
ID_LIKE="suse"
|
ID_LIKE="suse opensuse"
|
||||||
VERSION_ID="42.3"
|
VERSION_ID="15.1"
|
||||||
PRETTY_NAME="openSUSE Leap 42.3"
|
PRETTY_NAME="openSUSE Leap 15.1"
|
||||||
ANSI_COLOR="0;32"
|
ANSI_COLOR="0;32"
|
||||||
CPE_NAME="cpe:/o:opensuse:leap:42.3"
|
CPE_NAME="cpe:/o:opensuse:leap:15.1"
|
||||||
BUG_REPORT_URL="https://bugs.opensuse.org"
|
BUG_REPORT_URL="https://bugs.opensuse.org"
|
||||||
HOME_URL="https://www.opensuse.org/"
|
HOME_URL="https://www.opensuse.org"
|
||||||
|
|||||||
Reference in New Issue
Block a user