Commits

Moises Henriquez committed b019688

Debugging lilo boot menu creation

Comments (0)

Files changed (2)

vinstall/backend/bootloader.py

 	return "%s-%s"% (self.label, self._short_root)
 
     @classmethod
-    def all(cls, include_running_os=False, op_data = None, bp_data = None):
+    def all(cls, include_running_os=True, op_data = None, bp_data = None,
+            bootsplash_disabled = False, current_root = None):
         """Return one OperatingSystem instance for each OS
         installed
-
+        Arguments:
+            include_running_os:  True or False (self explanatory)
+            op_data: os-prober data (for unittests only)
+            bp_data: linux-boot-prober data (for unittests only)
+            bootsplash_disabled: True or False (self explanatory)
+            current_root: media.Partition object indicating the current partition mounted at /
         """
 	if not op_data:
             op_data = sp.check_output(["os-prober", "&>/dev/null"])
         found_os = op_data.split("\n")
-#        if include_running_os and os.path.exists('/boot/vmlinuz'):
-#            running_os = cls()
-#            running_os.kernel = '/boot/vmlinuz'
-#            running_os.label = 'VectorLinux'
-#            running_os.type = "linux"
-#            if os.path.exists('/boot/initrd'):
-#                running_os.initrd = '/boot/initrd'
-#            running_os.root = utils.get_mounted("/")
-#            yield running_os
+        
+        systems = []
+        if include_running_os and current_root is not None:
+            myroot = current_root.path()
+            LOG.debug("Creating Lilo boot entries for current OS")
+            LOG.debug("Current root=%s"% myroot)
+            if os.path.exists('/boot/vmlinuz'):
+                current_os = cls()
+                current_os.initrd = None
+                current_os_tui = cls()
+                current_os_tui.initrd = None
+                current_os.kernel = '/boot/vmlinuz'
+                current_os.label = 'Vector'
+                current_os.type = 'linux'
+                if os.path.exists('/boot/initrd'):
+                    current_os.initrd = '/boot/initrd'
+                    current_os_tui.initrd = '/boot/initrd'
+                current_os.root = myroot
+                current_os_tui.label = 'Vector-TUI'
+                current_os_tui.kernel = '/boot/vmlinuz'
+                current_os_tui.root = myroot
+                current_os_tui.type = "linux"
+                if bootsplash_disabled:
+                    current_os.appendline = "verbose"
+                else:
+                    current_os.appendline = "quiet splash"
+                current_os_tui.appendline = "2 verbose"
+                systems.append(current_os)
+                systems.append(current_os_tui)
 
         for i in found_os:
             if ":" not in i:
                 operating_system.root = bootinfo["root"] #XX or root ??
                 operating_system.kernel = bootinfo["kernel"]
                 operating_system.initrd = bootinfo["initrd"]
+#XX: The bootinfo["append"] reports invalid stuff that may cause LiLO to fail
+#  Setting appendline to None until further notice.
+                operating_system.appendline = None
 #                operating_system.appendline = bootinfo["append"]
-#XX: append line here is not good.  needs some work ^^
             elif "microsoft" in os_type.lower() or \
                     "windows" in os_type.lower() or \
 		    "chain" in os_type.lower():
             #XXX what about bsd, osx, etc.  Will 'chain' cover them?
             else:
                 continue
-            yield operating_system
-
+            systems.append(operating_system)
+#            yield operating_system
+        for op in systems:
+            yield op
 
 class MasterBootRecord(object):
     """The MBR of a device

vinstall/controller/bootloader.py

 
         """
         LOG.debug("Installing LILO to %s", target)
+        # Set the current root.  We would normally use utils.get_mounted("/") for this
+        # but on a new install, that returns None, so we must give it the
+        # self.config['target_device'] object itself.
 	with utils.Chroot("/mnt/TARGET"):
 	    lilo = bootloader.Lilo(target = target,
-		bootloader_root = self.config['target_device'].path())
-
-	    # Add the boot entry for the OS we just installed #
-	    LOG.debug("Generating LiLO Booot entry for newly installed on in %s"% lilo.bootloader_root)
-	    myos = bootloader.OperatingSystem()
-	    myos.root = self.config['target_device'].path()
-	    myos.type = "linux"
-	    myos.label = "Vector"
-	    myos.kernel = "/boot/vmlinuz"
-	    if splash_opt == True: # Splash was disabled, disable the initrd
-		LOG.debug("Bootsplash disabled by user. ")
-		myos.initrd = None
-		myos.appendline = "verbose"
-	    else:
-		if os.path.exists("/boot/initrd.gz"):
-		    myos.initrd = "/boot/initrd.gz" #XX: This is OK because / is now /mnt/TARGET
-		myos.appendline = "quiet"
-	    LOG.debug("Generating TUI LiLO Boot entry for new OS on %s"% lilo.bootloader_root)
-	    mytui = bootloader.OperatingSystem()
-	    mytui.root = self.config['target_device'].path()
-	    mytui.type = "linux"
-	    mytui.label = "Vector-TUI"
-	    mytui.kernel = "/boot/vmlinuz"
-	    if splash_opt == True: # Splash disabled, disable initrd
-		mytui.initrd = None
-	    else:
-		if os.path.exists("/boot/initrd.gz"):
-		    mytui.initrd = "/boot/initrd.gz"
-	    mytui.appendline = "2 verbose"
-
-	    lilo.add_os(myos)
-	    lilo.add_os(mytui)
-            for system in bootloader.OperatingSystem.all():
-                LOG.debug("Adding %s entry to LiLo boot menu"% system.label)
-	        lilo.add_os(system)
+		                   bootloader_root = self.config['target_device'].path())
+
+            for system in bootloader.OperatingSystem.all(
+                    include_running_os = True,
+                    bootsplash_disabled = splash_opt,
+                    current_root = self.config['target_device']):
 
-	    lilo.set_default_os(myos)
+                LOG.debug("Adding LiLO boot menu item for %s from %s"% (system.label, system.root))
+	        lilo.add_os(system)
 
 	    lilo.backup_config()
 	    lilo.write_config()