draft patches for syslinux/extlinux support

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

 



These are against the F19 alpha and have been tested on a local virt-install
but not widely. First patch adds the bootloader type but does nothing with
it; second patch adds an extlinux command line option which activates it.

In progress but not yet included, third patch to add an option to the
bootloader kickstart directive.


-- 
Matthew Miller  ☁☁☁  Fedora Cloud Architect  ☁☁☁  <mattdm@xxxxxxxxxxxxxxxxx>
>From fc1545628f86e92de031a6f80bc2dda6299d616f Mon Sep 17 00:00:00 2001
From: Matthew Miller <mattdm@xxxxxxxxxx>
Date: Thu, 25 Apr 2013 15:54:36 -0400
Subject: [PATCH 1/2] Add extlinux as a bootloader type.

This patch adds an EXTLINUX bootloader class but does nothing to actually
enable it.
---
 pyanaconda/bootloader.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 81bd441..ea03101 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -18,6 +18,7 @@
 # Red Hat, Inc.
 #
 # Red Hat Author(s): David Lehman <dlehman@xxxxxxxxxx>
+#                    Matthew Miller <mattdm@xxxxxxxxxx> (extlinux portion)
 #
 
 import collections
@@ -2112,6 +2113,94 @@ class UBOOT(BootLoader):
         if rc:
             raise BootLoaderError("bootloader install failed")
 
+class EXTLINUX(BootLoader):
+    name = "EXTLINUX"
+    _config_file = "extlinux.conf"
+
+    # stage1 device requirements
+    stage1_device_types = ["disk"]
+
+    # stage2 device requirements
+    stage2_format_types = ["ext4", "ext3", "ext2"]
+    stage2_device_types = ["partition"]
+    stage2_bootable = True
+
+    packages = ["syslinux-extlinux"]
+
+    @property
+    def config_dir(self):
+        if self.stage2_device.format.mountpoint == "/boot":
+            return "/boot"
+        else:
+            return "/etc"
+
+    @property
+    def config_file(self):
+        return "%s/%s" % (self.config_dir, self._config_file)
+
+    @property
+    def boot_dir(self):
+        return "/boot"
+
+    def write_config_images(self, config):
+        for image in self.images:
+            args = Arguments()
+            args.add("root=%s" % image.device.fstabSpec)
+            args.add("initrd=%s/%s" % (self.boot_prefix, image.initrd))
+            args.update(self.boot_args)
+            log.info("bootloader.py: used boot args: %s " % args)
+            stanza = ("label %(label)s (%(version)s)\n"
+                      "\tkernel %(boot_dir)s/%(kernel)s\n"
+                      "\tappend %(args)s\n\n"
+                      % {"label": self.image_label(image),
+                         "version": image.version,
+                         "kernel": image.kernel,
+                         "args": args,
+                         "boot_dir": self.boot_dir})
+            config.write(stanza)
+
+    def write_config_header(self, config):
+        header = ("# extlinux.conf generated by anaconda\n\n"
+                  "ui menu.c32\n\n"
+                  "menu autoboot Welcome to %(productName)s. Automatic boot in # second{,s}. Press a key for options.\n"
+                  "menu title %(productName)s Boot Options.\n"
+                  "menu hidden\n\n"
+                  "timeout %(timeout)d\n"
+                  "#totaltimeout 9000\n\n"
+                  % { "productName": productName, "timeout": self.timeout *10,
+                     "default": self.image_label(self.default)})
+        config.write(header)
+        self.write_config_password(config)
+
+    def write_config_password(self, config):
+        if self.password:
+            config.write("menu master passwd %s\n" % self.password)
+            config.write("menu notabmsg Press [Tab] and enter the password to edit options")
+
+    def write_config_post(self):
+        etc_extlinux = os.path.normpath(ROOT_PATH + "/etc/" + self._config_file)
+        if not os.access(etc_extlinux, os.R_OK):
+            try:
+                os.symlink("../boot/%s" % self._config_file, etc_extlinux)
+            except OSError as e:
+                log.warning("failed to create /etc/extlinux.conf symlink: %s" % e)
+
+    def write_config(self):
+        super(EXTLINUX, self).write_config()
+
+    #
+    # installation
+    #
+
+    def install(self):
+        backup = "%s/backup.b" % self.config_dir
+        args = ["--install", "/boot/extlinux"]
+        rc = iutil.execWithRedirect("extlinux", args,
+                                    root=ROOT_PATH)
+
+        if rc:
+            raise BootLoaderError("bootloader install failed")
+
 
 # every platform that wants a bootloader needs to be in this dict
 bootloader_by_platform = {platform.X86: GRUB2,
-- 
1.8.2.1

>From 2e324813d83ce98473ab2feb04d0da6ca46d5fa7 Mon Sep 17 00:00:00 2001
From: Matthew Miller <mattdm@xxxxxxxxxx>
Date: Fri, 26 Apr 2013 15:55:38 -0400
Subject: [PATCH 2/2] Add extlinux command-line option.

Note that there's no attempt to validate that this will work for your platform
or anything; it assumes that if you ask for it, you want to try.
---
 anaconda                 | 4 ++++
 pyanaconda/bootloader.py | 5 ++++-
 pyanaconda/flags.py      | 4 ++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/anaconda b/anaconda
index 57065f9..4bfc273 100755
--- a/anaconda
+++ b/anaconda
@@ -285,6 +285,7 @@ def parseOptions(argv=None, cmdline=None):
     op.add_option("--nomemcheck", action="store_false", dest="memcheck")
     op.add_option("--leavebootorder", action="store_true", default=False)
     op.add_option("--noeject", action="store_false", dest="eject", default=True)
+    op.add_option("--extlinux", action="store_true", default=False)
 
     # some defaults change based on cmdline flags
     if cmdline is not None:
@@ -823,6 +824,9 @@ if __name__ == "__main__":
     if opts.armPlatform:
         flags.armPlatform = opts.armPlatform
 
+    if opts.extlinux:
+        flags.extlinux = opts.extlinux
+
     # set flags
     flags.dmraid = opts.dmraid
     flags.mpath = opts.mpath
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index ea03101..df8ee74 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -2215,7 +2215,10 @@ bootloader_by_platform = {platform.X86: GRUB2,
 
 def get_bootloader():
     platform_name = platform.platform.__class__.__name__
-    cls = bootloader_by_platform.get(platform.platform.__class__, BootLoader)
+    if flags.extlinux:
+        cls = EXTLINUX
+    else:
+        cls = bootloader_by_platform.get(platform.platform.__class__, BootLoader)
     log.info("bootloader %s on %s platform" % (cls.__name__, platform_name))
     return cls()
 
diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index 5ba291c..7a22c90 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -66,6 +66,7 @@ class Flags(object):
         self.dirInstall = False
         self.askmethod = False
         self.eject = True
+        self.extlinux = False
         self.gpt = False
         self.leavebootorder = False
         self.testing = False
@@ -88,6 +89,9 @@ class Flags(object):
         if not selinux.is_selinux_enabled():
             self.selinux = 0
 
+        if "extlinux" in self.cmdline:
+            self.extlinux = True
+
         if "gpt" in self.cmdline:
             self.gpt = True
 
-- 
1.8.2.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux