Sys-OsRelease

helper library in Perl for reading OS info from FreeDesktop.Org-standard /etc/os-release file

NAME

Sys::OsRelease - read operating system details from standard /etc/os-release file

SYNOPSIS

non-object-oriented:

Sys::OsRelease->init();
my $id = Sys::OsRelease->id();
my $id_like = Sys::OsRelease->id_like();

object-oriented:

my $osrelease = Sys::OsRelease->instance();
my $id = $osrelease->id();
my $id_like = $osrelease->id_like();

DESCRIPTION

Sys::OsRelease is a helper library to read the /etc/os-release file, as defined by FreeDesktop.Org. The os-release file is used to define an operating system environment, in widespread use among Linux distributions since 2017 and BSD variants since 2020. It was started on Linux systems which use the systemd software, but then spread to other Linux, BSD and Unix-based systems. Its purpose is to identify the system to any software which needs to know. It differentiates between Unix-based operating systems and even between Linux distributions.

Sys::OsRelease is implemented with a singleton model, meaning there is only one instance of the class. Instead of instantiating an object with new(), the instance() class method returns the one and only instance. The first time it's called, it instantiates it. On following calls, it returns a reference to the singleton instance.

This module maintains minimal prerequisites, and only those which are usually included with Perl. (Suggestions of new features and code will largely depend on following this rule.) That is intended to be acceptable for establishing system or container environments which contain Perl programs. It can also be used for installing or configuring software that needs to know about the system environment.

The os-release Standard

FreeDesktop.Org's os-release standard is at https://www.freedesktop.org/software/systemd/man/os-release.html.

Current attributes recognized by Sys::OsRelease are: NAME ID ID_LIKE PRETTY_NAME CPE_NAME VARIANT VARIANT_ID VERSION VERSION_ID VERSION_CODENAME BUILD_ID IMAGE_ID IMAGE_VERSION HOME_URL DOCUMENTATION_URL SUPPORT_URL BUG_REPORT_URL PRIVACY_POLICY_URL LOGO ANSI_COLOR DEFAULT_HOSTNAME SYSEXT_LEVEL

If other attributes are found in the os-release file, they will be honored. Folded to lower case, the attribute names are used as keys in an internal hash structure.

METHODS

SEE ALSO

FreeDesktop.Org's os-release standard: https://www.freedesktop.org/software/systemd/man/os-release.html

GitHub repository for Sys::OsRelease: https://github.com/ikluft/Sys-OsRelease

BUGS AND LIMITATIONS

Please report bugs via GitHub at https://github.com/ikluft/Sys-OsRelease/issues

Patches and enhancements may be submitted via a pull request at https://github.com/ikluft/Sys-OsRelease/pulls

LICENSE INFORMATION

Copyright (c) 2022 by Ian Kluft

This module is distributed in the hope that it will be useful, but it is provided “as is” and without any express or implied warranties. For details, see the full text of the license in the file LICENSE or at https://www.perlfoundation.org/artistic-license-20.html.