Skip to content

Commit

Permalink
Merge pull request #340 from kholmanskikh/add-alpaquita-linux
Browse files Browse the repository at this point in the history
Add Alpaquita Linux
  • Loading branch information
stanislav-tkach committed Mar 19, 2023
2 parents 4114330 + 24fcc88 commit 5fbb59c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ os_info --help

Right now, the following operating system types can be returned:

- Alpaquita Linux
- Alpine Linux
- Amazon Linux AMI
- Android
Expand Down
1 change: 1 addition & 0 deletions os_info/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ mod tests {
fn with_type() {
let types = [
Type::Redox,
Type::Alpaquita,
Type::Alpine,
Type::Amazon,
Type::Android,
Expand Down
12 changes: 12 additions & 0 deletions os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
// https://github.com/chef/os_release

//"almalinux" => Alma
"alpaquita" => Some(Type::Alpaquita),
"alpine" => Some(Type::Alpine),
"amzn" => Some(Type::Amazon),
//"antergos" => Antergos
Expand Down Expand Up @@ -198,6 +199,17 @@ mod tests {
use super::*;
use pretty_assertions::assert_eq;

#[test]
fn alpaquita_os_release() {
let root = "src/linux/tests/Alpaquita";

let info = retrieve(&DISTRIBUTIONS, root).unwrap();
assert_eq!(info.os_type(), Type::Alpaquita);
assert_eq!(info.version, Version::Semantic(23, 0, 0));
assert_eq!(info.edition, None);
assert_eq!(info.codename, None);
}

#[test]
fn alpine_3_12_os_release() {
let root = "src/linux/tests/Alpine_3_12";
Expand Down
16 changes: 16 additions & 0 deletions os_info/src/linux/lsb_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn get() -> Option<Info> {
};

let os_type = match release.distribution.as_ref().map(String::as_ref) {
Some("Alpaquita") => Type::Alpaquita,
Some("Amazon") | Some("AmazonAMI") => Type::Amazon,
Some("Arch") => Type::Arch,
Some("Artix") => Type::Artix,
Expand Down Expand Up @@ -112,6 +113,14 @@ mod tests {
assert_eq!(parse_results.codename, Some("wheezy".to_string()));
}

#[test]
fn alpaquita() {
let parse_results = parse(alpaquita_file());
assert_eq!(parse_results.distribution, Some("Alpaquita".to_string()));
assert_eq!(parse_results.version, Some("23".to_string()));
assert_eq!(parse_results.codename, None);
}

#[test]
fn arch() {
let parse_results = parse(arch_file());
Expand Down Expand Up @@ -308,6 +317,13 @@ mod tests {
"
}

fn alpaquita_file() -> &'static str {
"\nDistributor ID: Alpaquita\n\
Description: BellSoft Alpaquita Linux Stream 23 (musl)\n\
Release: 23\n\
Codename: n/a"
}

fn arch_file() -> &'static str {
"\nLSB Version: 1.4\n\
Distributor ID: Arch\n\
Expand Down
3 changes: 2 additions & 1 deletion os_info/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ mod tests {
fn os_type() {
let version = current_platform();
match version.os_type() {
Type::Alpine
Type::Alpaquita
| Type::Alpine
| Type::Amazon
| Type::Arch
| Type::Artix
Expand Down
8 changes: 8 additions & 0 deletions os_info/src/linux/tests/Alpaquita/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NAME="BellSoft Alpaquita Linux Stream"
ID=alpaquita
ID_LIKE=alpine
VERSION_ID=23
PRETTY_NAME="BellSoft Alpaquita Linux Stream 23 (musl)"
HOME_URL="https://bell-sw.com/"
BUG_REPORT_URL="https://bell-sw.com/support/"
LIBC_TYPE=musl
4 changes: 4 additions & 0 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::fmt::{self, Display, Formatter};
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
#[non_exhaustive]
pub enum Type {
/// Alpaquita Linux (<https://bell-sw.com/alpaquita-linux/>).
Alpaquita,
/// Alpine Linux (<https://en.wikipedia.org/wiki/Alpine_Linux>).
Alpine,
/// Amazon Linux AMI (<https://en.wikipedia.org/wiki/Amazon_Machine_Image#Amazon_Linux_AMI>).
Expand Down Expand Up @@ -97,6 +99,7 @@ impl Default for Type {
impl Display for Type {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
Type::Alpaquita => write!(f, "Alpaquita Linux"),
Type::Alpine => write!(f, "Alpine Linux"),
Type::Amazon => write!(f, "Amazon Linux AMI"),
Type::Arch => write!(f, "Arch Linux"),
Expand Down Expand Up @@ -130,6 +133,7 @@ mod tests {
#[test]
fn display() {
let data = [
(Type::Alpaquita, "Alpaquita Linux"),
(Type::Alpine, "Alpine Linux"),
(Type::Amazon, "Amazon Linux AMI"),
(Type::Android, "Android"),
Expand Down

0 comments on commit 5fbb59c

Please sign in to comment.