[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Allow preseeding the installer



---
We use this when building the LinuxCNC live image to preseed the
root-login to false (root via sudo) and to add "dialout" to the default
group list (to give access to serial hardware such as MODBUS devices)

 lwr/bootloader.py |  7 ++++---
 lwr/run.py        | 13 +++++++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lwr/bootloader.py b/lwr/bootloader.py
index 69c27a2..77509f6 100644
--- a/lwr/bootloader.py
+++ b/lwr/bootloader.py
@@ -26,26 +26,27 @@ class BootloaderConfig(object):
                                  'initrd': '/live/initrd.img-%s' % (version,),
                                 })
 
-    def add_installer(self, kernel, ramdisk):  # pylint: disable=no-self-use
+    def add_installer(self, kernel, ramdisk, extra=''):  # pylint: disable=no-self-use
         self.entries.append({
                              'description': 'Graphical Debian Installer',
                              'type': 'linux',
                              'kernel': '/d-i/gtk/%s' % (os.path.basename(kernel),),
                              'initrd': '/d-i/gtk/%s' % (os.path.basename(ramdisk),),
-                             'cmdline': 'append video=vesa:ywrap,mtrr vga=788'
+                             'cmdline': 'append video=vesa:ywrap,mtrr vga=788 ' + extra
                             })
         self.entries.append({
                              'description': 'Debian Installer',
                              'type': 'linux',
                              'kernel': '/d-i/%s' % (os.path.basename(kernel),),
                              'initrd': '/d-i/%s' % (os.path.basename(ramdisk),),
+                             'cmdline': extra
                             })
         self.entries.append({
                              'description': 'Debian Installer with Speech Synthesis',
                              'type': 'linux',
                              'kernel': '/d-i/gtk/%s' % (os.path.basename(kernel),),
                              'initrd': '/d-i/gtk/%s' % (os.path.basename(ramdisk),),
-                             'cmdline': 'speakup.synth=soft',
+                             'cmdline': 'speakup.synth=soft ' + extra,
                             })
     def add_live_localisation(self):
         # FIXME: need declarative paths
diff --git a/lwr/run.py b/lwr/run.py
index 1f28ab6..05e7beb 100644
--- a/lwr/run.py
+++ b/lwr/run.py
@@ -17,8 +17,8 @@ import cliapp
 import logging
 import pycurl
 import tempfile
+import shutil
 import subprocess
-from shutil import rmtree
 from tarfile import TarFile
 from lwr.vm import VMDebootstrap
 from lwr.isolinux import install_isolinux
@@ -111,6 +111,9 @@ class LiveWrapper(cliapp.Application):
             ['di-daily'], 'Use the daily Debian Installer builds not releases',
             default=False, group="Debian Installer")
         self.settings.string(
+            ['preseed'], 'Include the named preseed file for the installer',
+            default=None, group="Debian Installer")
+        self.settings.string(
             ['customise'], 'Customisation script to run with vmdebootstrap (default: %default)',
             metavar='CUSTOMISE',
             group='Base Settings',
@@ -292,6 +295,10 @@ class LiveWrapper(cliapp.Application):
             handler.clean_up_apt()
             logging.info("... firmware deb downloads")
 
+        if self.settings['preseed']:
+            logging.info("Copying preseed file %s" % self.settings['preseed'])
+            shutil.copy(self.settings['preseed'], os.path.join(self.cdroot.path, "preseed.cfg"))
+
         # Generate boot config
         bootconfig = BootloaderConfig(self.cdroot.path)
 
@@ -301,7 +308,9 @@ class LiveWrapper(cliapp.Application):
             locallivecfg.add_live_localisation()
             bootconfig.add_submenu('Debian Live with Localisation Support', locallivecfg)
         if self.settings['installer']:
-            bootconfig.add_installer(self.kernel_path, self.ramdisk_path)
+            bootconfig.add_installer(self.kernel_path, self.ramdisk_path,
+                "preseed/file=/cdrom/preseed.cfg"
+                if self.settings['preseed'] else '')
 
         # Install isolinux if selected
         if self.settings['isolinux']:
-- 
2.11.0


Reply to: