Rechercher une page de manuel
Bootloader::Tools.3pm
Langue: en
Version: 2007-09-26 (openSuse - 09/10/07)
Section: 3 (Bibliothèques de fonctions)
Sommaire
NAME
Bootloader::Tools - set of high-level bootloader configuration functionsPREFACE
This package contains a set of high-level bootloader configuration functionsSYNOPSIS
"use Bootloader::Tools;""$mp_ref = Bootloader::Tools::ReadMountPoints ();"
"$part_ref = Bootloader::Tools::ReadPartitions ();"
"$numDM = Bootloader::Tools::DMRaidAvailable ();"
"$part_ref = Bootloader::Tools::ReadDMRaidPartitions ();"
"$part_ref = Bootloader::Tools::ReadDMRaidDisks ();"
"Bootloader::Tools::IsDMRaidSlave ($kernel_disk);"
"Bootloader::Tools::IsDMDevice($dev);"
"$dm_dev = Bootloader::Udev2DMDev($udevdevice);"
"$udev_dev = Bootloader::Tools::DMDev2Udev($dmdev);"
"$majmin = Bootloader::Tools::DMDev2MajMin($dmdev);"
"$majmin = Bootloader::Tools::Udev2MajMin($udev);"
"$udev_dev = Bootloader::Tools::MajMin2Udev($majmin);"
"$dm_dev = Bootloader::Tools::MajMin2DMDev($majmin);"
"$md_ref = Bootloader::Tools::ReadRAID1Arrays ();"
"$loader = Bootloader::Tools::GetBootloader ();"
"Bootloader::Tools::InitLibrary ();"
"Bootloader::Tools::CountImageSections ($image);"
"Bootloader::Tools::RemoveImageSections ($image);"
"Bootloader::Tools::GetSystemLanguage ();"
"Bootloader::Tools::GetDefaultSection ();"
"Bootloader::Tools::GetDefaultImage ();"
"Bootloader::Tools::GetDefaultInitrd ();"
"Bootloader::Tools::GetGlobals();"
"Bootloader::Tools::SetGlobals(@params);"
"Bootloader::Tools::GetSectionList(@selectors);"
"Bootloader::Tools::GetSection($name);"
"Bootloader::Tools::AdaptCommentLine($old_sections_ref, $original_name);"
"Bootloader::Tools::AddSection($name, @params);"
"Bootloader::Tools::RemoveSections($name);"
"$exec_with_path = Bootloader::Tools::AddPathToExecutable($executable);"
DESCRIPTION
- $mp_ref = Bootloader::Tools::ReadMountPoints ();
- reads the information about mountpoints in the system. The returned data is needed to initialize the bootloader library properly.
See InitLibrary function for example.
- $part_ref = Bootloader::Tools::ReadPartitions ();
- reads the information about disk partitions. This data is needed to initialize the bootloader library properly.
See InitLibrary function for example.
- Bootloader::Tools::DMRaidAvailable ();
- Tests wether DMRAID is available. Return 0 if no device, 1 if there are any.
- $part_ref = Bootloader::Tools::ReadDMRaidPartitions ();
- reads partitions belonging to a Devicemapper RAID device. needed to be able to put get the correct translation into Grub notation DMRaid Devices look like: dmraid-<strange name>
DMRaid Partitions look like: partX-dmraid-<strange name>
- $part_ref = Bootloader::Tools::ReadDMRaidDisks ();
- returns a refenrence to a list of DMRaid devices
- Bootloader::Tools::IsDMRaidSlave ($kernel_disk);
- checks wether a kernel_device is part of a DMRAID returns 1 if yes, 0 if no
- *
- " Bootloader::Tools:IsDMDevice ($device);"
returns 1 if $device is a Devicemapper device, otherwise 0. =cut
sub IsDMDevice {
my $dev = shift;unless (-e $dmsetup) { return 0; }
my $cmd = "$dmsetup info -c --noheadings -oname $dev"; if (my $test = qx{$cmd 2>/dev/null}){ chomp $test;
if ($dev =~ m/$test/){ return 1; } } return 0; }
- $dm_dev = Bootloader::Tools::Udev2DMDev($udevdevice);
- takes a udev device (dm-X) returns the devicemapper device like dmsetup returns
- $udev_dev = Bootloader::Tools::DMDev2Udev($dmdev);
- takes a devicemapper device as reported from dmsetup returns a udev device (dm-X)
- $majmin = Bootloader::Tools::DMDev2MajMin($dmdev);
- takes a devicemapper device as reported from dmsetup returns a string containing major:minor
- $majmin = Bootloader::Tools::Udev2MajMin($udev); takes a udev device as reported from udevinfo returns a string containing major:minor
- $udev_dev = Bootloader::Tools::MajMin2Udev($majmin); takes a string major:minor as reported from udevinfo returns a string containing the udev device as reported by udevinfo
- $dm_dev = Bootloader::Tools::DMDev2MajMin($majmin); takes a string major:minor as reported from udevinfo returns a string containing the device as reported by dmsetup
- $md_ref = Bootloader::Tools::ReadRAID1Arrays ();
- reads the information about disk MD RAID1 arrays. This data is needed to initialize the bootloader library properly.
- $loader = Bootloader::Tools::GetBootloader ();
- returns the used bootloader. Reads the value from sysconfig. Returns the string - bootloader type.
See InitLibrary function for example.
- Bootloader::Tools::InitLibrary ();
- initializes the bootloader configuration library. Fills its internal structures needed for it to run properly.
- Bootloader::Tools::CountImageSections ($image);
- counts sections in the bootolader menu reffering to the specified kernel.
EXAMPLE:
Bootloader::Tools::InitLibrary(); my $count = Bootloader::Tools::CountImageSections ("/boot/vmlinuz-2.6.11"); print "Sections: $count\n";
- Bootloader::Tools::CountSections (@selections);
- # FIXME: add documentation =cut
sub CountSections {
return scalar GetSectionList(@_); } - Bootloader::Tools::UpdateBootloader ();
- Updates the bootloader settings meaning do whatever it takes for the actual bootloader to use the current configuration
- $lang = Bootloader::Tools::GetSystemLanguage ();
- Read the System Language from /etc/sysconfig/language:RC_LANG
EXAMPLE:
my $Lang;
$Lang = Bootloader::Tools::GetSystemLanguage ();setlocale(LC_MESSAGES, $Lang);
- %defaultSelection = Bootloader::Tools::GetDefaultSection ();
- Get the default section, returns a hash reference
EXAMPLE:
my %section;
%section = Bootloader::Tools::GetDefaultSection ();
my $default_kernel = $section{``kernel''}; =cutsub GetDefaultSection {
#Get global Settings
my $glob_ref = $lib_ref->GetGlobalSettings ();if (! defined ($glob_ref)) { die ("GetDefaultSection(): Getting global data failed"); }
# This doesn't return the index of the default section, but the title of it. # All other keys have their real value (eg timeout has 8) my $def = $glob_ref->{"default"};
# $section_ref is a reference to a list of hashes, where the section data is stored my $section_ref = $lib_ref->GetSections ();
if (! defined ($section_ref)) { die ("GetDefaultSection(): Getting sections failed"); }
# get the hash of the default section, identified by key 'name' my @default_sect = grep {$_->{"name"} eq $def} @{$section_ref};
return $default_sect[0]; }
- Bootloader::Tools::GetDefaultImage ();
- Get the kernel name of the default section
EXAMPLE:
my $kernel;
$kernel = Bootloader::Tools::GetDefaultImage ();print("Default Kernel Name: $kernel\n");
- Bootloader::Tools::GetDefaultInitrd ();
- Get the initrd of the default section
EXAMPLE:
my $initrd;
$initrd = Bootloader::Tools::GetDefaultInitrd ();print("Default initrd Name: $initrd\n");
- Bootloader::Tools::GetGlobals(); =cut
- sub GetGlobals() {
return $lib_ref->GetGlobals(); } - Bootloader::Tools::SetGlobals(@params);
- # FIXME: Add documentation =cut sub SetGlobals {
my %option = @_;
my $glob_ref = $lib_ref->GetGlobalSettings();# merge with current, undef values delete options foreach (keys %option) { if (defined $option{$_}) { $glob_ref->{$_} = $option{$_}; } else { delete $glob_ref->{$_}; } } $glob_ref->{"__modified"} = 1; $lib_ref->SetGlobalSettings ($glob_ref); $lib_ref->WriteSettings (1); $lib_ref->UpdateBootloader (1); # avoid initialization but write config to # the right place DumpLog ($lib_ref->{"loader"}); }
- Bootloader::Tools::GetSectionList(@selectors);
- # FIXME: Add documentation =cut
sub GetSectionList {
my %option = @_;
my $loader = GetBootloader ();my $core_lib = $lib_ref->{"loader"};
# FIXME: Maybe activate this part of code later if - against all expectations # - still needed, but this shouldn't happen.
# Examines if image and initrd strings already contain a grub device
# prefix. If it is not the case, attach it. =cut
if ($loader eq ``grub'') { foreach my $key (sort keys %option) {
unless ($option{$key} =~ /^\(hd\d+,\d+\).*$/) {
# In case /boot is resided on an own partition, the function
# UnixPath2GrubPath (in GRUB.pm) doesn't substitute ``/boot''
# with the corresponding grub device, but keeps it.
#
# So the image, kernel and initrd values in the @sections
# array don't contain such a grub device prefix. Thus, to
# match sections to be deleted, a grub device prefix must not
# be attached to the given @option elements.
if ($lib_ref->UnixFile2GrubDev (``/boot'') eq $lib_ref->UnixFile2GrubDev (``/'')){
if ($key eq ``image'' || $key eq ``initrd'' || $key eq ``kernel'') {
my $grub_dev = $lib_ref->UnixFile2GrubDev (``/boot'');
$option{$key} = $grub_dev . $option{$key};
}
}
}
}
} =cutnormalize_options(\%option); my @sections = @{$lib_ref->GetSections ()};
# Print sections from file to logfile $core_lib->l_milestone ("Tools::GetSectionList: sections from file:\n' " . join("'\n' ", map { $_->{"name"}; } @sections) . "'\n" );
my @section_names = map { match_section($_, \%option) ? $_->{"name"} : (); } @sections;
# Print found sections to logfile $core_lib->l_milestone ("Tools::GetSectionList: Found sections:\n' " . join("'\n' ", @section_names) . "'\n" );
DumpLog ($lib_ref->{"loader"}); return @section_names; }
- Bootloader::Tools::GetSection($name);
- # FIXME: Add documentation =cut
sub GetSection {
my $name = shift or return undef;foreach (@{$lib_ref->GetSections ()}) { return $_ if $_->{"name"} eq $name; } return undef; }
- Bootloader::Tools::AdaptCommentLine($old_sections_ref, $original_name);
- Adapt YaST-like comments in already existing sections to be handled correctly by yast2-bootloader. Returns reference to sections array with adapted comment lines.
EXAMPLE:
my $old_sections_ref = $lib_ref->GetSections (); my $adapted_sections_ref = ""; my $original_name = "linux";
$adapted_sections = Bootloader::Tools::AdaptCommentLine ($old_sections_ref, $original_name);
- Bootloader::Tools::AddSection($name, @params);
- Add a new section (boot entry) to config file, e.g. to /boot/grub/menu.lst
EXAMPLE:
my $opt_name = "LabelOfSection"; my @params = (type => $type, image => $opt_image, initrd => $opt_initrd, );
Bootloader::Tools::AddSection ($opt_name, @params);
- Bootloader::Tools::RemoveImageSections ($image);
- removes all sections in the bootloader menu referring to the specified kernel.
EXAMPLE:
Bootloader::Tools::InitLibrary (); Bootloader::Tools::RemoveImageSections ("/boot/vmlinuz-2.6.11"); Bootloader::Tools::UpdateBootloader();
- Bootloader::Tools::RemoveSection($name);
- Bootloader::Tools::AddPathToExecutable ($executable);
- Prepends the corresponding (absolute) path to the given executable and returns the result. If not found in path, function returns undef.
EXAMPLE:
my $executable = "dmsetup";
my $exec_with_path = Bootloader::Tools::AddPathToExecutable ($executable);
if (-e $exec_with_path) { print ("The desired executable is located here: $exec_with_path"); }
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre