Bootloader::Library(3)

NAME
Bootloader::Library - library for accessing configuration of the bootloader

PREFACE
This package is the public API to configure bootloader settings

SYNOPSIS
"use Bootloader::Library;"

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

"$status = Bootloader::Library->Initialize ($bootloader);"

"$status = Bootloader::Library->DefineMountPoints (\%mountpoints);"

"$status = Bootloader::Library->DefinePartitions (\@partitions);"

"$status = Bootloader::Library->DefineMDArrays (\%md_arrays);"

"$status = Bootloader::Library->ReadSettings ();" // FIXME ?? sysconfig ??

"$status = Bootloader::Library->WriteSettings ();"

"$status = Bootloader::Library->ReadSettingsTmp ($tmp_dir);"

"$status = Bootloader::Library->WriteSettingsTmp ($tmp_dir);"

"$files_contents_ref = Bootloader::Library->GetFilesContents ();"

"$status = Bootloader::Library->SetFilesContents (\%files_contents);"

"$status = Bootloader::Library->UpdateBootloader ();"

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

"$file_list_ref = Bootloader::Library->ListConfigurationFiles ();"

"$settings_ref = Bootloader::Library->GetSettings ();"

"$status Bootloader::Library->SetSettings ($settings_ref);"

"$sections_ref = Bootloader::Library->GetSections ();"

"$global_ref = Bootloader::Library->GetGlobalSettings ();"

"$device_map_ref = Bootloader::Library->GetDeviceMapping ();"

"$status = Bootloader::Library->SetSections ($sections_ref);"

"$status = Bootloader::Library->SetGlobalSettings ($global_settings_ref);"

"$status = Bootloader::Library->SetDeviceMapping ($device_map_ref);"

DESCRIPTION

"$obj_ref = Bootloader::Library->new ();"
    Creates an instance of the Bootloader::Library class.

"$status = Bootloader::Library->Initialize ($bootloader);"
    Initializes the library for the particular bootloader. Takes the name of the bootloader as parameter. Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $status = Bootloader::Library->Initialize ("lilo");
      if (! defined ($status))
      {
        die "Error occurred while initalizing for LILO";
      }

"$status = Bootloader::Library->DefineMountPoints (\%mountpoints);"
    Defines mount points in the system so that the library needn't probe them itself when needed. Parameter (mountpoints) is a hash reference (key is mountpoint, value device). Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $mp = {
        "/" => "/dev/hda3",
        "/boot" => "/dev/hda1",
      }
      Bootloader::Library->DefineMountPoints ($mp);

"$status = Bootloader::Library->DefinePartitions (\@partitions);"
    Defines the information about partitions - what disk a partition belongs to and the number of the partition Parameter (partitions) is a list, one entry per partition, each entry is a 3-item list, containing the device of the partition, the device of the disk the partition belongs to, and the number of the partition (first is 1). Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $part = [
        [ "/dev/hda1", "/dev/hda", 1],
        [ "/dev/hda3", "/dev/hda", 3]
      ];
      Bootloader::Library->DefinePartitions ($part);

"$status = Bootloader::Library->DefineMDArrays (\%md_arrays);"
    Defines the information about MD RAID arrays (what array is built by what disks). As parameter, it takes a reference to a map of all MD devices, where key is the MD device name, and value a reference to a list of its members. Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $md = {
        "/dev/md0" => ["/dev/hda1", "/dev/hdc1"],
        "/dev/md1" => ["/dev/hda2", "/dev/hdc2"],
      };
      Bootloader::Library->DefineMDArrays ($md);

"$status = Bootloader::Library->ReadSettings ();"
    Reads the settings from the system Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $status = Bootloader::Library->ReadSettings ();
      if (! defined ($status))
      {
        die "Error occurred while reading the settings";
      }

"$status = Bootloader::Library->WriteSettings ();"
    Writes the settings to the system. Doesn't activate the bootloader or the written settings, InitializeBootloader or UpdateBootloader functions must be used for it. Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $status = Bootloader::Library->WriteSettings ();
      if (! defined ($status))
      {
        die "Error occurred while writing the settings";
      }

"$status = Bootloader::Library->ReadSettingsTmp ($tmp_dir);"
    Reads the settings from the Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $status = Bootloader::Library->ReadSettingsTmp ("/tmp");
      if (! defined ($status))
      {
        die "Error occurred while reading the settings";
      }

"$status = Bootloader::Library->WriteSettingsTmp ($tmp_dir);"
    Writes the settings to temporary directory. Slashes in the filename are replaced with underscores. Returns undef on fail, defined nonzero value otherwise.

    EXAMPLE:

      my $status = Bootloader::Library->WriteSettingsTmp ("/tmp");
      if (! defined ($status))
      {
        die "Error occurred while writing the settings";
      }

"$files_contents_ref = Bootloader::Library->GetFilesContents ();"
    Gets the future contents of all bootloader configuration files. Returns undef on fail, hash where key is file name and value its contents as value on success.

    EXAMPLE:

      my $files_contents_ref = Bootloader::Library->GetFilesContents ();
      if (! defined ($files_contents_ref))
      {
        die "Cannot get the contents of the configuration files"
      }
      my $lilo_conf = $files_contents_ref->{"/etc/lilo.conf"};
      print "$lilo.conf contents: \n$lilo_conf\n";

"$status = Bootloader::Library->SetFilesContents (\%files_contents);"
    Sets the contents of all configuration files (eg. from editor)

    $status = Bootloader::Library->SetFilesContents (\%files_contents);

"$status = Bootloader::Library->UpdateBootloader ();"
    Really updates the bootloader configuration after writing the settings Returns undef on fail, defined nonzero value otherwise

    EXAMPLE:

      my $status = Bootloader::Library->UpdateBootloader ();
      if (! defined ($status))
      {
        die "Connot update the bootloader configuration";
      }

"$status = Bootloader::Library->InitializeBootloader ();"
    Initializes the firmware to boot the bootloader Returns undef on fail, defined nonzero value otherwise

    EXAMPLE:

      my $status = Bootloader::Library->InitializeBootloader ();
      if (! defined ($status))
      {
        die "Connot initialize the bootloader";
      }

"$files_ref = Bootloader::Library->ListConfigurationFiles ();"
    Returns the list of the configuration files of the bootloader Returns undef on fail

    EXAMPLE:

      my $files_ref = Bootloader::Library->ListConfigurationFiles ();
      if (! defined ($files_ref))
      {
        die "Cannot list configuration files";
      }
      foreach my $fn (@{$files_ref})
      {
        system ("cp $fn $fn.backup");
      }

"$sections_ref = Bootloader::Library->GetSettings ();"
    Returns the complete settings of the bootloader. Returns undef on fail.

    EXAMPLE:

      see eg. GetSections function definition

"$status = Bootloader::Library->SetSettings ();"
    Returns the complete settings of the bootloader. Returns undef on fail.

    EXAMPLE:

      see eg. GetSections function definition

"$sections_ref = Bootloader::Library->GetSections ();"
    Gets the sections of the bootloader. See section description above. TODO Returns undef on fail.

    EXAMPLE:

      my $sections_ref = Bootloader::Library->GetSections ();
      if (! defined ($sections_ref))
      {
        die "Getting sections failed";
      }
      my @sect_names = map {
        $_->{"name"};
      } @{$sections_ref};
      my $list = join ", " @sect_names;
      print "Sections: $list";

"$global_ref = Bootloader::Library->GetGlobalSettings ();"
    Gets the global settings of the bootloader. See the example map above TODO Returns undef on fail.

    EXAMPLE:

      my $global_ref = Bootloader::Library->GetGlobalSettings ();
      if (! defined ($global_ref))
      {
        die "Getting global data failed";
      }
      my $default = $global_ref->{"default"};
      print "Default section: $default";

"$device_map_ref = Bootloader::Library->GetDeviceMapping ();"
    Gets the device mapping between Linux and firmware. Returns undef on fail.

    EXAMPLE:

      $device_map_ref = Bootloader::Library->GetDeviceMapping ();
      if (! defined ($device_map_ref))
      {
        die "Getting device mapping failed";
      }
      my $hda = $device_map_ref->{"/dev/hda"};
      print "/dev/hda is $hda";

"$status = Bootloader::Library->SetSections ();"
    Sets the sections of the bootloader. Sections have the same format as return value of GetSections (). Returns undef on fail, defined nonzero value on success.

    EXAMPLE:

      my $sections_ref = Bootloader::Library->GetSections ();
      if (! defined ($sections_ref))
      {
        die "Getting sections failed";
      }
      my @sections = @{$sections_ref};
      pop @sections;
      my $ret = Bootloader::Library->SetSections (\@sections);
      if (! defined ($ret))
      {
        print ("Setting sections failed");
      }

"$status = Bootloader::Library->SetGlobalSettings ();"
    Sets the global settings of the bootloader. The argument has the same format as the return value of GetGlobalSettings (). Returns undef on fail, defined nonzero value on success.

    EXAMPLE:

      my $global_ref = Bootloader::Library->GetGlobalSettings ();
      if (! defined ($global_ref))
      {
        die "Getting global data failed";
      }
      $global_ref->{"default"} = "linux";
      my $ret = Bootloader::Library->SetGlobalSettings ($global_ref);
      if (! defined ($ret))
      {
        print ("Setting global options failed.");
      }

"$status = Bootloader::Library->SetDeviceMapping ();"
    Sets the device mapping between Linux device and firmware identification. Returns undef on fail, defined nonzero value on success.

    EXAMPLE:

      $device_map_ref = Bootloader::Library->GetDeviceMapping ();
      if (! defined ($device_map_ref))
      {
        die "Getting device mapping failed";
      }
      $device_map_ref->{"/dev/hda"} = "(hd0)";
      my $ret = Bootloader::Library->SetDeviceMapping ($device_map_ref);
      if (! defined ($ret))
      {
        print ("Setting global options failed.");
      }