The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Linux::Info::Distribution::OSRelease - a subclass with data from /etc/os-release file

VERSION

version 2.11

SYNOPSIS

    use Linux::Info::Distribution::OSRelease;
    my $os = Linux::Info::Distribution::OSRelease->new;

    # fetch the default file location
    print Linux::Info::Distribution::OSRelease::DEFAULT_FILE, "\n";

DESCRIPTION

This is a subclass of Linux::Info::Distribution, which data is retrieved by reading the standard /etc/os-release file, which usually provides more fields than custom files.

Such file might contain only the minimal informatior required by the base class, but most probably will provide more fields.

    NAME="Ubuntu"
    VERSION_ID="22.04"
    VERSION="22.04.4 LTS (Jammy Jellyfish)"
    ID=ubuntu

This classes provides a parser to retrieve those fields and more from the default location or any other provided.

METHODS

parse

A class method, i.e., doesn't require a instance to be invoked.

Optionally, accepts a file path to the different file insteade using the default one.

Returns a hash reference, with all fields/values retrieve from the file.

The fields, stored as keys, will be forced to be on lowercase.

parse

Instance method. Parses a file with the expected format of /etc/os-release.

parse_from_file

Class method. Parses a file with the expected format of /etc/os-release.

Optionally, accepts a string as the complete path to a file to be parsed.

new

Creates and returns a new instance.

Expects the same optional parameter of parse, and uses this same method to parse the file content.

clean_cache

This class caches the information read from the source file into memory, so subclasses can reuse this information to handle additional attributes.

After that, the information is usually and should be removed by invoking this method.

get_source

Returns a string with the file path from where the information was retrieved.

get_pretty_name

Returns the "pretty" name of distribution, which is actually just a longer string than the name.

get_id_like

Returns an array reference containing the distribution ID of all distributions directly related to this one (a parent distribution, or siblings).

Not all distributions will have such value, but a default empty array will be provided by this class.

get_home_url

Returns the home URL of distribution.

EXPORTS

Nothing.

The default location of the source file can be retrieved with the DEFAULT_FILE constant.

AUTHOR

Alceu Rodrigues de Freitas Junior <glasswalk3r@yahoo.com.br>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Alceu Rodrigues de Freitas Junior.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007