osdistro

package
v0.0.0-...-f12bd69 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OSReleaseFile    = "/etc/os-release"
	OSReleaseFileNew = "/usr/lib/os-release"
	LSBReleaseFile   = "/etc/lsb-release"
	IssueFile        = "/etc/issue"
	IssueNetFile     = "/etc/issue.net"

	DebianVersionFile         = "/etc/debian_version"
	RedhatReleaseFile         = "/etc/redhat-release"
	CentosReleaseFile         = "/etc/centos-release"
	FedoraReleaseFile         = "/etc/fedora-release"
	OracleReleaseFile         = "/etc/oracle-release"
	SystemReleaseFile         = "/etc/system-release"     // Redhat/Centos/Fedora/Rocky/Alma/AmazonLinux/Oracle
	SystemReleaseCPEFile      = "/etc/system-release-cpe" // Redhat/Centos/Fedora/Rocky/Alma/AmazonLinux/Oracle
	RockyReleaseFile          = "/etc/rocky-release"
	RockyReleaseUpstream      = "/etc/rocky-release-upstream"
	AmazonLinuxReleaseFile    = "/etc/amazon-linux-release"
	AmazonLinuxReleaseCPEFile = "/etc/amazon-linux-release-cpe"
	AlpineReleaseFile         = "/etc/alpine-release" //only version number
	ArchReleaseFile           = "/etc/arch-release"   //can be empty
	SuseReleaseFile           = "/etc/SuSE-release"   //depricated
	SuseBrandFile             = "/etc/SUSE-brand"
	GentooReleaseFile         = "/etc/gentoo-release"
	SlackwareVersionFile      = "/etc/slackware-version"
	NixOSInfoFile             = "/etc/NIXOS"
)

Data file names

View Source
const (
	DebianID   = "debian"
	DebianName = "Debian GNU/Linux"

	UbuntuID   = "ubuntu"
	UbuntuName = "Ubuntu"

	FedoraID   = "fedora"
	FedoraName = "Fedora Linux"

	RedhatID   = "rhel"
	RedhatName = "Red Hat Enterprise Linux"

	CentosID   = "centos"
	CentosName = "CentOS Linux"

	RockyLinuxID   = "rocky"
	RockyLinuxName = "Rocky Linux"

	AlmaLinuxID   = "almalinux" //can be in double quotes
	AlmaLinuxName = "AlmaLinux"

	AmazonLinuxID   = "amzn" //can be in double quotes
	AmazonLinuxName = "Amazon Linux"

	OracleLinuxID   = "ol" //can be in double quotes
	OracleLinuxName = "Oracle Linux Server"

	AlpineID   = "alpine"
	AlpineName = "Alpine Linux"

	ArchID   = "arch"
	ArchName = "Arch Linux"

	WolfiID   = "wolfi" //base wolfi images and Chainguard images
	WolfiName = "Wolfi"

	ClearLinuxID   = "clear-linux-os"
	ClearLinuxName = "Clear Linux OS"

	GentooID   = "gentoo"
	GentooName = "Gentoo"

	SlackwareID   = "slackware"
	SlackwareName = "Slackware"

	OpenSuseID   = "opensuse" //need to do a "contains" check (e.g., to match "opensuse-leap")
	OpenSuseName = "openSUSE"

	SlesID   = "sles" //could be in double quotes (need to strip double quotes if present)
	SlesName = "SLES" //SUSE Linux Enterprise Server

	BottlerocketID   = "bottlerocket"
	BottlerocketName = "Bottlerocket"

	FlatcarID   = "flatcar"
	FlatcarName = "Flatcar Container Linux by Kinvolk"

	CoreosID   = "coreos"
	CoreosName = "Container Linux by CoreOS"

	NixosID   = "nixos"
	NixosName = "NixOS"
)

Linux distro IDs and names

Variables

A map of distro info files (todo: add a list of distros where the files are used)

Functions

func IsDataFile

func IsDataFile(filePath string) bool

func IsKnownDistro

func IsKnownDistro(id string) bool

func IsOSReleaseFile

func IsOSReleaseFile(filePath string) bool

Types

type OsRelease

type OsRelease struct {
	AnsiColor    string `osr:"ANSI_COLOR"`
	Name         string `osr:"NAME"`
	Version      string `osr:"VERSION"`
	Variant      string `osr:"VARIANT"`
	VariantID    string `osr:"VARIANT_ID"`
	ID           string `osr:"ID"`
	IDLike       string `osr:"ID_LIKE"`
	PrettyName   string `osr:"PRETTY_NAME"`
	VersionID    string `osr:"VERSION_ID"`
	HomeURL      string `osr:"HOME_URL"`
	SupportURL   string `osr:"SUPPORT_URL"`
	BugReportURL string `osr:"BUG_REPORT_URL"`
}

OsRelease reflects values in /etc/os-release Values in this struct must always be string or the reflection will not work properly.

func NewOsRelease

func NewOsRelease(contents []byte) (*OsRelease, error)

func (*OsRelease) ParseOsRelease

func (osr *OsRelease) ParseOsRelease(osReleaseContents []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL