Skip to content

Commit

Permalink
Add Alpaquita Linux
Browse files Browse the repository at this point in the history
The distro does not ship LSB utils, so the LSB code path
was tested with a manually built version of lsb-release-minimal
from https://salsa.debian.org/gioele/lsb-release-minimal
  • Loading branch information
kholmanskikh committed Mar 1, 2023
1 parent 39c38f3 commit 24fcc88
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
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
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
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
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("CentOS") => Type::CentOS,
Expand Down Expand Up @@ -111,6 +112,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 @@ -299,6 +308,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
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::CentOS
Expand Down
8 changes: 8 additions & 0 deletions os_info/src/linux/tests/Alpaquita/etc/os-release
@@ -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
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 @@ -95,6 +97,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 @@ -127,6 +130,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 24fcc88

Please sign in to comment.