[PATCH 07/13] Add a "boot drive" concept to the bootloader since stage1 types vary.

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

 



---
 pyanaconda/bootloader.py           |   21 ++++++++++++++++++++-
 pyanaconda/iw/cleardisks_gui.py    |    3 ++-
 pyanaconda/storage/partitioning.py |    6 +++---
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index dcb022b..791b1fc 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -263,6 +263,9 @@ class BootLoader(object):
         # the device the bootloader will be installed on
         self._stage1_device = None
 
+        # the "boot drive", meaning the drive we prefer stage1 be on
+        self.stage1_drive = None
+
         self._update_only = False
 
     #
@@ -283,6 +286,7 @@ class BootLoader(object):
 
         log.debug("new bootloader stage1 device: %s" % device.name)
         self._stage1_device = device
+        self.stage1_drive = device.disks[0]
 
     @property
     def stage2_device(self):
@@ -332,6 +336,10 @@ class BootLoader(object):
         # XXX requiring partitioned may break clearpart
         drives = [d for d in self.storage.disks if d.partitioned]
         self._drives = self._sort_drives(drives)
+
+        # set "boot drive"
+        self.stage1_drive = self._drives[0]
+
         return self._drives
 
     #
@@ -503,7 +511,18 @@ class BootLoader(object):
         for slot in slots:
             devices.extend(slot)
 
-        return self._sort_drives(devices)
+        devices = self._sort_drives(devices)
+
+        # if a boot drive has been chosen put it, and devices on it, first
+        # XXX should this be done in _sort_drives instead?
+        if self.stage1_drive:
+            boot_devs = [d for d in devices if self.stage1_drive in d.disks]
+            if len(boot_devs) != len(devices):
+                for dev in reversed(boot_devs):
+                    idx = devices.index(dev)
+                    devices.insert(0, devices.pop(idx))
+
+        return devices
 
     #
     # boot/stage2 device access
diff --git a/pyanaconda/iw/cleardisks_gui.py b/pyanaconda/iw/cleardisks_gui.py
index cd685e8..36453a4 100644
--- a/pyanaconda/iw/cleardisks_gui.py
+++ b/pyanaconda/iw/cleardisks_gui.py
@@ -62,7 +62,7 @@ class ClearDisksWindow (InstallWindow):
         cleardisks.sort(self.anaconda.storage.compareDisks)
 
         self.anaconda.storage.config.clearPartDisks = cleardisks
-        self.anaconda.bootloader.stage1_device = bootDisk
+        self.anaconda.bootloader.stage1_drive = bootDisk
 
     def getScreen (self, anaconda):
         # We can't just use exclusiveDisks here because of kickstart.  First,
@@ -76,6 +76,7 @@ class ClearDisksWindow (InstallWindow):
         # Skip this screen as well if there's only one disk to use.
         if len(disks) == 1:
             anaconda.storage.config.clearPartDisks = [disks[0].name]
+            anaconda.bootloader.stage1_drive = disks[0]
             return None
 
         (xml, self.vbox) = gui.getGladeWidget("cleardisks.glade", "vbox")
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index 30aee90..9aa3c0b 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -410,10 +410,10 @@ def clearPartitions(storage, bootloader=None):
     # make sure that the the boot device has the correct disklabel type if
     # we're going to completely clear it.
     for disk in storage.partitioned:
-        if not bootloader or not bootloader.stage1_device:
+        if not bootloader or not bootloader.stage1_drive:
             break
 
-        if disk in bootloader.stage1_device.disks:
+        if disk != bootloader.stage1_drive:
             continue
 
         if storage.config.clearPartType != CLEARPART_TYPE_ALL or \
@@ -961,7 +961,7 @@ def allocatePartitions(storage, disks, partitions, freespace, bootloader=None):
         req_disks.sort(key=lambda d: d.name, cmp=storage.compareDisks)
         boot_index = None
         for disk in req_disks:
-            if bootloader and disk == bootloader.stage1_device.disks[0]:
+            if bootloader and disk == bootloader.stage1_drive:
                 boot_index = req_disks.index(disk)
 
         if boot_index is not None and len(req_disks) > 1:
-- 
1.7.3.4

_______________________________________________
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