- while 1:
+ while True:
rc = dialog.run()
if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
rc = False
diff --git a/pyanaconda/iw/bootloader_main_gui.py b/pyanaconda/iw/bootloader_main_gui.py
index 3512026..ed9c9ba 100644
--- a/pyanaconda/iw/bootloader_main_gui.py
+++ b/pyanaconda/iw/bootloader_main_gui.py
@@ -47,24 +47,19 @@ class MainBootloaderWindow(InstallWindow):
def getNext(self):
# go ahead and set the device even if we already knew it
# since that won't change anything
- self.bl.setDevice(self.bldev)
-
- self.bl.drivelist = self.driveorder
+ self.bl.stage1_device = self.bldev
+ self.bl.drive_order = self.driveorder
if not self.grubCB.get_active():
# if we're not installing a boot loader, don't show the second
# screen and don't worry about other options
self.dispatch.skipStep("instbootloader", skip = 1)
-
- # kind of a hack...
- self.bl.defaultDevice = None
return
else:
self.dispatch.skipStep("instbootloader", skip = 0)
- self.bl.setUseGrub(1)
# set the password
- self.bl.setPassword(self.blpass.getPassword(), isCrypted = 0)
+ self.bl.password = self.blpass.getPassword()
# set the bootloader images based on what's in our list
self.oslist.setBootloaderImages()
@@ -76,23 +71,8 @@ class MainBootloaderWindow(InstallWindow):
if widget:
widget.set_sensitive(active)
-
- def _deviceChange(self, b, anaconda, *args):
- def __driveChange(combo, dxml, choices):
- if not choices.has_key("mbr"):
- return
-
- iter = combo.get_active_iter()
- if not iter:
- return
-
- first = combo.get_model()[iter][1]
- desc = choices["mbr"][1]
- dxml.get_widget("mbrRadio").set_label("%s - /dev/%s" %(_(desc), first))
- dxml.get_widget("mbrRadio").set_data("bootDevice", first)
-
def __genStore(combo, disks, active):
- model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
combo.set_model(model)
cell = gtk.CellRendererText()
combo.pack_start(cell, True)
@@ -102,7 +82,7 @@ class MainBootloaderWindow(InstallWindow):
i = model.append(None)
model[i] = ("%s %8.0f MB %s" %(disk.name, disk.size,
disk.description),
- "%s" %(disk.name,))
+ disk)
if disk.name == active:
combo.set_active_iter(i)
@@ -114,20 +94,32 @@ class MainBootloaderWindow(InstallWindow):
dialog.set_transient_for(self.parent)
dialog.show()
- choices = anaconda.platform.bootloaderChoices(self.bl)
+ # XXX for md stage1, should we show md, first member disk, or first
+ # disk?
+ stage1 = anaconda.platform.bootLoaderDevice
+ stage1_desc = anaconda.bootloader.device_description(stage1)
+ choices = {"mbr": (stage1, stage1_desc)}
+
+ stage2 = anaconda.platform.bootDevice
+ try:
+ stage2_desc = anaconda.bootloader.device_description(stage2)
+ except ValueError:
+ # stage2's type isn't valid as stage1, so don't offer "boot".
+ pass
+ else:
+ choices["boot"] = (stage2, stage2_desc)
+
for t in ("mbr", "boot"):
if not choices.has_key(t):
continue
(device, desc) = choices[t]
w = dxml.get_widget("%sRadio" %(t,))
- w.set_label("%s - /dev/%s" %(_(desc), device))
+ w.set_label("%s - %s" %(desc, device.path))
w.show()
- if self.bldev == device:
- w.set_active(True)
- else:
- w.set_active(False)
+ w.set_active(self.bldev == device)
w.set_data("bootDevice", device)
+ bl_disks = anaconda.platform.bootloader.drives
for i in range(1, 5):
if len(self.driveorder) < i:
break
@@ -135,15 +127,9 @@ class MainBootloaderWindow(InstallWindow):
lbl = dxml.get_widget("bd%dLabel" %(i,))
combo.show()
lbl.show()
- partitioned = anaconda.storage.partitioned
- disks = anaconda.storage.disks
- bl_disks = [d for d in disks if d in partitioned]
m = __genStore(combo, bl_disks, self.driveorder[i - 1])
- dxml.get_widget("bd1Combo").connect("changed", __driveChange, dxml, choices)
- __driveChange(dxml.get_widget("bd1Combo"), dxml, choices)
-
- while 1:
+ while True:
rc = dialog.run()
if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
break
@@ -167,62 +153,35 @@ class MainBootloaderWindow(InstallWindow):
if not iter:
continue
- act = combo.get_model()[iter][1]
+ act = combo.get_model()[iter][1].name
if act not in neworder:
neworder.append(act)
for d in self.driveorder:
if d not in neworder:
neworder.append(d)
self.driveorder = neworder
-
break
# make sure we get a valid device to say we're installing to
- if self.bl.getDevice() is not None:
- self.bldev = self.bl.getDevice()
- else:
- # we don't know what it is yet... if mbr is possible, we want
- # it, else we want the boot dev
- choices = anaconda.platform.bootloaderChoices(self.bl)
- if choices.has_key('mbr'):
- self.bldev = choices['mbr'][0]
- else:
- self.bldev = choices['boot'][0]
+ self.bldev = self.bl.stage1_device
def getScreen (self, anaconda):
# We can't just use exclusiveDisks here because of kickstart. First,
@@ -76,7 +76,6 @@ 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.drivelist = [disks[0].name]
return None
(xml, self.vbox) = gui.getGladeWidget("cleardisks.glade", "vbox")
@@ -160,7 +159,7 @@ class ClearDisksWindow (InstallWindow):
for d in disks:
rightVisible = d.name in self.anaconda.storage.config.clearPartDisks
rightActive = rightVisible and
- d.name in self.anaconda.bootloader.drivelist[:1]
+ d == self.anaconda.bootloader.drives[0]
leftVisible = not rightVisible
if hasattr(d, "wwid"):
diff --git a/pyanaconda/iw/osbootwidget.py b/pyanaconda/iw/osbootwidget.py
index 1b18070..b95c303 100644
--- a/pyanaconda/iw/osbootwidget.py
+++ b/pyanaconda/iw/osbootwidget.py
@@ -27,6 +27,7 @@ from pyanaconda import gui
import datacombo
from pyanaconda.constants import *
from pyanaconda.storage.devices import devicePathToName
+import copy
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -34,15 +35,12 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
class OSBootWidget:
"""Widget to display OSes to boot and allow adding new ones."""
buttonbar = gtk.VButtonBox()
@@ -126,7 +126,7 @@ class OSBootWidget:
self.fillOSList()
# adds/edits a new "other" os to the boot loader config
- def editOther(self, oldDevice, oldLabel, isDefault, isRoot = 0):
+ def editOther(self, image):
dialog = gtk.Dialog(_("Image"), self.parent)
dialog.add_button('gtk-cancel', gtk.RESPONSE_CANCEL)
dialog.add_button('gtk-ok', 1)
@@ -152,7 +152,7 @@ class OSBootWidget:
label = gui.MnemonicLabel(_("_Device"))
table.attach(label, 0, 1, 2, 3, gtk.FILL, 0, 10)
- if not isRoot:
+ if image.device != self.storage.rootDevice:
parts = []
for part in self.storage.partitions:
@@ -168,8 +168,8 @@ class OSBootWidget:
defindex = 0
i = 0
for part in parts:
- deviceCombo.append(part.path, part.name)
- if oldDevice and oldDevice == part.name:
+ deviceCombo.append(part.path, part)
+ if image.device and image.device == part:
defindex = i
i = i + 1
default = gtk.CheckButton(_("Default Boot _Target"))
table.attach(default, 0, 2, 3, 4, gtk.FILL, 0, 10)
- if isDefault != 0:
- default.set_active(True)
-
- if self.numentries == 1 and oldDevice != None:
+ default.set_active(image.device == self.defaultDev)
+ if len(self.images.keys()) == 1 and image.device:
default.set_sensitive(False)
- else:
- default.set_sensitive(True)
dialog.vbox.pack_start(table)
dialog.show_all()
- while 1:
+ while True:
rc = dialog.run()
# cancel
@@ -203,10 +199,10 @@ class OSBootWidget:
label = labelEntry.get_text()
- if not isRoot:
+ if not image.device == self.storage.rootDevice:
dev = deviceCombo.get_active_value()
else:
- dev = oldDevice
+ dev = image.device
if not dev:
self.intf.messageWindow(_("Error"),
@@ -235,17 +231,15 @@ class OSBootWidget:
# verify that the label hasn't been used
foundBad = 0
- for key in self.imagelist.keys():
- if dev == key:
+ for key in self.images.keys():
+ if dev.name == key:
continue
- if self.blname == "GRUB":
- thisLabel = self.imagelist[key][1]
- else:
- thisLabel = self.imagelist[key][0]
+
+ thisLabel = self.bl.image_label(self.images[key])
# if the label is the same as it used to be, they must
# have changed the device which is fine
- if thisLabel == oldLabel:
+ if thisLabel == image.label:
continue
if thisLabel == label:
@@ -259,32 +253,23 @@ class OSBootWidget:
continue
# they could be duplicating a device, which we don't handle
- if dev in self.imagelist.keys() and (not oldDevice or
- dev != oldDevice):
+ if dev.name in self.images.keys() and (not image.device or
+ dev != image.device):
self.intf.messageWindow(_("Duplicate Device"),
_("This device is already being "
"used for another boot entry."),
type="warning")
continue
- # if we're editing a previous, get what the old info was for
- # labels. otherwise, make it something safe for grub and the
- # device name for lilo for lack of any better ideas
- if oldDevice:
- (oldshort, oldlong, oldisroot) = self.imagelist[oldDevice]
- else:
- (oldshort, oldlong, oldisroot) = (dev, label, None)
-
# if we're editing and the device has changed, delete the old
- if oldDevice and dev != oldDevice:
- del self.imagelist[oldDevice]
+ if image.device and dev != image.device:
+ del self.images[image.device.name]
+ image.device = dev
+
+ image.label = label
# go ahead and add it
- if self.blname == "GRUB":
- self.imagelist[dev] = (oldshort, label, isRoot)
- else:
- self.imagelist[dev] = (label, oldlong, isRoot)
-
+ self.images[dev.name] = image
if default.get_active():
self.defaultDev = dev
@@ -300,27 +285,22 @@ class OSBootWidget:
if not iter:
return None
def deleteEntry(self, widget, *args):
rc = self.getSelected()
if not rc:
return
- (dev, label, isDefault, isRoot) = rc
- if not isRoot:
- del self.imagelist[dev]
- if isDefault:
- keys = self.imagelist.keys()
- keys.sort()
- self.defaultDev = keys[0]
+ if image.device != self.storage.rootDevice:
+ del self.images[image.device.name]
+ if image.device == self.defaultDev:
+ devs = [i.device for i in self.images]
+ devs.sort(key=lambda d: d.name)
+ self.defaultDev = devs[0]
self.fillOSList()
else:
@@ -335,68 +315,45 @@ class OSBootWidget:
rc = self.getSelected()
if not rc:
return
- (dev, label, isDefault, isRoot) = rc
- self.editOther(dev, label, isDefault, isRoot)
+ self.editOther(rc)
# the default os was changed in the treeview
def toggledDefault(self, data, row):
iter = self.osStore.get_iter((int(row),))
- dev = self.osStore.get_value(iter, 2)
- self.defaultDev = devicePathToName(dev)
+ self.defaultDev = self.osStore.get_value(iter, 3).device
self.fillOSList()
# fill in the os list tree view
def fillOSList(self):
self.osStore.clear()
- keys = self.imagelist.keys()
- keys.sort()
-
- for dev in keys:
- (label, longlabel, fstype) = self.imagelist[dev]
- device = self.storage.devicetree.getDeviceByName(dev)
- if self.blname == "GRUB":
- theLabel = longlabel
- else:
- theLabel = label
+ devs = sorted(self.images.keys())
+ for dev in devs:
+ image = self.images[dev]
# if the label is empty, remove from the image list and don't
# worry about it
- if not theLabel:
- del self.imagelist[dev]
+ if not image.label:
+ del self.images[dev]
continue
- # FIXME: I really shouldn't have such intimate knowledge of
- # the bootloader object
def setBootloaderImages(self):
- "Apply the changes from our list into the self.bl object"
- # make a copy of our image list to shove into the bl struct
- self.bl.images.images = {}
- for key in self.imagelist.keys():
- self.bl.images.images[key] = self.imagelist[key]
- self.bl.images.setDefault(self.defaultDev)
+ """Apply the changes from our list into the self.bl object."""
+ self.bl.clear_images()
+ for image in self.images.values():
+ self.bl.add_image(image)
+ if image.device == self.defaultDev:
+ self.bl.default = image
diff --git a/pyanaconda/iw/timezone_gui.py b/pyanaconda/iw/timezone_gui.py
index 39037ae..0d2313b 100644
--- a/pyanaconda/iw/timezone_gui.py
+++ b/pyanaconda/iw/timezone_gui.py
@@ -25,7 +25,6 @@ from scdate.core import zonetab
from timezone_map_gui import TimezoneMap
from iw_gui import *
-from pyanaconda.bootloader import hasWindows
from pyanaconda.constants import *
import gettext
@@ -93,7 +92,7 @@ class TimezoneWindow(InstallWindow):
self.utcCheckbox.set_active(asUTC)
if not anaconda.ksdata:
- self.utcCheckbox.set_active(not hasWindows(anaconda.bootloader))
+ self.utcCheckbox.set_active(not anaconda.bootloader.has_windows)
self.update_radio = gtk.RadioButton(None, _("_Update boot loader configuration"))
updatestr = _("This will update your current boot loader.")
- if newToLibata or (self.type is None or self.bootDev is None):
- if newToLibata:
- current = _("Due to system changes, your boot loader "
- "configuration can not be automatically updated.")
- else:
- current = _("The installer is unable to detect the boot loader "
- "currently in use on your system.")
+ if (not self.bl.can_update) or
+ (self.type is None or self.bootDev is None):
+ current = _("The installer is unable to detect the boot loader "
+ "currently in use on your system.")
self.update_label = gtk.Label("%s" % (updatestr,))
self.update_radio.set_sensitive(False)
self.update_label.set_sensitive(False)
- update = 0
+ update = False
else:
current = _("The installer has detected the %(type)s boot loader "
"currently installed on %(bootDev)s.")
@@ -138,7 +79,7 @@ class UpgradeBootloaderWindow (InstallWindow):
self.update_label = gtk.Label("%s %s" % (updatestr,
_("This is the recommended option.")))
self.update_radio.set_active(False)
- update = 1
+ update = True
self.newbl_radio = gtk.RadioButton(self.update_radio,
_("_Create new boot loader "
@@ -165,10 +106,8 @@ class UpgradeBootloaderWindow (InstallWindow):
str = _("What would you like to do?")
# if they have one, the default is to update, otherwise the
# default is to not touch anything
- if update == 1:
+ if update:
default = self.update_radio
- elif newToLibata:
- default = self.newbl_radio
else:
default = self.nobl_radio
diff --git a/pyanaconda/iw/zipl_gui.py b/pyanaconda/iw/zipl_gui.py
index a4ea01d..81cd0a2 100644
--- a/pyanaconda/iw/zipl_gui.py
+++ b/pyanaconda/iw/zipl_gui.py
@@ -42,8 +42,7 @@ class ZiplWindow (InstallWindow):
pass
import os, sys
from pyanaconda import isys
-import string
import copy
from pyanaconda import network
import parted
@@ -55,7 +54,7 @@ class PartitionTypeWindow:
def __call__(self, screen, anaconda):
self.anaconda = anaconda
- while 1:
+ while True:
g = GridFormHelp(screen, _("Partitioning Type"), "autopart", 1, 6)
txt = TextboxReflowed(65, _("Installation requires partitioning of your hard drive. The default layout is suitable for most users. Select what space to use and which drives to use as the install target."))
@@ -132,7 +131,6 @@ class PartitionTypeWindow:
addDialog = addDriveDialog(anaconda)
if addDialog.addDriveDialog(screen) != INSTALL_BACK:
anaconda.storage.reset()
- anaconda.bootloader.updateDriveList()
continue
if res == TEXT_BACK_CHECK:
diff --git a/pyanaconda/textw/timezone_text.py b/pyanaconda/textw/timezone_text.py
index d30ed41..efffc73 100644
--- a/pyanaconda/textw/timezone_text.py
+++ b/pyanaconda/textw/timezone_text.py
@@ -19,12 +19,10 @@
#
import sys
-import string
from pyanaconda import iutil
from time import *
from snack import *
from constants_text import *
-from pyanaconda.bootloader import hasWindows
from scdate.core import zonetab
from pyanaconda.constants import *
@@ -53,7 +51,7 @@ class TimezoneWindow:
t = TextboxReflowed(30,
_("In which time zone are you located?"))
- if not anaconda.ksdata and not hasWindows(anaconda.bootloader):
+ if not anaconda.ksdata and not anaconda.bootloader.has_windows:
asUtc = True
- (update, nobl) = (0, 0)
- if self.dispatch.stepInSkipList("instbootloader"):
- nobl = 1
- elif not (newToLibata or self.type is None or self.bootDev is None):
- update = 1
-
- if newToLibata or self.type is None or self.bootDev is None:
- if newToLibata:
- t = TextboxReflowed(53,
- _("Due to system changes, your boot loader "
- "configuration can not be automatically updated."))
- else:
- t = TextboxReflowed(53,
- _("The installer is unable to detect the boot loader "
- "currently in use on your system."))
-
+ update = False
+ nobl = False
+ if anaconda.dispatch.stepInSkipList("instbootloader") :
+ nobl = True
+ elif self.type and self.bootDev:
+ update = True
+
+ if (not anaconda.bootloader.can_update) or
+ (self.type is None or self.bootDev is None):
+ t = TextboxReflowed(53,
+ _("The installer is unable to detect the boot loader "
+ "currently in use on your system."))
screen.popWindow()
return INSTALL_OK
diff --git a/pyanaconda/textw/zipl_text.py b/pyanaconda/textw/zipl_text.py
index 1a546e2..b50b890 100644
--- a/pyanaconda/textw/zipl_text.py
+++ b/pyanaconda/textw/zipl_text.py
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import string
from snack import *
from constants_text import *
@@ -35,33 +34,16 @@ class ZiplWindow:
t = TextboxReflowed(53,
_("The z/IPL Boot Loader will be installed "
"on your system after installation is complete. "
- "You can now enter any additional kernel and "
- "chandev parameters which your machine or your "
- "setup require."))
+ "You can now enter any additional kernel parameters "
+ "required by your machine or setup."))