1. VectorLinux Core
  2. vinstall

Commits

Moises Henriquez  committed d750494

Fixed LiLO boot menu

  • Participants
  • Parent commits 89fcacf
  • Branches master

Comments (0)

Files changed (2)

File vinstall/backend/bootloader.py

View file
  • Ignore whitespace
 from StringIO import StringIO
 from vinstall.backend import utils, media
 from vinstall.backend import sp
-from vinstall.core import log
 import unittest
 
 
 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.
     The only reason it exists is to do some unittesting"""
         if not os.path.exists(self.tamu):
             os.mkdir(self.tamu)
 
+
     def add_os(self, system):
 	"""Add the information about this operating system to the
 	class"""
         if system.type != "linux":
 	    return
 	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
 	    partition = media.Partition(system.root)
 	    if not partition.is_mounted():
-	        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(mountpoint, system.kernel)
+	    kernel_from = mountpoint + system.kernel #XX: os.path.join wont work here!!
 	    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")
+	    if not os.path.exists(os.path.split(kernel_to)[0]):
+	        os.mkdir(os.path.split(kernel_to)[0])
 	    shutil.copy2(kernel_from, kernel_to)
 
 	    # Copy the initrd to the local tamu path
 	    if system.initrd:
-	        initrd_from = os.path.join(mountpoint, system.initrd)
+	        initrd_from = mountpoint + system.initrd #XX: os.path.join wont work here !!
 	    	shutil.copy2(initrd_from, system.tamu_initrd_path)
 
         # un-mount the partition if necessary
 
         """
         newline = "\n"
+	if self.default_os:
+	    default_os_line = "default = %s"% self.default_os.label
+	else:
+	    default_os_line = "#"
         header = (
             "# LILO configuration file.",
             "# ",
             "# Generated by VASM.",
             "# ",
             "boot = %s" % self.target,
+	    default_os_line,
             "compact",
             "prompt",
             "timeout = %s" % self.timeout,

File vinstall/controller/bootloader.py

View file
  • Ignore whitespace
 
         """
         LOG.debug("Installing LILO to %s", target)
-#        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())
+
+	    # 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)
 
+	    lilo.set_default_os(myos)
+
 	    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()
-
     def install_grub(self, target):
         """ Install Grub2 to target