Rodrigo Bistolfi avatar Rodrigo Bistolfi committed 7d45c65 Merge

Merged in m0e_lnx/m0e-vinstall (pull request #9)

Add option to disable bootsplash on advanced + TUI entry for LiLO boot menu + other features.

Comments (0)

Files changed (2)

vinstall/backend/bootloader.py

             if system.initrd:
                 self.buffer.append("%s initrd = %s" % (tab,
                     system.initrd))
-            if system.appendline:
-                if "splash" not in system.appendline:
-                    self.buffer.append('%s append = "%s splash quiet"' %
-                            (tab, system.appendline))
-                else:
-                    self.buffer.append('s append = "%s"' % (tab,
-                            system.appendline))
+#            if system.appendline:
+#                if "splash" not in system.appendline:
+#                    self.buffer.append('%s append = "%s splash quiet"' %
+#                            (tab, system.appendline))
+#                else:
+#                    self.buffer.append('%s append = "%s"' % (tab,
+#                            system.appendline))
+	    if system.appendline:
+	        self.buffer.append('%s append = "%s"'% (tab, system.appendline))
             self.buffer.append("%s read-only" % tab)
             self.buffer.append("# --")
 

vinstall/controller/bootloader.py

 """
 
 
-import os
+import os, shutil
 from vinstall.backend import bootloader, utils, sp
 from vinstall.backend.media import Disk, Partition
 from vinstall.core import Render, Controller, model, log
 
         location = model.DropdownOptionList()
         location.label = u"Install the bootloader in"
+	splash_opt = model.BoolOption(u"Disable boot animation","Disable boot animation","Disable bootsplash")
         for i in self.targets:
             location.add_option(unicode(i))
 
-        return Render(title, intro, bootloaders, location)
+        return Render(title, intro, bootloaders, location, splash_opt)
 
     def next(self):
         """Return next step
         from vinstall.controller import usersetup
         return usersetup.UserSetup
 
-    def command(self, bootloader, target):
+    def disable_bootsplash(self, splash_disabled):
+	"""Disable the bootsplash if asked to by the preference set by splash_opt.
+	splash_opt is a Boolean"""
+	ramdiskdir="/mnt/TARGET/boot"
+	if splash_disabled == True :
+	    # Disable the bootsplash by renaming the initrd.
+	    if not os.path.exists(os.path.join(ramdiskdir,'initrd.gz')):
+	        LOG.error("User selected to disable bootsplash, but no initrd was found in target")
+		return
+	    LOG.debug("Renaming initrd.gz to disable bootsplash animation per user's request")
+	    os.rename(os.path.join(ramdiskdir,"initrd.gz"),
+		      os.path.join(ramdiskdir,"disabledinitrd.gz"))
+
+    def command(self, bootloader, target, splash_opt):
         """Schedule command for later execution
 
         """
         yield self.set_bind_mounts, tuple(), "Mounting pseudo filesystems"
         yield self.depmod, tuple(), "Running depmod"
         yield self.mkinitrd, tuple(), "Creating initrd"
-        yield self.install_bootloader, (bootloader, target), "Installing bootloader"
+	if splash_opt == True : # This will have a True value if it was disabled by the user
+	    LOG.debug("User selected to disable the bootsplash animation.  Scheduling method to disable it.")
+	    yield self.disable_bootsplash, (splash_opt,), "Setting bootsplash preference"
+        yield self.install_bootloader, (bootloader, target, splash_opt), "Installing bootloader"
         yield self.clear_bind_mounts, tuple(), "Clearing bind mounts"
+	yield self.save_installation_logs, tuple(), "Saving installation logs"
 
-    def install_bootloader(self, bloader, target):
+    def save_installation_logs(self):
+	"""Save the installation logs to the target"""
+	logloc = os.getcwd()
+	logtarget = "/mnt/TARGET/var/log"
+	shutil.copy(os.path.join(logloc,'installer.log'), os.path.join(logtarget,'installer.log'))
+	shutil.copy(os.path.join(logloc,'subprocess.log'), os.path.join(logtarget,'installer-subprocess.log'))
+
+    def install_bootloader(self, bloader, target, splash_opt):
         """Install the bootloader
 
         """
         target = disk.path()
 
         if bloader.lower() == "lilo":
-            self.install_lilo(target)
+            self.install_lilo(target, splash_opt)
         elif bloader == "Grub2":
             self.install_grub(target)
         else:
             return
 
-    def install_lilo(self, target):
+    def install_lilo(self, target, splash_opt):
         """ Install LILO to target
 
         """
         LOG.debug("Installing LILO to %s", target)
         lilo = bootloader.Lilo(target)
         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.
+	        tui_label = system.label
+   	        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 = "root=%s verbose"% system.root
+	    else:
+	        system.appendline = "root=%s splash quiet"% system.root
             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"%tui_label
+	    tui.appendline = 'root=%s ro 2 verbose'% tui.root
+	    lilo.add_os(tui)
+	
+
         with utils.Chroot("/mnt/TARGET"):
             lilo.backup_config()
             lilo.write_config()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.