diff options
-rw-r--r-- | autopart.py | 50 | ||||
-rw-r--r-- | dispatch.py | 16 | ||||
-rw-r--r-- | installclass.py | 4 | ||||
-rw-r--r-- | installclasses/custom.py | 6 | ||||
-rw-r--r-- | installclasses/server.py | 8 | ||||
-rw-r--r-- | installclasses/workstation.py | 6 | ||||
-rw-r--r-- | instdata.py | 15 | ||||
-rw-r--r-- | iw/partition_gui.py | 20 | ||||
-rw-r--r-- | iw/partmethod_gui.py | 20 | ||||
-rw-r--r-- | kickstart.py | 4 | ||||
-rw-r--r-- | partitioning.py | 65 | ||||
-rw-r--r-- | textw/partition_text.py | 16 | ||||
-rw-r--r-- | textw/partmethod_text.py | 14 |
13 files changed, 136 insertions, 108 deletions
diff --git a/autopart.py b/autopart.py index b3f1ad1b5..df24a0d29 100644 --- a/autopart.py +++ b/autopart.py @@ -632,7 +632,10 @@ def doPartitioning(diskset, requests, doRefresh = 1): # given clearpart specification execute it # probably want to reset diskset and partition request lists before calling # this the first time -def doClearPartAction(id, type, cleardrives): +def doClearPartAction(partitions, diskset): + type = partitions.autoClearPartType + cleardrives = partitions.autoClearPartDrives + if type == CLEARPART_TYPE_LINUX: linuxOnly = 1 elif type == CLEARPART_TYPE_ALL: @@ -642,14 +645,14 @@ def doClearPartAction(id, type, cleardrives): else: raise ValueError, "Invalid clear part type in doClearPartAction" - drives = id.diskset.disks.keys() + drives = diskset.disks.keys() drives.sort() for drive in drives: # skip drives not in clear drive list if cleardrives and len(cleardrives) > 0 and not drive in cleardrives: continue - disk = id.diskset.disks[drive] + disk = diskset.disks[drive] part = disk.next_partition() while part: if (part.type & parted.PARTITION_FREESPACE) or (part.type & parted.PARTITION_METADATA): @@ -660,40 +663,39 @@ def doClearPartAction(id, type, cleardrives): else: ptype = None if (linuxOnly == 0) or (ptype and (ptype.isLinuxNativeFS())): - old = id.partrequests.getRequestByDeviceName(get_partition_name(part)) - id.partrequests.removeRequest(old) + old = partitions.getRequestByDeviceName(get_partition_name(part)) + partitions.removeRequest(old) - drive = part.geom.disk.dev.path[5:] + drive = get_partition_drive(part) delete = DeleteSpec(drive, part.geom.start, part.geom.end) - id.partrequests.addDelete(delete) + partitions.addDelete(delete) part = disk.next_partition(part) # set the diskset up - doPartitioning(id.diskset, id.partrequests, doRefresh = 1) + doPartitioning(diskset, partitions, doRefresh = 1) for drive in drives: if cleardrives and len(cleardrives) > 0 and not drive in cleardrives: continue - disk = id.diskset.disks[drive] + disk = diskset.disks[drive] ext = disk.extended_partition if ext and len(get_logical_partitions(disk)) == 0: delete = DeleteSpec(drive, ext.geom.start, ext.geom.end) - old = id.partrequests.getRequestByDeviceName(get_partition_name(ext)) - id.partrequests.removeRequest(old) - id.partrequests.addDelete(delete) - deletePart(id.diskset, delete) + old = partitions.getRequestByDeviceName(get_partition_name(ext)) + partitions.removeRequest(old) + partitions.addDelete(delete) + deletePart(diskset, delete) continue -def doAutoPartition(dir, id, intf): - +def doAutoPartition(dir, diskset, partitions, intf): if dir == DISPATCH_BACK: - id.diskset.refreshDevices() - id.partrequests.setFromDisk(id.diskset) + diskset.refreshDevices() + partitions.setFromDisk(diskset) return # if no auto partition info in instclass we bail - if len(id.autoPartitionRequests) < 1: + if len(partitions.autoPartitionRequests) < 1: return DISPATCH_NOOP # reset drive and request info to original state @@ -701,16 +703,16 @@ def doAutoPartition(dir, id, intf): ## id.diskset.refreshDevices() ## id.partrequests = PartitionRequests(id.diskset) - doClearPartAction(id, id.autoClearPartType, id.autoClearPartDrives) + doClearPartAction(partitions, diskset) - for request in id.autoPartitionRequests: - id.partrequests.addRequest(request) + for request in partitions.autoPartitionRequests: + partitions.addRequest(request) try: - doPartitioning(id.diskset, id.partrequests, doRefresh = 0) + doPartitioning(diskset, partitions, doRefresh = 0) except PartitioningError, msg: # restore drives to original state - id.diskset.refreshDevices() - id.partrequests = PartitionRequests(id.diskset) + diskset.refreshDevices() + partitions.setFromDisk(diskset) intf.messageWindow(_("Error Partitioning"), _("Could not allocated requested partitions: %s.") % (msg.value)) diff --git a/dispatch.py b/dispatch.py index 8bf8289e0..7258c21b8 100644 --- a/dispatch.py +++ b/dispatch.py @@ -50,13 +50,13 @@ installSteps = [ ( "reconfigkeyboard", ("id.instLanguage", "id.keyboard" ) ), ( "installtype", ("dispatch", "id", "method", "intf") ), ( "findinstall", ("dispatch", "intf", "id", "instPath") ), - ( "partitionmethod", ("id",) ), - ( "partitionobjinit", partitionObjectsInitialize, ("id", "dir") ), - ( "partitionmethodsetup", partitionMethodSetup, ("id", "dispatch") ), - ( "autopartition", ("id", "id.diskset", "intf") ), - ( "autopartitionexecute", doAutoPartition, ("dir", "id", "intf")), - ( "fdisk", ("id.useFdisk", "id.diskset", "id.partrequests")), - ( "partition", ("id.fsset", "id.diskset", "id.partrequests", "intf")), + ( "partitionmethod", ("id.partitions",) ), + ( "partitionobjinit", partitionObjectsInitialize, ("id.diskset", "id.partitions", "dir") ), + ( "partitionmethodsetup", partitionMethodSetup, ("id.partitions", "dispatch") ), + ( "autopartition", ("id.diskset", "id.partitions", "intf") ), + ( "autopartitionexecute", doAutoPartition, ("dir", "id.diskset", "id.partitions", "intf")), + ( "fdisk", ("id.useFdisk", "id.diskset", "id.partitions")), + ( "partition", ("id.fsset", "id.diskset", "id.partitions", "intf")), ( "upgrademount", upgradeMountFilesystems, ("intf", "id.upgradeRoot", "id.fsset", "instPath")), ( "upgradecontinue", queryUpgradeContinue, ("intf", "dir")), @@ -65,7 +65,7 @@ installSteps = [ ( "addswap", ("intf", "id.fsset", "instPath", "id.upgradeSwapInfo") ), ( "partitiondone", partitioningComplete, ("dispatch", "id.bootloader", "id.fsset", "id.diskset", - "id.partrequests") ), + "id.partitions") ), ( "bootloadersetup", bootloaderSetupChoices, ("dispatch", "id.bootloader", "id.fsset", "id.diskset") ), ( "bootloader", ("dispatch", "id.bootloader", "id.fsset", "id.diskset") ), diff --git a/installclass.py b/installclass.py index 085b0da93..74f7ab9bc 100644 --- a/installclass.py +++ b/installclass.py @@ -46,8 +46,8 @@ class BaseInstallClass: id.bootloader.useGrubVal = 0 def setClearParts(self, id, clear, drives = None, warningText = None): - id.autoClearPartType = clear - id.autoClearPartDrives = drives + id.partitions.autoClearPartType = clear + id.partitions.autoClearPartDrives = drives # XXX hack for install help text in GUI mode if clear == CLEARPART_TYPE_LINUX: self.clearType = "wkst" diff --git a/installclasses/custom.py b/installclasses/custom.py index 3dc8b41a2..e19650c0a 100644 --- a/installclasses/custom.py +++ b/installclasses/custom.py @@ -23,9 +23,9 @@ class InstallClass(BaseInstallClass): (minswap, maxswap) = iutil.swapSuggestion() autorequests.append((None, "swap", minswap, maxswap, 1, 1)) - id.autoClearPartType = CLEARPART_TYPE_LINUX - id.autoClearPartDrives = [] - id.autoPartitionRequests = autoCreatePartitionRequests(autorequests) + id.partitions.autoClearPartType = CLEARPART_TYPE_LINUX + id.partitions.autoClearPartDrives = [] + id.partitions.autoPartitionRequests = autoCreatePartitionRequests(autorequests) def __init__(self, expert): BaseInstallClass.__init__(self, expert) diff --git a/installclasses/server.py b/installclasses/server.py index 48cd3201d..7f58f2e36 100644 --- a/installclasses/server.py +++ b/installclasses/server.py @@ -40,16 +40,16 @@ class InstallClass(BaseInstallClass): autorequests = [ ("/", None,256, None, 1, 1), ("/boot", None, 50, None, 0, 1), - ("/usr", None, 512, None, 0, 1), + ("/usr", None, 800, None, 0, 1), ("/var", None, 256, None, 0, 1), ("/home", None, 512, None, 1, 1) ] (minswap, maxswap) = iutil.swapSuggestion() autorequests.append((None, "swap", minswap, maxswap, 1, 1)) - id.autoClearPartType = CLEARPART_TYPE_ALL - id.autoClearPartDrives = [] - id.autoPartitionRequests = autoCreatePartitionRequests(autorequests) + id.partitions.autoClearPartType = CLEARPART_TYPE_ALL + id.partitions.autoClearPartDrives = [] + id.partitions.autoPartitionRequests = autoCreatePartitionRequests(autorequests) def __init__(self, expert): BaseInstallClass.__init__(self, expert) diff --git a/installclasses/workstation.py b/installclasses/workstation.py index 580bd151f..4c0bcd5eb 100644 --- a/installclasses/workstation.py +++ b/installclasses/workstation.py @@ -37,9 +37,9 @@ class InstallClass(BaseInstallClass): (minswap, maxswap) = iutil.swapSuggestion() autorequests.append((None, "swap", minswap, maxswap, 1, 1)) - id.autoClearPartType = CLEARPART_TYPE_LINUX - id.autoClearPartDrives = [] - id.autoPartitionRequests = autoCreatePartitionRequests(autorequests) + id.partitions.autoClearPartType = CLEARPART_TYPE_LINUX + id.partitions.autoClearPartDrives = None + id.partitions.autoPartitionRequests = autoCreatePartitionRequests(autorequests) def __init__(self, expert): BaseInstallClass.__init__(self, expert) diff --git a/instdata.py b/instdata.py index 1a966084f..b76856db7 100644 --- a/instdata.py +++ b/instdata.py @@ -22,6 +22,7 @@ import desktop import users import fsset import bootloader +import partitioning from flags import * from simpleconfig import SimpleConfigFile @@ -59,21 +60,13 @@ class InstallData: self.hdList = None self.comps = None self.upgrade = Boolean() + # XXX move fsset and/or diskset into Partitions object? self.fsset.reset() -# -# delay setting these until we know the partition method -# self.diskset = partitioning.DiskSet() -# self.partrequests = partitioning.PartitionRequests(self.diskset) - self.diskset = None - self.partrequests = None - self.autoPartitionRequests = [] - self.autoClearPartType = None - self.autoClearPartDrives = [] + self.diskset = partitioning.DiskSet() + self.partitions = partitioning.Partitions() self.bootloader = bootloader.getBootloader() self.dependencies = [] self.dbpath = None - self.useFdisk = 0 - self.useAutopartitioning = 1 self.upgradeRoot = None self.upgradeSwapInfo = None diff --git a/iw/partition_gui.py b/iw/partition_gui.py index 1407f320c..ff5c25624 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -1197,11 +1197,11 @@ class AutoPartitionWindow(InstallWindow): def getNext(self): if self.clearLinuxRB.get_active(): - self.id.autoClearPartType = CLEARPART_TYPE_LINUX + self.partitions.autoClearPartType = CLEARPART_TYPE_LINUX elif self.clearAllRB.get_active(): - self.id.autoClearPartType = CLEARPART_TYPE_ALL + self.partitions.autoClearPartType = CLEARPART_TYPE_ALL else: - self.id.autoClearPartType = CLEARPART_TYPE_NONE + self.partitions.autoClearPartType = CLEARPART_TYPE_NONE allowdrives = [] for i in self.driveclist.selection: @@ -1213,18 +1213,18 @@ class AutoPartitionWindow(InstallWindow): "Red Hat Linux installed onto."), type = "ok") raise gui.StayOnScreen - self.id.autoClearPartDrives = allowdrives + self.partitions.autoClearPartDrives = allowdrives return None - def getScreen(self, id, diskset, intf): + def getScreen(self, diskset, partitions, intf): - # XXX Change to not use id in (use more specific components of id) - self.id = id self.diskset = diskset - type = id.autoClearPartType - cleardrives = id.autoClearPartDrives + self.partitions = partitions + self.intf = intf + type = partitions.autoClearPartType + cleardrives = partitions.autoClearPartDrives box = GtkVBox (FALSE) box.set_border_width (5) @@ -1274,7 +1274,7 @@ class AutoPartitionWindow(InstallWindow): label = GtkLabel(_("Which drives do you want to use for Linux?")) label.set_alignment(0.0, 0.0) drivesbox.pack_start(label, FALSE, FALSE, 10) - self.driveclist = createAllowedDrivesClist(id.diskset.disks, + self.driveclist = createAllowedDrivesClist(diskset.disks, cleardrives) # XXX bad use of usize self.driveclist.set_usize(300, -1) diff --git a/iw/partmethod_gui.py b/iw/partmethod_gui.py index 4a548032d..b24c59f48 100644 --- a/iw/partmethod_gui.py +++ b/iw/partmethod_gui.py @@ -25,21 +25,21 @@ class PartitionMethodWindow(InstallWindow): def getNext(self): if self.useFdisk.get_active(): - self.id.useAutopartitioning = 0 - self.id.useFdisk = 1 + self.partitions.useAutopartitioning = 0 + self.partitions.useFdisk = 1 elif self.useAuto.get_active(): - self.id.useAutopartitioning = 1 - self.id.useFdisk = 0 + self.partitions.useAutopartitioning = 1 + self.partitions.useFdisk = 0 else: - self.id.useAutopartitioning = 0 - self.id.useFdisk = 0 + self.partitions.useAutopartitioning = 0 + self.partitions.useFdisk = 0 return None - def getScreen (self, id): + def getScreen (self, partitions): # XXX Change to not use id in (use more specific components of id) - self.id = id + self.partitions = partitions box = GtkVBox (FALSE) box.set_border_width (5) @@ -75,9 +75,9 @@ class PartitionMethodWindow(InstallWindow): self.useAuto, _("Manually partition with fdisk [experts only]")) radioBox.pack_start(self.useFdisk, FALSE, FALSE) - if id.useAutopartitioning: + if partitions.useAutopartitioning: self.useAuto.set_active(1) - elif id.useFdisk: + elif partitions.useFdisk: self.useFdisk.set_active(1) else: self.useDS.set_active(1) diff --git a/kickstart.py b/kickstart.py index d7920a0a2..f703d8010 100644 --- a/kickstart.py +++ b/kickstart.py @@ -552,7 +552,7 @@ class KickstartBase(BaseInstallClass): self.excludedList = excludedPackages # XXX this is just not really a good way to do this... - id.bootloader.setDefaultDevice = 1 + id.bootloader.useDefaultDevice = 1 # test to see if they specified to clear partitions and also # tried to --onpart on a logical partition @@ -683,7 +683,7 @@ class KickstartBase(BaseInstallClass): if not format: request.format = 0 - id.autoPartitionRequests.append(request) + id.partitions.autoPartitionRequests.append(request) self.skipSteps.append("partition") self.skipSteps.append("partitionmethod") diff --git a/partitioning.py b/partitioning.py index e25e0240b..6704b1a5b 100644 --- a/partitioning.py +++ b/partitioning.py @@ -527,16 +527,43 @@ class PartitionSpec: entry.setFormat(self.format) return entry -class PartitionRequests: +class Partitions: def __init__ (self, diskset = None): + # requests for partitions including preexisting partitions + # a list of PartitionSpec objects self.requests = [] + + # preexisting partitions which should be deleted + # a list of DeleteSpec objects self.deletes = [] - # identifier used for raid partitions + + # auto partitioning requests + # a list of PartitionSpec objects + # these are set by the installclass and then folded into self.requests + self.autoPartitionRequests = [] + + # CLEARPART_TYPE_LINUX, CLEARPART_TYPE_ALL, CLEARPART_TYPE_NONE + # used by installclasses to say which partitions to clear + self.autoClearPartType = None + + # drives to clear partitions on (following self.autoClearPartType) + # note that None clears ALL drives + self.autoClearPartDrives = None + + # internal counter... if you use it as an ID, increment it to avoid + # problems later on self.nextUniqueID = 1 + + # partition method + self.useAutopartitioning = 1 + self.useFdisk = 0 + if diskset: self.setFromDisk(diskset) + # clear out the delete list and initialize all partitions which + # currently exist on the disk def setFromDisk(self, diskset): self.deletes = [] self.requests = [] @@ -569,7 +596,7 @@ class PartitionRequests: start = part.geom.start end = part.geom.end size = getPartSizeMB(part) - drive = part.geom.disk.dev.path[5:] + drive = get_partition_drive(part) spec = PartitionSpec(ptype, requesttype = REQUEST_PREEXIST, start = start, end = end, size = size, @@ -580,7 +607,7 @@ class PartitionRequests: part = disk.next_partition(part) def addRequest (self, request): - request.uniqueID = self.nextUniqueID + 1 + request.uniqueID = self.nextUniqueID self.nextUniqueID = self.nextUniqueID + 1 self.requests.append(request) self.requests.sort() @@ -644,13 +671,20 @@ class PartitionRequests: n = n + 1 def copy (self): - new = PartitionRequests() + new = Partitions() for request in self.requests: new.addRequest(request) for delete in self.deletes: new.addDelete(delete) - return new + new.autoPartitionRequests = self.autoPartitionRequests + new.autoClearPartType = self.autoClearPartType + new.autoClearPartDrives = self.autoClearPartDrives + new.nextUniqueID = self.nextUniqueID + new.useAutopartitioning = self.useAutopartitioning + new.useFdisk = self.useFdisk + return new + class DiskSet: skippedDisks = [] @@ -864,30 +898,29 @@ class DiskSet: part = disk.next_partition(part) return rc -def partitionObjectsInitialize(id, dir): +def partitionObjectsInitialize(diskset, partitions, dir): if dir == DISPATCH_BACK: return # read in drive info - id.diskset = DiskSet() - id.diskset.refreshDevices() - id.partrequests = PartitionRequests(id.diskset) + diskset.refreshDevices() + partitions.setFromDisk(diskset) -def partitionMethodSetup(id, dispatch): +def partitionMethodSetup(partitions, dispatch): # turn on/off step based on 3 paths: # - use fdisk, then set mount points # - use autopartitioning, then set mount points # - use interactive partitioning tool, continue - dispatch.skipStep("autopartition", skip = not id.useAutopartitioning) - dispatch.skipStep("autopartitionexecute",skip = not id.useAutopartitioning) - dispatch.skipStep("fdisk", skip = not id.useFdisk) + dispatch.skipStep("autopartition", skip = not partitions.useAutopartitioning) + dispatch.skipStep("autopartitionexecute",skip = not partitions.useAutopartitioning) + dispatch.skipStep("fdisk", skip = not partitions.useFdisk) protected = dispatch.method.protectedPartitions() if protected: for device in protected: - request = id.partrequests.getRequestByDeviceName(device) + request = partitions.getRequestByDeviceName(device) request.type = REQUEST_PROTECTED @@ -983,7 +1016,7 @@ def doDeletePartitionByRequest(intf, requestlist, partition): drive = get_partition_drive(partition) if partition.type & parted.PARTITION_EXTENDED: - deleteAllLogicalPartitions(partition, requsestlist) + deleteAllLogicalPartitions(partition, requestlist) delete = DeleteSpec(drive, partition.geom.start, partition.geom.end) requestlist.addDelete(delete) diff --git a/textw/partition_text.py b/textw/partition_text.py index ea85b2efe..b00074763 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -740,8 +740,8 @@ class AutoPartitionWindow: flag = FLAGS_SET # XXX need a way to disable the checkbox tree - def __call__(self, screen, id, diskset, intf): - if not id.useAutopartitioning: + def __call__(self, screen, diskset, partitions, intf): + if not partitions.useAutopartitioning: return INSTALL_NOOP self.g = GridFormHelp(screen, _("Autopartitioning"), "autopartitioning", 1, 6) @@ -751,9 +751,9 @@ class AutoPartitionWindow: typebox.append(_("Remove all Linux partitions"), CLEARPART_TYPE_LINUX) typebox.append(_("Remove all partitions"), CLEARPART_TYPE_ALL) typebox.append(_("Remove no partitions"), CLEARPART_TYPE_NONE) - if id.autoClearPartType == CLEARPART_TYPE_LINUX: + if partitions.autoClearPartType == CLEARPART_TYPE_LINUX: typebox.setCurrent(CLEARPART_TYPE_LINUX) - elif id.autoClearPartType == CLEARPART_TYPE_ALL: + elif partitions.autoClearPartType == CLEARPART_TYPE_ALL: typebox.setCurrent(CLEARPART_TYPE_ALL) else: typebox.setCurrent(CLEARPART_TYPE_NONE) @@ -763,9 +763,9 @@ class AutoPartitionWindow: # list of drives to select which to clear subgrid = Grid(1, 2) driveLbl = Label(_("Clear Partitions on These Drives:")) - cleardrives = id.autoClearPartDrives + cleardrives = partitions.autoClearPartDrives subgrid.setField(driveLbl, 0, 0) - disks = id.diskset.disks.keys() + disks = diskset.disks.keys() drivelist = CheckboxTree(height=3, scroll=1) if not cleardrives or len(cleardrives) < 1: for disk in disks: @@ -792,6 +792,6 @@ class AutoPartitionWindow: if res == TEXT_BACK_CHECK: return INSTALL_BACK - id.autoClearPartType = typebox.current() - id.autoClearPartDrives = drivelist.getSelection() + partitions.autoClearPartType = typebox.current() + partitions.autoClearPartDrives = drivelist.getSelection() return INSTALL_OK diff --git a/textw/partmethod_text.py b/textw/partmethod_text.py index d8243bdb1..434f35448 100644 --- a/textw/partmethod_text.py +++ b/textw/partmethod_text.py @@ -19,7 +19,7 @@ from translate import _, cat, N_ from constants_text import * class PartitionMethod: - def __call__(self, screen, id): + def __call__(self, screen, partitions): rc = ButtonChoiceWindow(screen, _("Disk Setup"), _("Autopartitioning sets up your partitioning in a reasonable " "way depending on your installation type and then gives you a " @@ -39,13 +39,13 @@ class PartitionMethod: if rc == TEXT_BACK_CHECK: return INSTALL_BACK elif rc == "fd": - id.useAutopartitioning = 0 - id.useFdisk = 1 + partitions.useAutopartitioning = 0 + partitions.useFdisk = 1 elif rc == "ds": - id.useAutopartitioning = 0 - id.useFdisk = 0 + partitions.useAutopartitioning = 0 + partitions.useFdisk = 0 else: - id.useAutopartitioning = 1 - id.useFdisk = 0 + partitions.useAutopartitioning = 1 + partitions.useFdisk = 0 return INSTALL_OK |