Bootloader::Core::PowerLILO.3pm

Langue: en

Version: 2007-09-26 (openSuse - 09/10/07)

Section: 3 (Bibliothèques de fonctions)

NAME

Bootloader::Core::PowerLILO - LILO library for bootloader configuration on POWER

PREFACE

This package is the LILO library of the bootloader configuration on POWER

SYNOPSIS

use Bootloader::Core::PowerLILO;

"$obj_ref = Bootloader::Core::PowerLILO->new ();"

"$files_ref = Bootloader::Core::PowerLILO->ListFiles ();"

"$status = Bootloader::Core::PowerLILO->ParseLines (\%files, $avoid_reading_device_map);"

"$files_ref = Bootloader::Core::PowerLILO->CreateLines ();"

"$status = Bootloader::Core::PowerLILO->UpdateBootloader ($avoid_init);"

"$status = Bootloader::Core::PowerLILO->InitializeBootloader ();"

DESCRIPTION

$obj_ref = Bootloader::Core::PowerLILO->new ();
Creates an instance of the Bootloader::Core::PowerLILO class.
$settings_ref = Bootloader::Core::PowerLILO->GetSettings ();
returns the complete settings in a hash. Does not read the settings from the system, but returns internal structures.
$files_ref = Bootloader::Core::PowerLILO->ListFiles ();
Returns the list of the configuration files of the bootloader Returns undef on fail
$status = Bootloader::Core::PowerLILO->ParseLines (\%files, $avoid_reading_device_map);
Parses the contents of all files and stores the settings in the internal structures. As first argument, it takes a hash reference, where keys are file names and values are references to lists, each member is one line of the file. As second argument, it takes a boolean flag that, if set to a true value, causes it to skip updating the internal device_map information. The latter argument is not used for PowerLILO. Returns undef on fail, defined nonzero value on success.
$files_ref = Bootloader::Core::PowerLILO->CreateLines ();
creates contents of all files from the internal structures. Returns a hash reference in the same format as argument of ParseLines on success, or undef on fail.
$glob_info = $Bootloader::Core->Global2Info (\@glob_lines, \@section_names);
Gets the general information from the global section of the menu file. This information usually means the default section, graphical menu, timeout etc. As argument it takes a reference to the list of hashes representing lines of the section, returns a reference to a hash containing the important information.
$lines_ref = Bootloader::Core->Info2Global (\%section_info, \@section_names);
Takes the info about the global options and uses it to construct the list of lines. The info about global option also contains the original lines. As parameter, takes the section info (reference to a hash) and a list of sectino names, returns the lines (a list of hashes).
$lines_ref = Bootloader::Core->Info2Section (\%section_info, \@section_names);
Takes the info about the section and uses it to construct the list of lines. The info about the section also contains the original lines. As parameter, takes the section info (reference to a hash), returns the lines (a list of hashes). =cut

# list<map<string,any>> Info2Section (map<string,string> info, list<string> section_names) sub Info2Section {
    my $self = shift;
    my %sectinfo = %{+shift};
    my $sect_names_ref = shift;


    my @lines = @{$sectinfo{"__lines"} || []};

    my $type = $sectinfo{"type"} || "";

    my $so = $self->{"exports"}{"section_options"};

    my @lines_new = ();




    # allow to keep the section unchanged

    if (! ($sectinfo{"__modified"} || 0))

    {

        return $self->FixSectionLineOrder (

            \@lines,

            ["image", "other"]);

    }




    $sectinfo{"name"} = $self->FixSectionName ($sectinfo{"name"}, $sect_names_ref);




    foreach my $line_ref (@lines) {

        my $key = $line_ref->{"key"};




        if ($key eq "label")

        {

            $line_ref = $self->UpdateSectionNameLine ($sectinfo{"name"}, $line_ref,

                                                      $sectinfo{"original_name"});

            delete ($sectinfo{"name"});

        }

        elsif (!exists $so->{$type . "_" . $key}) {

            # only accept known section options :-)

            next; 

        }

        else

        {

            next unless defined ($sectinfo{$key});




            $line_ref->{"value"} = $sectinfo{$key};

            delete ($sectinfo{$key});

            my ($stype) = split /:/, $so->{$type . "_" . $key};

            # bool values appear in a config file or not

            if ($stype eq "bool") {

                next if $line_ref->{"value"} ne "true";

                $line_ref->{"value"} = "";

            }

        }




        push @lines_new, $line_ref if defined $line_ref;

    }




    @lines = @lines_new;




    while ((my $key, my $value) = each (%sectinfo))

    {

        if ($key eq "name")

        {

            my $line_ref = $self->UpdateSectionNameLine ($sectinfo{"name"}, {},

                                                         $sectinfo{"original_name"});

            $line_ref->{"key"} = "label";

            push @lines, $line_ref;

        }

        elsif (! exists ($so->{$type . "_" . $key}))

        {

            # only accept known section options :-)

            next;

        }

        else

        {

            my ($stype) = split /:/, $so->{$type . "_" . $key};

            # bool values appear in a config file or not

            if ($stype eq "bool") {

                next if $value ne "true";

                $value = "";

            }




            push @lines, {

                "key" => $key,

                "value" => $value,

            };

        }

    }




    my $ret = $self->FixSectionLineOrder (\@lines,

        ["image", "other"]);




    return $ret;

}



$sectin_info_ref = Bootloader::Core->Section2Info (\@section_lines);
Gets the information about the section. As argument, takes a reference to the list of lines building the section, returns a reference to a hash containing information about the section.
$status = Bootloader::Core::PowerLILO->UpdateBootloader ($avoid_init);
Updates the settings in the system. Backs original configuration files up and replaces them with the ones with the '.new' suffix. Also performs operations needed to make the change effect (run '/sbin/lilo'). Returns undef on fail, defined nonzero value on success.
$status = Bootloader::Core::PowerLILO->InitializeBootloader ();
Initializes the firmware to boot the bootloader. Returns undef on fail, defined nonzero value otherwise