diff options
-rw-r--r-- | installclasses/custom.py | 26 | ||||
-rw-r--r-- | installclasses/server.py | 18 | ||||
-rw-r--r-- | installclasses/workstation.py | 26 | ||||
-rw-r--r-- | partitioning.py | 47 |
4 files changed, 89 insertions, 28 deletions
diff --git a/installclasses/custom.py b/installclasses/custom.py index bd79c2c5d..3dc8b41a2 100644 --- a/installclasses/custom.py +++ b/installclasses/custom.py @@ -2,13 +2,35 @@ from installclass import BaseInstallClass from translate import N_ import os import iutil +from autopart import CLEARPART_TYPE_LINUX +from autopart import CLEARPART_TYPE_ALL +from autopart import CLEARPART_TYPE_NONE +from partitioning import autoCreatePartitionRequests # custom installs are easy :-) class InstallClass(BaseInstallClass): - name = N_("Custom System") pixmap = "custom.png" - + sortPriority = 10000 + def setInstallData(self, id): + BaseInstallClass.setInstallData(self, id) + self.setHostname(id, "localhost.localdomain") + + autorequests = [ ("/", None, 700, None, 1, 1), + ("/boot", None, 50, None, 0, 1) ] + + (minswap, maxswap) = iutil.swapSuggestion() + autorequests.append((None, "swap", minswap, maxswap, 1, 1)) + id.autoClearPartType = CLEARPART_TYPE_LINUX + id.autoClearPartDrives = [] + id.autoPartitionRequests = autoCreatePartitionRequests(autorequests) + + def __init__(self, expert): + BaseInstallClass.__init__(self, expert) + if expert: + self.skipLilo = 1 + else: + self.skipLilo = 0 diff --git a/installclasses/server.py b/installclasses/server.py index 2d79019f5..48cd3201d 100644 --- a/installclasses/server.py +++ b/installclasses/server.py @@ -2,6 +2,10 @@ from installclass import BaseInstallClass from translate import * import os import iutil +from partitioning import autoCreatePartitionRequests +from autopart import CLEARPART_TYPE_LINUX +from autopart import CLEARPART_TYPE_ALL +from autopart import CLEARPART_TYPE_NONE class InstallClass(BaseInstallClass): @@ -34,6 +38,19 @@ class InstallClass(BaseInstallClass): BaseInstallClass.setInstallData(self, id) self.setHostname(id, "localhost.localdomain") + autorequests = [ ("/", None,256, None, 1, 1), + ("/boot", None, 50, None, 0, 1), + ("/usr", None, 512, 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) + def __init__(self, expert): BaseInstallClass.__init__(self, expert) @@ -41,4 +58,3 @@ class InstallClass(BaseInstallClass): self.skipLilo = 1 else: self.skipLilo = 0 - diff --git a/installclasses/workstation.py b/installclasses/workstation.py index 79930eac4..5945a46d9 100644 --- a/installclasses/workstation.py +++ b/installclasses/workstation.py @@ -31,30 +31,14 @@ class InstallClass(BaseInstallClass): BaseInstallClass.setInstallData(self, id) self.setHostname(id, "localhost.localdomain") - rootrequest = PartitionSpec(fileSystemTypeGetDefault(), - mountpoint = "/", - size = 800, - grow = 1, - requesttype = REQUEST_NEW, - format = 1) - - bootrequest = PartitionSpec(fileSystemTypeGetDefault(), - mountpoint = "/boot", - size = 100, - grow = 0, - requesttype = REQUEST_NEW, - format = 1) - - swaprequest = PartitionSpec(fileSystemTypeGet("swap"), - size = 128, - grow = 0, - requesttype = REQUEST_NEW, - format = 1) + autorequests = [ ("/", None, 1100, None, 1, 1), + ("/boot", None, 50, None, 0, 1) ] + (minswap, maxswap) = iutil.swapSuggestion() + autorequests.append((None, "swap", minswap, maxswap, 1, 1)) id.autoClearPartType = CLEARPART_TYPE_LINUX id.autoClearPartDrives = [] - id.autoPartitionRequests = [rootrequest, bootrequest, swaprequest] - + id.autoPartitionRequests = autoCreatePartitionRequests(autorequests) def __init__(self, expert): BaseInstallClass.__init__(self, expert) diff --git a/partitioning.py b/partitioning.py index 72c2d7c2f..89a72882a 100644 --- a/partitioning.py +++ b/partitioning.py @@ -291,15 +291,18 @@ def doMountPointLinuxFSChecks(newrequest): if not newrequest.mountpoint: return None - if newrequest.fstype.isLinuxNativeFS(): + if newrequest.fstype == None: + return None + + if newrequest.fstype.isMountable(): if newrequest.mountpoint in mustbeonroot: return _("This mount point is invalid. This directory must " "be on the / filesystem.") - - else: + + if not newrequest.fstype.isLinuxNativeFS(): if newrequest.mountpoint in mustbeonlinuxfs: return _("This mount point must be on a linux filesystem.") - + return None def doPartitionSizeCheck(newrequest): @@ -839,3 +842,39 @@ def partitionMethodSetup(id, dispatch): for device in protected: request = id.partrequests.getRequestByDeviceName(device) request.type = REQUEST_PROTECTED + + +# shorthand mainly for installclasses +# +# make a list of tuples of the form: +# (mntpt, fstype, minsize, maxsize, grow, format) +# +# mntpt = None for non-mountable, otherwise is mount point +# fstype = None to use default, otherwise a string +# minsize = smallest size +# maxsize = max size, or None means no max +# grow = 0 or 1, should partition be grown +# format = 0 or 1, whether to format +# +def autoCreatePartitionRequests(autoreq): + requests = [] + for (mntpt, fstype, minsize, maxsize, grow, format) in autoreq: + if fstype: + ptype = fsset.fileSystemTypeGet(fstype) + else: + ptype = fsset.fileSystemTypeGetDefault() + + newrequest = PartitionSpec(ptype, + mountpoint = mntpt, + size = minsize, + maxSize = maxsize, + grow = grow, + requesttype = REQUEST_NEW, + format = format) + + requests.append(newrequest) + + for r in requests: + print r + + return requests |