1. VectorLinux Core
  2. vinstall

Commits

Rodrigo Bistolfi  committed 864aff4

Make initrd before installing bootloader

  • Participants
  • Parent commits 4e20d54
  • Branches master

Comments (0)

Files changed (2)

File vinstall/controller/automatic.py

View file
 """
 
 
-from vinstall.core import Render, Controller, model
+from vinstall.core import Render, Controller, model, log
 from vinstall.backend import (media,  utils,  partitioning, fstab, users,
         service, bootloader, sp)
 import vinstall.controller.intro as intro
 import os, glob, shutil
 
 
+LOG = log.get_logger("automatic")
+
+
 class AutomaticMode(Controller):
     """Automatic install mode. We will look for devices suitable for
     installation and let the user pick one.
         """
         grub = bootloader.Grub2(target=disk.path())
         with utils.Chroot("/mnt/TARGET"):
+            self.mkinitrd()
+            grub.backup_config()
             grub.install()
             grub.write_config()
 
+    def mkinitrd(self):
+        LOG.debug("Creating initrd")
+        command = "mkinitrd -c -u -m i810:i915:intel:nouveau:radeon:vmwgfx"
+        try:
+            sp.call(command.split())
+        except Exception as e:
+            # initrd not supported
+            LOG.info("Initrd not supported: %s", e)
+
     def install_kernels(self):
         """Copy the kernels from the initrd to the target"""
         src = self.config["install_media"]

File vinstall/controller/bootloader.py

View file
 """
 
 
-from vinstall.core import Render, Controller, model
-from vinstall.backend.media import Disk, Partition
-from vinstall.backend import bootloader, utils, sp
-from itertools import chain
 import os
+from itertools import chain
+from vinstall.backend import bootloader, utils, sp
+from vinstall.backend.media import Disk, Partition
+from vinstall.core import Render, Controller, model, log
+
+
+LOG = log.get_logger("bootloader")
 
 
 class Bootloader(Controller):
         """Schedule command for later execution
 
         """
+        LOG.debug("Bootloader: %s", bootloader)
+        LOG.debug("Target; %s", target)
         yield self.set_bind_mounts, tuple(), "Mounting pseudo filesystems"
         yield self.install_bootloader, (bootloader, target), "Installing bootloader"
         yield self.clear_bind_mounts, tuple(), "Clearing bind mounts"
         target = disk.path()
 
         if bloader.lower() == "lilo":
-            bl = bootloader.Lilo(target)
-            for system in bootloader.OperatingSystem.all():
-                bl.add_os(system)
-	    sequence = (bl.backup_config, bl.write_config, bl.install)
+            self.install_lilo(target)
         elif bloader == "Grub2":
-            bl = bootloader.Grub2(target)
-	    sequence = (bl.backup_config, bl.install, bl.write_config)
+            self.install_grub(target)
         else:
             return
 
+    def install_lilo(self, target):
+        """ Install LILO to target
+
+        """
+        LOG.debug("Installing LILO to %s", target)
+        lilo = bootloader.Lilo(target)
+        for system in bootloader.OperatingSystem.all():
+            lilo.add_os(system)
+        with utils.Chroot("/mnt/TARGET"):
+            self.mkinitrd()
+            lilo.backup_config()
+            lilo.write_config()
+            lilo.install()
+
+    def install_grub(self, target):
+        """ Install Grub2 to target
+
+        """
+        LOG.debug("Installing Grub2 to %s", target)
+        grub2 = bootloader.Grub2(target)
         with utils.Chroot("/mnt/TARGET"):
-	    for meth in sequence:
-		meth()
-#            bl.backup_config()
-#            bl.write_config()
-#            bl.install()
+            self.mkinitrd()
+            grub2.backup_config()
+            grub2.install()
+            grub2.write_config()
+
+    def mkinitrd(self):
+        LOG.debug("Creating initrd")
+        command = "mkinitrd -c -u -m i810:i915:intel:nouveau:radeon:vmwgfx"
+        try:
+            sp.call(command.split())
+        except Exception as e:
+            # initrd not supported
+            LOG.info("Initrd not supported: %s", e)
 
     def set_bind_mounts(self):
         """Bind mount some paths into the target.
         Later steps will need this when we chroot there
 
         """
+        LOG.debug("Bind mounting filesystems")
         for point in ("sys","proc","dev"):
             cmd = "mount -o bind /%s /mnt/TARGET/%s" % (point, point)
             sp.check_call(cmd.split())