File grubby-compat.diff of Package cobbler

Index: scripts/grubby-compat
===================================================================
--- /dev/null
+++ scripts/grubby-compat
@@ -0,0 +1,57 @@
+#! /usr/bin/perl
+
+use POSIX;
+use Getopt::Long;
+use Pod::Usage;
+use Bootloader::Tools;
+use strict;
+
+my %oper;
+my ($opt_args, $opt_update, $opt_initrd, $opt_add_image, $opt_default, $opt_title)
+    = ("",0,'','',undef,'');
+
+# dummy option - we need it always as 0 but koan may set it.
+my $opt_copydefault = 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);
+
+if (defined $oper{'bootloader-probe'}){
+  print Bootloader::Tools::GetBootloader();
+  exit 0;
+}
+
+my $lib = InitLibrary();
+
+if ($opt_add_image ne ''){
+  print "add kernel\n";
+  my @sections = @{$lib->GetSections ()};
+  my $section = { 'name' => $opt_title,
+                  'append' => $opt_args,
+                  'type' => "image",
+                  'initrd' => $opt_initrd,
+                  'image' => $opt_add_image,
+                  'original_name' => 'linux',
+                  '__modified' => '1',
+                  'root' => $lib->GetMountPoints()->{"/"}};
+  unshift @sections, $section;
+  $lib->SetSections (\@sections);
+  print "set sections\n";
+  if (defined $oper{'make-default'}){
+    my $glob_ref = $lib->GetGlobalSettings();
+    $glob_ref->{"default"} = $section->{"name"};
+    $lib->SetGlobalSettings ($glob_ref);
+  }
+  $lib->WriteSettings(1);
+  $lib->UpdateBootloader (1);
+  print "bootloader updated\n";
+  Bootloader::Tools::DumpLog($lib->{"loader"});
+}
Index: koan/app.py
===================================================================
--- koan/app.py.orig
+++ koan/app.py
@@ -930,7 +930,11 @@ class Koan:
                return (0, "grub")
             else:
                return (0, "lilo") 
-        cmd = [ "/sbin/grubby", "--bootloader-probe" ]
+        (make, version) = utils.os_release()
+        grubby_bin = "/sbin/grubby"
+        if (make == "suse"):
+            grubby_bin = "/sbin/grubby-compat"
+        cmd = [ grubby_bin, "--bootloader-probe" ]
         probe_process = sub_process.Popen(cmd, stdout=sub_process.PIPE)
         which_loader = probe_process.communicate()[0]
         return probe_process.returncode, which_loader
@@ -954,14 +958,16 @@ class Koan:
     
 
         def after_download(self, profile_data):
-            if not os.path.exists("/sbin/grubby"):
-                raise InfoException, "grubby is not installed"
+            (make, version) = utils.os_release()
+            grubby_bin = "/sbin/grubby"
+            if (make == "suse"):
+                grubby_bin = "/sbin/grubby-compat"
+            if not os.path.exists(grubby_bin):
+                raise InfoException, "%s is not installed" % grubby_bin
             k_args = self.calc_kernel_args(profile_data,replace_self=1)
 
             kickstart = self.safe_load(profile_data,'kickstart')
 
-            (make, version) = utils.os_release()
-
             if (make == "centos" and version < 7) or (make == "redhat" and version < 7) or (make == "fedora" and version < 10) or (make == "suse"):
 
                 # embed the initrd in the kickstart file because of libdhcp and/or pump
@@ -995,20 +1001,26 @@ class Koan:
                 elif arch.startswith("s390"):
                     if len(k_args) > 895:
                         raise InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args
-                elif len(k_args) > 255:
-                    raise InfoException, "Kernel options are too long, 255 chars exceeded: %s" % k_args
+                elif len(k_args) > 2047:
+                    raise InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args
 
-            cmd = [ "/sbin/grubby",
+            kargs_string = ""
+            if make == "suse":
+                kargs_string = "%s" % k_args
+            else:
+                kargs_string = "\"%s\"" % k_args
+
+            cmd = [ grubby_bin,
                     "--add-kernel", self.safe_load(profile_data,'kernel_local'),
                     "--initrd", self.safe_load(profile_data,'initrd_local'),
-                    "--args", "\"%s\"" % k_args
+                    "--args", kargs_string
             ]
 
             if self.grubby_copy_default:
                 cmd.append("--copy-default")
 
             boot_probe_ret_code, probe_output = self.get_boot_loader_info()
-            if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") >= 0:
+            if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") >= 0 and make != "suse":
                 cmd.append("--lilo")
 
             if self.add_reinstall_entry:
@@ -1044,10 +1056,13 @@ class Koan:
             else:
                 # if grubby --bootloader-probe returns lilo,
                 #    apply lilo changes
-                if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") != -1:
+                if boot_probe_ret_code == 0 and probe_output.startswith("lilo"):
                     print "- applying lilo changes"
                     cmd = [ "/sbin/lilo" ]
-                    utils.subprocess_call(cmd)
+                elif boot_probe_ret_code == 0 and probe_output.startswith("elilo"):
+                    print "- applying elilo changes"
+                    cmd = [ "/sbin/elilo" ]
+                utils.subprocess_call(cmd)
 
             if not self.add_reinstall_entry:
                 print "- reboot to apply changes"
Index: setup.py
===================================================================
--- setup.py.orig
+++ setup.py
@@ -170,6 +170,7 @@ if __name__ == "__main__":
         data_files = proc_data_files([
             # tftpd, hide in /usr/sbin
             ("/usr/sbin", ["scripts/tftpd.py"]),
+            ("/sbin", ["scripts/grubby-compat"]),
 
             ("%s" % webconfig,              ["config/cobbler.conf"]),
             ("%s" % vhostconfig,            ["config/cobbler_web.conf"]),
openSUSE Build Service is sponsored by