37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
namespace StellaOps.DistroIntel;
|
|
|
|
public static partial class DistroMappings
|
|
{
|
|
/// <summary>
|
|
/// Checks if a distro is a known canonical (parent) distro.
|
|
/// </summary>
|
|
/// <param name="distro">The distro identifier to check.</param>
|
|
/// <returns>True if the distro is a known canonical distro.</returns>
|
|
public static bool IsCanonicalDistro(string distro)
|
|
{
|
|
var lower = distro.ToLowerInvariant();
|
|
return lower is "rhel" or "debian" or "ubuntu" or "sles" or "alpine";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Normalizes a distro name to its canonical form.
|
|
/// </summary>
|
|
/// <param name="distro">The distro name to normalize.</param>
|
|
/// <returns>Lowercase canonical form.</returns>
|
|
public static string NormalizeDistroName(string distro)
|
|
{
|
|
var lower = distro.ToLowerInvariant();
|
|
return lower switch
|
|
{
|
|
"redhat" or "red hat" or "red-hat" => "rhel",
|
|
"alma" or "almalinux-os" => "almalinux",
|
|
"rockylinux" or "rocky-linux" => "rocky",
|
|
"oracle linux" or "oraclelinux" => "oracle",
|
|
"opensuse" or "opensuse-tumbleweed" => "opensuse-leap",
|
|
"mint" => "linuxmint",
|
|
"popos" or "pop_os" => "pop",
|
|
_ => lower
|
|
};
|
|
}
|
|
}
|