Commits

Uelsk8s committed 89fcacf

Debugging LiLO install procedure

Comments (0)

Files changed (2)

vinstall/backend/bootloader.py

 GRUB = object()
 GRUB2 = object()
 
+LOG = log.get_logger("bootloader_be")
 
 class LiloDotConfEntry(object):
     """Dummy wrapper for reading a lilo.conf.  Has absolutely no use at all.
             self.lilo_root = utils.get_mounted("/")
 	else:
 	    self.lilo_root = bootloader_root
+	self.bootloader_root = bootloader_root
         self.tamu = "/boot/tamu"
         if not os.path.exists(self.tamu):
             os.mkdir(self.tamu)
 	"""Copy the kernel and initrd to our partition
 	if necessary"""
 	
+	umount = False
         if system.type != "linux":
 	    return
-	if system.root != self.lilo_root:
+	if system.os_root != self.bootloader_root:
+	    LOG.debug("Processing foreign Linux OS found on %s"% system.root)
 	    # Mount the os root partition if needed
-	    umount = False
 	    partition = media.Partition(system.root)
 	    if not partition.is_mounted():
-	        mountpoint = system.root.replace("/dev/","/mnt/")
-	        if not os.path.exists(mountpoint):
-		    os.mkdir(mountpoint)
-		partition.mount(mountpoint)
+	        LOG.debug("Partition %s needs to be mounted to copy boot data to /boot"% system.root)
 		umount = True
+		#mountpoint = system.root.replace("/dev/","/mnt/")
+		#LOG.debug("attempting to mount to %s"% mountpoint)
+		if not os.path.exists(partition.mountpoint):
+		    os.mkdir(partition.mountpoint)
+		mountpoint = partition.mount(partition.mountpoint)
+	    else:
+		LOG.debug("Partition %s is already mounted on %s"% (system.root, partition.mountpoint))
+		mountpoint = partition.mountpoint
 
             targetdir = os.path.split(system.tamu_kernel_path)[0]
 	    if not os.path.exists(targetdir):
 	        os.mkdir(targetdir)
 	    # Copy the kernel to the local tamu path
-	    kernel_from = os.path.join(partition.mountpoint, system.kernel)
-	    shutil.copy2(kernel_from, system.tamu_kernel_path)
+	    kernel_from = os.path.join(mountpoint, system.kernel)
+	    kernel_to = system.tamu_kernel_path
+
+	    LOG.debug("Copy kernel from partition %s with path %s to %s"% (system.os_root, kernel_from, kernel_to))
+	    if not os.path.exists(kernel_from):
+		LOG.error("Unable to find kernel %s in %s"% (kernel_from, partition.mountpoint))
+	    if not partition.is_mounted():
+		LOG.error("Partition should be mounted now, but it's not.  Imminent failure")
+	    shutil.copy2(kernel_from, kernel_to)
+
 	    # Copy the initrd to the local tamu path
 	    if system.initrd:
-	        initrd_from = os.path.join(partition.mountpoint, system.initrd)
+	        initrd_from = os.path.join(mountpoint, system.initrd)
 	    	shutil.copy2(initrd_from, system.tamu_initrd_path)
 
         # un-mount the partition if necessary
         self.buffer.append("# -- %s on %s --" % (system.label,
             system.root))
 	
-	if system.root != self.lilo_root:
+	if system.root != self.bootloader_root:
 	    self.buffer.append("image = %s"% system.tamu_kernel_path)
 	    self.buffer.append("%s label = %s"% (tab, system.tamu_lilo_label))
 	    if system.initrd:
                 bootinfo = get_linux_boot_info(root, bp_data)
                 if bootinfo is None:
                     continue
-                operating_system.root = bootinfo["root"] or root
+                operating_system.root = bootinfo["root"] #XX or root ??
                 operating_system.kernel = bootinfo["kernel"]
                 operating_system.initrd = bootinfo["initrd"]
                 operating_system.appendline = bootinfo["append"]

vinstall/controller/bootloader.py

 
         """
         LOG.debug("Bootloader: %s", bootloader)
