File grubby-compat-zipl-fix.patch of Package cobbler

Index: cobbler-2.2.2/scripts/grubby-compat
===================================================================
--- cobbler-2.2.2.orig/scripts/grubby-compat
+++ cobbler-2.2.2/scripts/grubby-compat
@@ -4,6 +4,7 @@ use POSIX;
 use Getopt::Long;
 use Pod::Usage;
 use Bootloader::Tools;
+use Bootloader::Library;
 use strict;
 
 my %oper;
@@ -12,17 +13,18 @@ my ($opt_args, $opt_update, $opt_initrd,
 
 # dummy option - we need it always as 0 but koan may set it.
 my $opt_copydefault = 0;
+my $use_zipl = 0;
 
 GetOptions (\%oper,
-    'add-kernel=s' => \$opt_add_image,
-    'bootloader-probe' ,
-    'update-kernel' => \$opt_update,
-    'make-default',
-    'args=s'      => \$opt_args,
-    'initrd=s'      => \$opt_initrd,
-    'title=s' => \$opt_title,
-    'copy-default' => \$opt_copydefault)
-    or pod2usage(2);
+	    'add-kernel=s' => \$opt_add_image,
+	    'bootloader-probe' ,
+	    'update-kernel' => \$opt_update,
+	    'make-default',
+	    'args=s' => \$opt_args,
+	    'initrd=s' => \$opt_initrd,
+	    'title=s' => \$opt_title,
+	    'copy-default' => \$opt_copydefault,
+	    'zipl' => \$use_zipl) || pod2usage(2);
 
 if (defined $oper{'bootloader-probe'}){
   print Bootloader::Tools::GetBootloader();
@@ -32,9 +34,9 @@ if (defined $oper{'bootloader-probe'}){
 my $lib = InitLibrary();
 
 if ($opt_add_image ne ''){
-  print "add kernel\n";
   my @sections = @{$lib->GetSections ()};
   my $section = { 'name' => $opt_title,
+		  'default' => $opt_title,
                   'append' => $opt_args,
                   'type' => "image",
                   'initrd' => $opt_initrd,
@@ -42,16 +44,33 @@ if ($opt_add_image ne ''){
                   'original_name' => 'linux',
                   '__modified' => '1',
                   'root' => $lib->GetMountPoints()->{"/"}};
+  if ($use_zipl) {
+      $section->{target} = "/boot/zipl";
+      # Update defaults of 'menu' section in zipl.conf
+      for (@sections) {
+	  if($_->{type} eq 'menu') {
+	      $_->{list} = "$opt_title, $_->{list}";
+	      if($oper{'make-default'}) {
+		  $_->{default} = 1;
+	      } else {
+		  $_->{default}++;
+	      }
+	  }
+      }
+  }
   unshift @sections, $section;
-  $lib->SetSections (\@sections);
-  print "set sections\n";
+  $lib->SetSections(\@sections);
+
   if (defined $oper{'make-default'}){
     my $glob_ref = $lib->GetGlobalSettings();
-    $glob_ref->{"default"} = $section->{"name"};
-    $lib->SetGlobalSettings ($glob_ref);
+    $glob_ref->{default} = $section->{name};
+    $glob_ref->{__modified} = 1;
+    $lib->SetGlobalSettings($glob_ref);
+    print "make default: " . $section->{"name"} . "\n";
   }
+
   $lib->WriteSettings(1);
-  $lib->UpdateBootloader (1);
+  $lib->UpdateBootloader(1);
   print "bootloader updated\n";
   Bootloader::Tools::DumpLog($lib->{"loader"});
 }
openSUSE Build Service is sponsored by