commit perl-Bootloader for openSUSE:Factory

Hello community, here is the log from the commit of package perl-Bootloader for openSUSE:Factory checked in at 2012-04-02 10:30:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Bootloader (Old) and /work/SRC/openSUSE:Factory/.perl-Bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-Bootloader", Maintainer is "snwint@suse.com" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Bootloader/perl-Bootloader.changes 2012-03-20 11:31:29.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Bootloader.new/perl-Bootloader.changes 2012-04-02 10:30:32.000000000 +0200 @@ -1,0 +2,14 @@ +Thu Mar 22 10:30:34 UTC 2012 - mchang@suse.com + +- grub2-kernel-commandline.patch: add kerenl parameters (detected + necessary and user specfied one during installation) to grub2's + config file.(bnc#752939) +- 0.6.1 + +------------------------------------------------------------------- +Thu Mar 22 10:30:33 UTC 2012 - mchang@suse.com + +- grub2-efi-module.patch: add new grub2-efi module to support + booting on UEFI firmware. + +------------------------------------------------------------------- Old: ---- grub2-skip-fs-probe-for-extended-partition.patch perl-Bootloader-0.6.0.tar.bz2 New: ---- perl-Bootloader-0.6.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Bootloader.spec ++++++ --- /var/tmp/diff_new_pack.v3r2wR/_old 2012-04-02 10:30:33.000000000 +0200 +++ /var/tmp/diff_new_pack.v3r2wR/_new 2012-04-02 10:30:33.000000000 +0200 @@ -17,7 +17,7 @@ Name: perl-Bootloader -Version: 0.6.0 +Version: 0.6.1 Release: 0 Requires: perl-base = %{perl_version} Requires: e2fsprogs @@ -29,7 +29,6 @@ Source1: update-bootloader Source2: bootloader_entry Source3: boot.readme -Patch: grub2-skip-fs-probe-for-extended-partition.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl Conflicts: multipath-tools < 0.4.8-40.25.1 @@ -49,7 +48,6 @@ %prep %setup -q -%patch -p1 rm -rf perl-Bootloader-testsuite mkdir -p lib mv src lib/Bootloader ++++++ perl-Bootloader-0.6.0.tar.bz2 -> perl-Bootloader-0.6.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/perl-Bootloader.changes new/perl-Bootloader-0.6.1/perl-Bootloader.changes --- old/perl-Bootloader-0.6.0/perl-Bootloader.changes 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/perl-Bootloader.changes 2012-03-30 11:47:45.000000000 +0200 @@ -1,4 +1,38 @@ ------------------------------------------------------------------- +Thu Mar 22 10:30:34 UTC 2012 - mchang@suse.com + +- grub2-kernel-commandline.patch: add kerenl parameters (detected + necessary and user specfied one during installation) to grub2's + config file.(bnc#752939) +- 0.6.1 + +------------------------------------------------------------------- +Thu Mar 22 10:30:33 UTC 2012 - mchang@suse.com + +- grub2-efi-module.patch: add new grub2-efi module to support + booting on UEFI firmware. + +------------------------------------------------------------------- +Fri Mar 9 08:40:15 UTC 2012 - mchang@suse.com + +- grub2-skip-fs-probe-for-extended-partition.patch (bnc#750897) + +------------------------------------------------------------------- +Mon Mar 5 15:38:44 CET 2012 - snwint@suse.de + +- integrate grub2 patch + +------------------------------------------------------------------- +Wed Feb 15 09:16:19 UTC 2012 - mchang@suse.com + +- add-basic-grub2-module.patch : add basic grub2 support + +------------------------------------------------------------------- +Wed Dec 14 11:06:44 UTC 2011 - coolo@suse.com + +- fix license to be in spdx.org format + +------------------------------------------------------------------- Fri Oct 14 09:31:40 CEST 2011 - snwint@suse.de - support more devices in fallback heuristics diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/perl-Bootloader.spec.in new/perl-Bootloader-0.6.1/perl-Bootloader.spec.in --- old/perl-Bootloader-0.6.0/perl-Bootloader.spec.in 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/perl-Bootloader.spec.in 2012-03-30 11:47:45.000000000 +0200 @@ -18,7 +18,7 @@ Recommends: perl-gettext AutoReqProv: on Group: System/Boot -License: GNU General Public License (GPL) +License: GPL-2.0+ Summary: Library for Configuring Boot Loaders Source: perl-Bootloader-%{version}.tar.bz2 Source1: update-bootloader diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/src/Core/GRUB2.pm new/perl-Bootloader-0.6.1/src/Core/GRUB2.pm --- old/perl-Bootloader-0.6.0/src/Core/GRUB2.pm 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/src/Core/GRUB2.pm 2012-03-30 11:47:45.000000000 +0200 @@ -28,6 +28,10 @@ C<< $settings_ref = Bootloader::Core::GRUB2->GetSettings (); >> +C<< $glob_info = Bootloader::Core::GRUB2->Global2Info (\@glob_lines, \@section_names); >> + +C<< $lines_ref = Bootloader::Core::GRUB2->Info2Global (\%section_info, \@section_names); >> + C<< $status = Bootloader::Core::GRUB2->SetSettings (\%settings); >> C<< $status = Bootloader::Core::GRUB2->InitializeBootloader (); >> @@ -312,7 +316,8 @@ my $self = shift; return [ Bootloader::Path::Grub2_devicemap(), - Bootloader::Path::Grub2_installdevice() ]; + Bootloader::Path::Grub2_installdevice(), + Bootloader::Path::Grub2_defaultconf() ]; } =item @@ -359,8 +364,25 @@ $self->l_milestone ("GRUB2::Parselines: device_map: $unix <-> $fw."); } - my %glob; - my $glob_ref = \%glob; + # and now proceed with /etc/default/grub + my @defaultconf = @{$files{Bootloader::Path::Grub2_defaultconf()} || []}; + $self->l_milestone ("GRUB2::Parselines: input from default conf :\n'" . + join("'\n' ", @defaultconf) . "'"); + + # prefix commented config with '@' instread of '#' + # this is to new notation for "commented config" and + # need to process saparately + foreach my $conf (@defaultconf) { + if ($conf =~ m/^\s*#\s*GRUB_/) { + $conf =~ s/^\s*#/@/; + } + } + + (my $glob_ref, my $sect_ref) = $self->ParseMenuFileLines ( + "=", + [], + \@defaultconf + ); if (not exists $self->{"mountpoints"}{'/'}) { @@ -561,10 +583,32 @@ # map<string,list<string>> CreateLines () sub CreateLines { my $self = shift; + my $global = $self->{"global"}; # first create /etc/default/grub_installdevice my $grub2_installdev = $self->CreateGrubInstalldevLines(); + if (defined $global->{"__lines"}) { + foreach my $line (@{$global->{"__lines"}}) { + if (defined $line->{"value"} && $line->{"value"} eq "" ) { + $line->{"value"} = '""'; + } + } + } + + my $grub2_defaultconf = $self->PrepareMenuFileLines ( + [], + $global, + "", + "=" + ); + + + foreach my $conf (@{$grub2_defaultconf}) { + if ($conf =~ m/^\s*@\s*GRUB_/) { + $conf =~ s/^\s*@/#/; + } + } # TODO: as we know the grub2-install also create device map # I skipped creating them by yast .. @@ -578,11 +622,193 @@ ## } return { Bootloader::Path::Grub2_installdevice() => $grub2_installdev, + Bootloader::Path::Grub2_defaultconf() => $grub2_defaultconf, ## Bootloader::Path::Grub2_devicemap() => \@device_map, } } =item +C<< $glob_info = $Bootloader::Core::GRUB2->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. + +=cut + +# map<string,string> Global2Info (list<map<string,any>> global, list<string>sections) + +sub Global2Info { + my $self = shift; + my @lines = @{+shift}; + my @sections = @{+shift}; + + my %ret = (); + $ret{"__lines"} = \@lines; + + foreach my $line_ref (@lines) { + my $key = $line_ref->{"key"}; + my $val = $line_ref->{"value"}; + + # Check if key is defined to prevent perl warnings + next if (!defined($key)); + + if ($key =~ m/@?GRUB_CMDLINE_LINUX_DEFAULT/) + { + if ($val =~ /^(?:(.*)\s+)?vga=(\S+)(?:\s+(.*))?$/) + { + $ret{"vgamode"} = $2 if $2 ne ""; + $val = $self->MergeIfDefined ($1, $3); + } + + $ret{"append"} = $val; + } + } + + return \%ret; +} + +=item +C<< $lines_ref = Bootloader::Core::GRUB2->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). + +=cut + +# list<map<string,any>> Info2Global (map<string,string> info, list<string>sections) + +sub Info2Global { + my $self = shift; + my %globinfo = %{+shift}; + my $sections_ref = shift; + + my @lines = @{$globinfo{"__lines"} || []}; + + # my $sysconf = Bootloader::Tools::GetSysconfigValue("DEFAULT_APPEND"); + # allow to keep the section unchanged + return \@lines unless $globinfo{"__modified"} || 0; + + if (scalar (@lines) == 0) + { + @lines = ( + { + 'key' => 'GRUB_DISTRIBUTOR', + 'value' => '"openSUSE"', + 'comment_before' => [ + '# If you change this file, run \'grub2-mkconfig -o /boot/grub2/grub.cfg\' afterwards to update', + '# /boot/grub2/grub.cfg.' + ], + }, + { + 'key' => 'GRUB_DEFAULT', + 'value' => '0', + }, + { + 'key' => 'GRUB_HIDDEN_TIMEOUT', + 'value' => '0', + }, + { + 'key' => 'GRUB_HIDDEN_TIMEOUT_QUIET', + 'value' => 'true', + }, + { + 'key' => 'GRUB_TIMEOUT', + 'value' => '10', + }, + { + 'key' => 'GRUB_CMDLINE_LINUX_DEFAULT', + 'value' => 'quiet splash=silent', + }, + { + 'key' => 'GRUB_CMDLINE_LINUX', + 'value' => '""', + }, + { + 'key' => '@GRUB_BADRAM', + 'value' => '"0x01234567,0xfefefefe,0x89abcdef,0xefefefef"', + 'comment_before' => [ + '# Uncomment to enable BadRAM filtering, modify to suit your needs', + '# This works with Linux (no patch required) and with any kernel that obtains', + '# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)' + ], + }, + { + 'key' => '@GRUB_TERMINAL', + 'value' => 'console', + 'comment_before' => [ + '# Uncomment to disable graphical terminal (grub-pc only)' + ], + }, + { + 'key' => '@GRUB_GFXMODE', + 'value' => '640x480', + 'comment_before' => [ + '# The resolution used on graphical terminal', + '# note that you can use only modes which your graphic card supports via VBE', + '# you can see them in real GRUB with the command `vbeinfo\'' + ], + }, + { + 'key' => '@GRUB_DISABLE_LINUX_UUID', + 'value' => 'true', + 'comment_before' => [ + '# Uncomment if you don\'t want GRUB to pass "root=UUID=xxx" parameter to Linux' + ], + }, + { + 'key' => '@GRUB_DISABLE_LINUX_RECOVERY', + 'value' => 'true', + 'comment_before' => [ + '# Uncomment to disable generation of recovery mode menu entries' + ], + }, + { + 'key' => '@GRUB_INIT_TUNE', + 'value' => '480 440 1', + 'comment_before' => [ + '# Uncomment to get a beep at grub start' + ], + }, + ); + + } + + # We don't need to set root= as grub2-mkconfig + # already detect that for us .. + # my $root = delete $globinfo{"root"} || ""; + my $vga = delete $globinfo{"vgamode"} || ""; + my $append = delete $globinfo{"append"} || ""; + # $root = " root=$root" if $root ne ""; + $vga = " vga=$vga" if $vga ne ""; + $append = " $append" if $append ne ""; + + @lines = map { + my $line_ref = $_; + my $key = $line_ref->{"key"}; + if ($key =~ m/@?GRUB_CMDLINE_LINUX_DEFAULT/) + { + $line_ref->{"value"} = "$append$vga" if "$append$vga" ne ""; + $append = ""; + $vga = ""; + } + defined $line_ref ? $line_ref : (); + } @lines; + + if ("$append$vga" ne "") { + push @lines, { + "key" => "GRUB_CMDLINE_LINUX_DEFAULT", + "value" => "$append$vga", + } + } + + return \@lines; +} + +=item C<< $settings_ref = Bootloader::Core::GRUB2->GetSettings (); >> returns the complete settings in a hash. Does not read the settings @@ -655,6 +881,7 @@ # boolean InitializeBootloader () sub InitializeBootloader { my $self = shift; + my %glob = %{$self->{"global"}}; my $file = Bootloader::Path::Grub2_installdevice(); my $files_ref = $self->ReadFiles ([$file,]); @@ -663,6 +890,13 @@ return undef; } + my $install_opts = "--force"; + my $skip_fs_probe = delete $glob{"boot_extended"}; + + if (defined $skip_fs_probe and $skip_fs_probe eq "true") { + $install_opts .= " --skip-fs-probe "; + } + my @devices = @{$files_ref->{$file} || []}; # Hmm .. grub2-install must has been run before @@ -679,7 +913,7 @@ # the tradeoff is we can't capture errors # only patch grub2 package is possible way # to get around this problem - "/usr/sbin/grub2-install --force $dev", + "/usr/sbin/grub2-install $install_opts $dev", "/var/log/YaST2/y2log_bootloader" ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/src/Core/GRUB2EFI.pm new/perl-Bootloader-0.6.1/src/Core/GRUB2EFI.pm --- old/perl-Bootloader-0.6.0/src/Core/GRUB2EFI.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.6.1/src/Core/GRUB2EFI.pm 2012-03-30 11:47:45.000000000 +0200 @@ -0,0 +1,456 @@ +#! /usr/bin/perl -w +# +# Bootloader configuration base library +# + +=head1 NAME + +Bootlader::Core::GRUB2EFI - library for blank configuration + + +=head1 PREFACE + +This package is the GRUB2EFI library of the bootloader configuration + +=head1 SYNOPSIS + +use Bootloader::Core::GRUB2EFI; + +C<< $obj_ref = Bootloader::Core::GRUB2EFI->new (); >> + +C<< $files_ref = Bootloader::Core::GRUB2EFI->ListFiles (); >> + +C<< $status = Bootloader::Core::GRUB2EFI->ParseLines (\%files, $avoid_reading_device_map); >> + +C<< $files_ref = Bootloader::Core::GRUB2EFI->CreateLines (); >> + +C<< $settings_ref = Bootloader::Core::GRUB2EFI->GetSettings (); >> + +C<< $status = Bootloader::Core::GRUB2EFI->SetSettings (\%settings); >> + +C<< $glob_info = Bootloader::Core::GRUB2EFI->Global2Info (\@glob_lines, \@section_names); >> + +C<< $lines_ref = Bootloader::Core::GRUB2EFI->Info2Global (\%section_info, \@section_names); >> + +C<< $status = Bootloader::Core::GRUB2EFI->UpdateBootloader (); >> + +C<< $status = Bootloader::Core::GRUB2EFI->InitializeBootloader (); >> + + +=head1 DESCRIPTION + +=over 2 + +=cut + +package Bootloader::Core::GRUB2EFI; + +use strict; + +use Bootloader::Core; +our @ISA = ('Bootloader::Core'); +use Bootloader::Path; + +use Data::Dumper; + +#module interface + +=item +C<< $obj_ref = Bootloader::Core::GRUB2EFI->new (); >> + +Creates an instance of the Bootloader::Core::GRUB2EFI class. + +=cut + +sub new { + my $self = shift; + my $old = shift; + + my $loader = $self->SUPER::new ($old); + bless ($loader); + + $loader->l_milestone ("GRUB2EFI::new: Created GRUB2EFI instance"); + return $loader; +} + + + +=item +C<< $files_ref = Bootloader::Core::GRUB2EFI->ListFiles (); >> + +Returns the list of the configuration files of the bootloader +Returns undef on fail + +=cut + +# list<string> ListFiles () +sub ListFiles { + my $self = shift; + + return [ Bootloader::Path::Grub2_defaultconf() ]; +} + + +=item +C<< $status = Bootloader::Core::GRUB2EFI->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. Returns undef on +fail, defined nonzero value on success. + +=cut + +# void ParseLines (map<string,list<string>>, boolean) +sub ParseLines { + my $self = shift; + my %files = %{+shift}; + my $avoid_reading_device_map = shift; + + # and now proceed with /etc/default/grub + my @defaultconf = @{$files{Bootloader::Path::Grub2_defaultconf()} || []}; + $self->l_milestone ("GRUB2::Parselines: input from default conf :\n'" . + join("'\n' ", @defaultconf) . "'"); + + # prefix commented config with '@' instread of '#' + # this is to new notation for "commented config" and + # need to process saparately + foreach my $conf (@defaultconf) { + if ($conf =~ m/^\s*#\s*GRUB_/) { + $conf =~ s/^\s*#/@/; + } + } + + (my $glob_ref, my $sect_ref) = $self->ParseMenuFileLines ( + "=", + [], + \@defaultconf + ); + + $self->{"global"} = $glob_ref; + return 1; +} + +=item +C<< $files_ref = Bootloader::Core::GRUB2EFI->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. + +=cut + +# map<string,list<string>> CreateLines () +sub CreateLines { + my $self = shift; + my $global = $self->{"global"}; + + if (defined $global->{"__lines"}) { + foreach my $line (@{$global->{"__lines"}}) { + if (defined $line->{"value"} && $line->{"value"} eq "" ) { + $line->{"value"} = '""'; + } + } + } + + my $grub2_defaultconf = $self->PrepareMenuFileLines ( + [], + $global, + "", + "=" + ); + + foreach my $conf (@{$grub2_defaultconf}) { + if ($conf =~ m/^\s*@\s*GRUB_/) { + $conf =~ s/^\s*@/#/; + } + } + + return { Bootloader::Path::Grub2_defaultconf() => $grub2_defaultconf }; +} + +=item +C<< $glob_info = $Bootloader::Core::GRUB2EFI->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. + +=cut + +# map<string,string> Global2Info (list<map<string,any>> global, list<string>sections) + +sub Global2Info { + my $self = shift; + my @lines = @{+shift}; + my @sections = @{+shift}; + + my %ret = (); + $ret{"__lines"} = \@lines; + + foreach my $line_ref (@lines) { + my $key = $line_ref->{"key"}; + my $val = $line_ref->{"value"}; + + # Check if key is defined to prevent perl warnings + next if (!defined($key)); + + if ($key =~ m/@?GRUB_CMDLINE_LINUX_DEFAULT/) + { + if ($val =~ /^(?:(.*)\s+)?vga=(\S+)(?:\s+(.*))?$/) + { + $ret{"vgamode"} = $2 if $2 ne ""; + $val = $self->MergeIfDefined ($1, $3); + } + + $ret{"append"} = $val; + } + } + + return \%ret; +} + +=item +C<< $lines_ref = Bootloader::Core::GRUB2EFI->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). + +=cut + +# list<map<string,any>> Info2Global (map<string,string> info, list<string>sections) + +sub Info2Global { + my $self = shift; + my %globinfo = %{+shift}; + my $sections_ref = shift; + + my @lines = @{$globinfo{"__lines"} || []}; + + # my $sysconf = Bootloader::Tools::GetSysconfigValue("DEFAULT_APPEND"); + # allow to keep the section unchanged + return \@lines unless $globinfo{"__modified"} || 0; + + if (scalar (@lines) == 0) + { + @lines = ( + { + 'key' => 'GRUB_DISTRIBUTOR', + 'value' => '"openSUSE"', + 'comment_before' => [ + '# If you change this file, run \'grub2-mkconfig -o /boot/grub2/grub.cfg\' afterwards to update', + '# /boot/grub2/grub.cfg.' + ], + }, + { + 'key' => 'GRUB_DEFAULT', + 'value' => '0', + }, + { + 'key' => 'GRUB_HIDDEN_TIMEOUT', + 'value' => '0', + }, + { + 'key' => 'GRUB_HIDDEN_TIMEOUT_QUIET', + 'value' => 'true', + }, + { + 'key' => 'GRUB_TIMEOUT', + 'value' => '10', + }, + { + 'key' => 'GRUB_CMDLINE_LINUX_DEFAULT', + 'value' => 'quiet splash=silent', + }, + { + 'key' => 'GRUB_CMDLINE_LINUX', + 'value' => '""', + }, + { + 'key' => '@GRUB_BADRAM', + 'value' => '"0x01234567,0xfefefefe,0x89abcdef,0xefefefef"', + 'comment_before' => [ + '# Uncomment to enable BadRAM filtering, modify to suit your needs', + '# This works with Linux (no patch required) and with any kernel that obtains', + '# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)' + ], + }, + { + 'key' => '@GRUB_TERMINAL', + 'value' => 'console', + 'comment_before' => [ + '# Uncomment to disable graphical terminal (grub-pc only)' + ], + }, + { + 'key' => '@GRUB_GFXMODE', + 'value' => '640x480', + 'comment_before' => [ + '# The resolution used on graphical terminal', + '# note that you can use only modes which your graphic card supports via VBE', + '# you can see them in real GRUB with the command `vbeinfo\'' + ], + }, + { + 'key' => '@GRUB_DISABLE_LINUX_UUID', + 'value' => 'true', + 'comment_before' => [ + '# Uncomment if you don\'t want GRUB to pass "root=UUID=xxx" parameter to Linux' + ], + }, + { + 'key' => '@GRUB_DISABLE_LINUX_RECOVERY', + 'value' => 'true', + 'comment_before' => [ + '# Uncomment to disable generation of recovery mode menu entries' + ], + }, + { + 'key' => '@GRUB_INIT_TUNE', + 'value' => '480 440 1', + 'comment_before' => [ + '# Uncomment to get a beep at grub start' + ], + }, + ); + + } + + # We don't need to set root= as grub2-mkconfig + # already detect that for us .. + # my $root = delete $globinfo{"root"} || ""; + my $vga = delete $globinfo{"vgamode"} || ""; + my $append = delete $globinfo{"append"} || ""; + # $root = " root=$root" if $root ne ""; + $vga = " vga=$vga" if $vga ne ""; + $append = " $append" if $append ne ""; + + @lines = map { + my $line_ref = $_; + my $key = $line_ref->{"key"}; + if ($key =~ m/@?GRUB_CMDLINE_LINUX_DEFAULT/) + { + $line_ref->{"value"} = "$append$vga" if "$append$vga" ne ""; + $append = ""; + $vga = ""; + } + defined $line_ref ? $line_ref : (); + } @lines; + + if ("$append$vga" ne "") { + push @lines, { + "key" => "GRUB_CMDLINE_LINUX_DEFAULT", + "value" => "$append$vga", + } + } + + return \@lines; +} + +=item +C<< $settings_ref = Bootloader::Core::GRUB2EFI->GetSettings (); >> + +returns the complete settings in a hash. Does not read the settings +from the system, but returns internal structures. + +=cut + +# map<string,any> GetSettings () +sub GetSettings { + my $self = shift; + my $ret = $self->SUPER::GetSettings (); + return $ret; +} + +=item +C<< $status = Bootloader::Core::GRUB2EFI->SetSettings (\%settings); >> + +Stores the settings in the given parameter to the internal +structures. Does not touch the system. +Returns undef on fail, defined nonzero value on success. + +=cut + +# void SetSettings (map<string,any> settings) +sub SetSettings { + my $self = shift; + my %settings = %{+shift}; + return $self->SUPER::SetSettings (\%settings); +} + + +=item +C<< $status = Bootloader::Core::GRUB2EFI->UpdateBootloader (); >> + +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/elilo'). +Returns undef on fail, defined nonzero value on success. + +=cut + +# boolean UpdateBootloader () +sub UpdateBootloader { + my $self = shift; + my $avoid_init = shift; + + # backup the config file + # it really did nothing for now + my $ret = $self->SUPER::UpdateBootloader (); + + return undef unless defined $ret; + + if (! $avoid_init) + { + return $self->InitializeBootloader (); + } + + return 0 == $self->RunCommand ( + "/usr/sbin/grub2-efi-mkconfig -o /boot/grub2-efi/grub.cfg", + "/var/log/YaST2/y2log_bootloader" + ); +} + + +=item +C<< $status = Bootloader::Core::GRUB2EFI->InitializeBootloader (); >> + +Initializes the firmware to boot the bootloader. +Returns undef on fail, defined nonzero value otherwise + +=cut + +# boolean InitializeBootloader () +sub InitializeBootloader { + my $self = shift; + + my $ret = $self->RunCommand ( + "/usr/sbin/grub2-efi-install", + "/var/log/YaST2/y2log_bootloader" + ); + + return 0 if (0 != $ret); + + return 0 == $self->RunCommand ( + "/usr/sbin/grub2-efi-mkconfig -o /boot/grub2-efi/grub.cfg", + "/var/log/YaST2/y2log_bootloader" + ); +} + +1; + +# +# Local variables: +# mode: perl +# mode: font-lock +# mode: auto-fill +# fill-column: 78 +# End: +# + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/src/Library.pm new/perl-Bootloader-0.6.1/src/Library.pm --- old/perl-Bootloader-0.6.0/src/Library.pm 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/src/Library.pm 2012-03-30 11:47:45.000000000 +0200 @@ -137,6 +137,11 @@ require Bootloader::Core::GRUB2; $loader = Bootloader::Core::GRUB2->new ($loader); } + elsif ($bootloader eq "grub2-efi") + { + require Bootloader::Core::GRUB2EFI; + $loader = Bootloader::Core::GRUB2EFI->new ($loader); + } elsif ($bootloader eq "lilo") { require Bootloader::Core::LILO; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/src/Path.pm new/perl-Bootloader-0.6.1/src/Path.pm --- old/perl-Bootloader-0.6.0/src/Path.pm 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/src/Path.pm 2012-03-30 11:47:45.000000000 +0200 @@ -270,4 +270,16 @@ return Prefix($value); } +=item +C<< $path = Bootloader::Path::Grub2_defaultconf(); >> + +Gets path for grub configuration file grub +(this file contains commands for initialize bootloader). + +=cut + +sub Grub2_defaultconf { + my $value = "/etc/default/grub"; + return Prefix($value); +} 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/src/Tools.pm new/perl-Bootloader-0.6.1/src/Tools.pm --- old/perl-Bootloader-0.6.0/src/Tools.pm 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/src/Tools.pm 2012-03-30 11:47:45.000000000 +0200 @@ -882,7 +882,9 @@ sub UpdateBootloader { - my $ret = $lib_ref->UpdateBootloader (); + my $avoid_init = shift; + + my $ret = $lib_ref->UpdateBootloader ($avoid_init); DumpLog ($lib_ref->{"loader"}); return $ret; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/update-bootloader new/perl-Bootloader-0.6.1/update-bootloader --- old/perl-Bootloader-0.6.0/update-bootloader 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/update-bootloader 2012-03-30 11:47:45.000000000 +0200 @@ -122,7 +122,7 @@ if ( -f '/usr/bin/zypper' ){ my $zypper_out = qx{zypper --terse tos -l}; if ($zypper_out =~ m/^labelLong\s*(\S.*\S)\s*\nlabelShort\s*(\S.*\S)[\s\n]*$/){ - return $1 if ($1 ne "" && ($loader eq "grub" || $loader eq "grub2")); + return $1 if ($1 ne "" && ($loader eq "grub" || $loader eq "grub2" || $loader eq "grub2-efi")); return $2 if ($2 ne ""); } } @@ -131,7 +131,7 @@ # Second try: Is there a usable /etc/SuSE-release? # This should really not be used anymore, as the syntax changed # no 'SP1' in the output. - if (open(RELEASE, "</etc/SuSE-release") && ($loader eq "grub" || $loader eq "grub2")) { + if (open(RELEASE, "</etc/SuSE-release") && ($loader eq "grub" || $loader eq "grub2" || $loader eq "grub2-efi")) { # first line is sufficient $namever = <RELEASE>; @@ -506,7 +506,10 @@ } if (defined $oper{refresh}) { - my $ret = UpdateBootloader(); + my $loader = Bootloader::Tools::GetBootloader(); + my $avoid_init = ($loader eq "grub2" || $loader eq "grub2-efi") ? 1 : 0; + + my $ret = UpdateBootloader($avoid_init); exit 1 if ( !$ret ); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.6.0/version new/perl-Bootloader-0.6.1/version --- old/perl-Bootloader-0.6.0/version 2012-03-05 15:23:55.000000000 +0100 +++ new/perl-Bootloader-0.6.1/version 2012-03-30 11:47:45.000000000 +0200 @@ -1 +1 @@ -0.6.0 +0.6.1 ++++++ update-bootloader ++++++ --- /var/tmp/diff_new_pack.v3r2wR/_old 2012-04-02 10:30:34.000000000 +0200 +++ /var/tmp/diff_new_pack.v3r2wR/_new 2012-04-02 10:30:34.000000000 +0200 @@ -122,7 +122,7 @@ if ( -f '/usr/bin/zypper' ){ my $zypper_out = qx{zypper --terse tos -l}; if ($zypper_out =~ m/^labelLong\s*(\S.*\S)\s*\nlabelShort\s*(\S.*\S)[\s\n]*$/){ - return $1 if ($1 ne "" && ($loader eq "grub" || $loader eq "grub2")); + return $1 if ($1 ne "" && ($loader eq "grub" || $loader eq "grub2" || $loader eq "grub2-efi")); return $2 if ($2 ne ""); } } @@ -131,7 +131,7 @@ # Second try: Is there a usable /etc/SuSE-release? # This should really not be used anymore, as the syntax changed # no 'SP1' in the output. - if (open(RELEASE, "</etc/SuSE-release") && ($loader eq "grub" || $loader eq "grub2")) { + if (open(RELEASE, "</etc/SuSE-release") && ($loader eq "grub" || $loader eq "grub2" || $loader eq "grub2-efi")) { # first line is sufficient $namever = <RELEASE>; @@ -506,7 +506,10 @@ } if (defined $oper{refresh}) { - my $ret = UpdateBootloader(); + my $loader = Bootloader::Tools::GetBootloader(); + my $avoid_init = ($loader eq "grub2" || $loader eq "grub2-efi") ? 1 : 0; + + my $ret = UpdateBootloader($avoid_init); exit 1 if ( !$ret ); } -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de