-        LOG.debug("Target; %s", target)
+        LOG.debug("Target: %s", target)
         yield self.set_bind_mounts, tuple(), "Mounting pseudo filesystems"
         yield self.depmod, tuple(), "Running depmod"
         yield self.mkinitrd, tuple(), "Creating initrd"
 
         """
         LOG.debug("Installing LILO to %s", target)
-        lilo = bootloader.Lilo(target = target,
-	    bootloader_root = self.config['target_device'])
-        for system in bootloader.OperatingSystem.all():
-	    LOG.debug("Adding %s entry to LiLo boot menu"% system.label)
-	    if system.root == self.config['target_device'].path():
-	        # Set grab the values for the tui entry here.
-		system.label = "Vector"
-   	        tui_kernel = system.kernel
-	    if splash_opt == True: 
-		# Splash was disabled... override the initd line for the entry
-	        if system.root == self.config['target_device'].path():
-		    system.initrd = None
-		    system.appendline = 'verbose'
-	    else:
-	        system.appendline = 'splash quiet'
-            lilo.add_os(system)
-	if tui_kernel:
-	    # Create the TUI entry for LiLO
-	    LOG.debug("Adding Linux-tui entry to LiLO boot menu")
-	    tui = bootloader.OperatingSystem()
-	    rootpart = self.config['target_device']
-	    tui.kernel = tui_kernel
-	    tui.root = rootpart.path()
-	    tui.type = "linux"
-	    tui.initrd = None
-	    tui.label = "%s-tui"% system.label
-	    tui.appendline = '2 verbose'
-	    lilo.add_os(tui)
+#        lilo = bootloader.Lilo(target = target,
+#	    bootloader_root = self.config['target_device'].path())
+	with utils.Chroot("/mnt/TARGET"):
+	    lilo = bootloader.Lilo(target = target,
+		bootloader_root = self.config['target_device'].path())
+            for system in bootloader.OperatingSystem.all():
+                LOG.debug("Adding %s entry to LiLo boot menu"% system.label)
+	        lilo.add_os(system)
+
+	    lilo.backup_config()
+	    lilo.write_config()
+	    lilo.install()
+
+
+#	    if system.root == self.config['target_device'].path():
+#	        # Set grab the values for the tui entry here.
+#		system.label = "Vector"
+#   	        tui_kernel = system.kernel
+#	    if splash_opt == True: 
+#		# Splash was disabled... override the initd line for the entry
+#	        if system.root == self.config['target_device'].path():
+#		    system.initrd = None
+#		    system.appendline = 'verbose'
+#	    else:
+#	        system.appendline = 'splash quiet'
+#            lilo.add_os(system)
+#	if tui_kernel:
+#	    # Create the TUI entry for LiLO
+#	    LOG.debug("Adding Linux-tui entry to LiLO boot menu")
+#	    tui = bootloader.OperatingSystem()
+#	    rootpart = self.config['target_device']
+#	    tui.kernel = tui_kernel
+#	    tui.root = rootpart.path()
+#	    tui.type = "linux"
+#	    tui.initrd = None
+#	    tui.label = "%s-tui"% system.label
+#	    tui.appendline = '2 verbose'
+#	    lilo.add_os(tui)
 	
 
-        with utils.Chroot("/mnt/TARGET"):
-            lilo.backup_config()
-            lilo.write_config()
-	    # The lilo.install method will copy the kernels and initrds
-	    # to the right location to keep the API sane.
-            lilo.install()
+#        with utils.Chroot("/mnt/TARGET"):
+#            lilo.backup_config()
+#            lilo.write_config()
+#	    # The lilo.install method will copy the kernels and initrds
+#	    # to the right location to keep the API sane.
+#            lilo.install()
 
     def install_grub(self, target):
         """ Install Grub2 to target