|
|
|
@ -28,7 +28,7 @@ def installExit(*args,**kwars):
|
|
|
|
|
raise InstallError(globals()["install_errors"])
|
|
|
|
|
|
|
|
|
|
def overprintERROR(s):
|
|
|
|
|
globals()["install_errors"] += s +"\n"
|
|
|
|
|
globals()["install_errors"] += str(s) +"\n"
|
|
|
|
|
|
|
|
|
|
cl_overriding.exit = installExit
|
|
|
|
|
cl_overriding.printERROR = overprintERROR
|
|
|
|
@ -39,9 +39,11 @@ from cl_template import template
|
|
|
|
|
from cl_datavars import DataVars
|
|
|
|
|
from cl_print import color_print
|
|
|
|
|
from cl_distr import PartitionDistributive,DistributiveRepository,\
|
|
|
|
|
DistributiveError, ScratchDistributive
|
|
|
|
|
DistributiveError, ScratchDistributive, MultiPartitions
|
|
|
|
|
from cl_string import tableReport
|
|
|
|
|
from time import sleep
|
|
|
|
|
from subprocess import Popen,PIPE
|
|
|
|
|
from server.utils import dialogYesNo
|
|
|
|
|
|
|
|
|
|
tr = lang()
|
|
|
|
|
tr.setGlobalDomain('cl_install')
|
|
|
|
@ -160,78 +162,134 @@ class convertDictOpt:
|
|
|
|
|
["suid", "nosuid"],
|
|
|
|
|
["ro", "rw"],
|
|
|
|
|
["user", "nouser"]]},
|
|
|
|
|
"ext2":_ext2Options,
|
|
|
|
|
"ext3":_ext3Options,
|
|
|
|
|
"ext4":{"options":["journal_dev", "noload", "data",
|
|
|
|
|
"commit", "orlov", "oldalloc",
|
|
|
|
|
"user_xattr", "nouser_xattr", "acl",
|
|
|
|
|
"noacl", "bsddf", "minixdf", "debug",
|
|
|
|
|
"errors", "data_err", "grpid",
|
|
|
|
|
"bsdgroups", "nogrpid", "sysvgroups",
|
|
|
|
|
"resgid", "resuid", "sb", "quota",
|
|
|
|
|
"noquota", "grpquota", "usrquota",
|
|
|
|
|
"bh", "nobh", "journal_checksum",
|
|
|
|
|
"journal_async_commit", "journal",
|
|
|
|
|
"barrier", "nobarrier",
|
|
|
|
|
"inode_readahead", "stripe",
|
|
|
|
|
"delalloc", "nodelalloc",
|
|
|
|
|
"max_batch_time", "journal_ioprio",
|
|
|
|
|
"auto_da_alloc", "noauto_da_alloc"],
|
|
|
|
|
"pair": {"journal_dev":{\
|
|
|
|
|
"options":re.compile(".+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"data":{"options":["journal", "ordered",
|
|
|
|
|
"writeback"],
|
|
|
|
|
"incompatible":["journal",
|
|
|
|
|
"ordered",
|
|
|
|
|
"writeback"]},
|
|
|
|
|
"commit":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"errors":{"options":["continue",
|
|
|
|
|
"remount-ro",
|
|
|
|
|
"panic"],
|
|
|
|
|
"incompatible":["continue",
|
|
|
|
|
"remount-ro",
|
|
|
|
|
"panic"]},
|
|
|
|
|
"data_err":{"options":["abort",
|
|
|
|
|
"ext2":_ext2Options,
|
|
|
|
|
"ext3":_ext3Options,
|
|
|
|
|
"ext4":{"options":["journal_dev", "noload", "data",
|
|
|
|
|
"commit", "orlov", "oldalloc",
|
|
|
|
|
"user_xattr", "nouser_xattr", "acl",
|
|
|
|
|
"noacl", "bsddf", "minixdf", "debug",
|
|
|
|
|
"errors", "data_err", "grpid",
|
|
|
|
|
"bsdgroups", "nogrpid", "sysvgroups",
|
|
|
|
|
"resgid", "resuid", "sb", "quota",
|
|
|
|
|
"noquota", "grpquota", "usrquota",
|
|
|
|
|
"bh", "nobh", "journal_checksum",
|
|
|
|
|
"journal_async_commit", "journal",
|
|
|
|
|
"barrier", "nobarrier",
|
|
|
|
|
"inode_readahead", "stripe",
|
|
|
|
|
"delalloc", "nodelalloc",
|
|
|
|
|
"max_batch_time", "journal_ioprio",
|
|
|
|
|
"auto_da_alloc", "noauto_da_alloc"],
|
|
|
|
|
"pair": {"journal_dev":{\
|
|
|
|
|
"options":re.compile(".+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"data":{"options":["journal", "ordered",
|
|
|
|
|
"writeback"],
|
|
|
|
|
"incompatible":["journal",
|
|
|
|
|
"ordered",
|
|
|
|
|
"ignore"],
|
|
|
|
|
"incompatible":["abort",
|
|
|
|
|
"ordered",
|
|
|
|
|
"ignore"]},
|
|
|
|
|
"resgid":{"options":re.compile("\d+"),
|
|
|
|
|
"writeback"]},
|
|
|
|
|
"commit":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"errors":{"options":["continue",
|
|
|
|
|
"remount-ro",
|
|
|
|
|
"panic"],
|
|
|
|
|
"incompatible":["continue",
|
|
|
|
|
"remount-ro",
|
|
|
|
|
"panic"]},
|
|
|
|
|
"data_err":{"options":["abort",
|
|
|
|
|
"ordered",
|
|
|
|
|
"ignore"],
|
|
|
|
|
"incompatible":["abort",
|
|
|
|
|
"ordered",
|
|
|
|
|
"ignore"]},
|
|
|
|
|
"resgid":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"resuid":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"sb":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"journal":{"options":["update"],
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"inode_readahead":{"options":\
|
|
|
|
|
re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"stripe":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"max_batch_time":{"options":\
|
|
|
|
|
re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"journal_ioprio":{"options":\
|
|
|
|
|
re.compile("[1-7]"),
|
|
|
|
|
"incompatible":[]}},
|
|
|
|
|
"incompatible":[["oldalloc", "orlov"],
|
|
|
|
|
["user_xattr","nouser_xattr"],
|
|
|
|
|
["acl", "noacl"],
|
|
|
|
|
["bsddf", "minixdf"],
|
|
|
|
|
["grpid","bsdgroups"],
|
|
|
|
|
["grpid","nogrpid"],
|
|
|
|
|
["bsdgroups","sysvgroups"],
|
|
|
|
|
["nogrpid","sysvgroups"],
|
|
|
|
|
["grpquota","noquota","quota",
|
|
|
|
|
"usrquota"],
|
|
|
|
|
["bh","nobh"],
|
|
|
|
|
["delalloc", "nodelalloc"],
|
|
|
|
|
["auto_da_alloc",
|
|
|
|
|
"noauto_da_alloc"]]},
|
|
|
|
|
"reiserfs":{"options":["conv","hash","hashed_relocation",
|
|
|
|
|
"no_unhashed_relocation",
|
|
|
|
|
"noborder", "nolog", "notail",
|
|
|
|
|
"replayonly", "resize",
|
|
|
|
|
"user_xattr", "acl"],
|
|
|
|
|
"pair":{"hash":{"options":["rupasov", "tea",
|
|
|
|
|
"r5", "detect"],
|
|
|
|
|
"incompatible":["rupasov",
|
|
|
|
|
"tea",
|
|
|
|
|
"r5",
|
|
|
|
|
"detect"]},
|
|
|
|
|
"resize":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]}},
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"xfs":{"options":["allocsize", "attr2", "noattr2",
|
|
|
|
|
"barrier", "dmapi", "grpid",
|
|
|
|
|
"bsdgroups", "nogrpid", "sysvgroups",
|
|
|
|
|
"ihashsize", "ikeep", "noikeep",
|
|
|
|
|
"inode64", "largeio","nolargeio",
|
|
|
|
|
"logbufs", "logbsize", "logdev",
|
|
|
|
|
"rtdev", "mtpt", "noalign", "noatime",
|
|
|
|
|
"norecovery", "nouuid", "osyncisosync",
|
|
|
|
|
"uquota", "usrquota", "uqnoenforce",
|
|
|
|
|
"quota", "pquota", "prjquota",
|
|
|
|
|
"pqnoenforce", "sunit", "swidth",
|
|
|
|
|
"swalloc"],
|
|
|
|
|
"pair":{"allocsize":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"resuid":{"options":re.compile("\d+"),
|
|
|
|
|
"ihashsize":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"sb":{"options":re.compile("\d+"),
|
|
|
|
|
"logbufs":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"logbsize":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"logdev":{"options":re.compile(".+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"rtdev":{"options":re.compile(".+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"journal":{"options":["update"],
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"inode_readahead":{"options":\
|
|
|
|
|
re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"stripe":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"max_batch_time":{"options":\
|
|
|
|
|
re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"journal_ioprio":{"options":\
|
|
|
|
|
re.compile("[1-7]"),
|
|
|
|
|
"incompatible":[]}},
|
|
|
|
|
"incompatible":[["oldalloc", "orlov"],
|
|
|
|
|
["user_xattr","nouser_xattr"],
|
|
|
|
|
["acl", "noacl"],
|
|
|
|
|
["bsddf", "minixdf"],
|
|
|
|
|
["grpid","bsdgroups"],
|
|
|
|
|
["grpid","nogrpid"],
|
|
|
|
|
["bsdgroups","sysvgroups"],
|
|
|
|
|
["nogrpid","sysvgroups"],
|
|
|
|
|
["grpquota","noquota","quota",
|
|
|
|
|
"usrquota"],
|
|
|
|
|
["bh","nobh"],
|
|
|
|
|
["delalloc", "nodelalloc"],
|
|
|
|
|
["auto_da_alloc", "noauto_da_alloc"]]}
|
|
|
|
|
}
|
|
|
|
|
"mtpt":{"options":re.compile(".+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"sunit":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]},
|
|
|
|
|
"swidth":{"options":re.compile("\d+"),
|
|
|
|
|
"incompatible":[]}},
|
|
|
|
|
"incompatible":[["attr2", "noattr2"],
|
|
|
|
|
["grpid", "bsdgroups"],
|
|
|
|
|
["grpid", "nogrpid"],
|
|
|
|
|
["bsdgroups", "sysvgroups"],
|
|
|
|
|
["nogrpid", "sysvgroups"],
|
|
|
|
|
["ikeep", "noikeep"],
|
|
|
|
|
["largeio","nolargeio"],
|
|
|
|
|
["uquota", "usrquota",
|
|
|
|
|
"uqnoenforce", "quota"],
|
|
|
|
|
["pquota", "prjquota",
|
|
|
|
|
"pqnoenforce"]]}}
|
|
|
|
|
listFileSystemCorrupted = []
|
|
|
|
|
|
|
|
|
|
def __init__(self, clVars):
|
|
|
|
|
self.clVars = clVars
|
|
|
|
@ -239,6 +297,11 @@ class convertDictOpt:
|
|
|
|
|
'os_disk_mount', 'os_disk_options',
|
|
|
|
|
'os_disk_part', 'os_disk_size')
|
|
|
|
|
|
|
|
|
|
def addFileSystemCorrupted(self, fileSystem):
|
|
|
|
|
"""Add file system with error"""
|
|
|
|
|
if not fileSystem in self.listFileSystemCorrupted:
|
|
|
|
|
self.listFileSystemCorrupted.append(fileSystem)
|
|
|
|
|
|
|
|
|
|
def getAllSupportFileSystemOpt(self):
|
|
|
|
|
"""Get list all file system"""
|
|
|
|
|
return filter(lambda x: not x.startswith("_"),
|
|
|
|
@ -265,6 +328,7 @@ class convertDictOpt:
|
|
|
|
|
raise InstallError(_("Unsupported file system %s")%realFileSystem)
|
|
|
|
|
for opt in realOptions:
|
|
|
|
|
if not opt in allOptions:
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect option %s")%opt)
|
|
|
|
|
|
|
|
|
|
def _checkFileSystemIncompatibleOpt(self, realFileSystem, realOptions):
|
|
|
|
@ -297,6 +361,7 @@ class convertDictOpt:
|
|
|
|
|
listOpt = filter(lambda x: x!=option, dataOpt[0])
|
|
|
|
|
twoOptList = list(set(listOpt)&set(realOptions))
|
|
|
|
|
if twoOptList:
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incompatible options") + ":"+\
|
|
|
|
|
" " + option + " " + _("and") +\
|
|
|
|
|
" " + ",".join(twoOptList))
|
|
|
|
@ -319,6 +384,7 @@ class convertDictOpt:
|
|
|
|
|
dictOpt[nameOpt] = []
|
|
|
|
|
dictOpt[nameOpt].append(valueOpt)
|
|
|
|
|
elif len(dataOpt)>2:
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect option %s")%opt)
|
|
|
|
|
else:
|
|
|
|
|
notPairOpt.append(opt)
|
|
|
|
@ -330,10 +396,12 @@ class convertDictOpt:
|
|
|
|
|
allPairOpt = pairData.keys()
|
|
|
|
|
wrongOpt = list(set(allPairOpt)&set(notPairOpt))
|
|
|
|
|
if wrongOpt:
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect options %s")\
|
|
|
|
|
%", ".join(wrongOpt))
|
|
|
|
|
for nameOpt in dictOpt.keys():
|
|
|
|
|
if not nameOpt in allPairOpt:
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect option %s")\
|
|
|
|
|
%"%s=%s"%(nameOpt,valueOpt))
|
|
|
|
|
checkValues = pairData[nameOpt]
|
|
|
|
@ -344,9 +412,11 @@ class convertDictOpt:
|
|
|
|
|
if len(listValues)>1:
|
|
|
|
|
wrongOpt = ",".join(map(lambda x: "%s=%s"%(nameOpt,x),
|
|
|
|
|
listValues))
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect option %s")\
|
|
|
|
|
%wrongOpt)
|
|
|
|
|
if not checkValuesOpt.search(listValues[0]):
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect option %s")\
|
|
|
|
|
%"%s=%s"%(nameOpt,listValues[0]))
|
|
|
|
|
else:
|
|
|
|
@ -354,6 +424,7 @@ class convertDictOpt:
|
|
|
|
|
if wrongValues:
|
|
|
|
|
wrongOpt = ",".join(map(lambda x: "%s=%s"%(nameOpt,x),
|
|
|
|
|
wrongValues))
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incorrect option %s")\
|
|
|
|
|
%wrongOpt)
|
|
|
|
|
checkValuesIncompOpt = checkValues["incompatible"]
|
|
|
|
@ -363,6 +434,7 @@ class convertDictOpt:
|
|
|
|
|
if len(incompValues)>1:
|
|
|
|
|
wrongOpt = map(lambda x: "%s=%s"%(nameOpt,x),
|
|
|
|
|
incompValues)
|
|
|
|
|
self.addFileSystemCorrupted(realFileSystem)
|
|
|
|
|
raise InstallError(_("Incompatible options") + ":"+\
|
|
|
|
|
" " + wrongOpt[0] + " " + \
|
|
|
|
|
_("and") + " " +\
|
|
|
|
@ -403,8 +475,10 @@ class convertDictOpt:
|
|
|
|
|
optProperties = optionsDict.copy()
|
|
|
|
|
if "srcMountPoint" in optProperties:
|
|
|
|
|
# bind options
|
|
|
|
|
optProperties.update(self.getDefaultOptBind())
|
|
|
|
|
return optProperties
|
|
|
|
|
dictOptions = {}
|
|
|
|
|
dictOptions.update(self.getDefaultOptBind())
|
|
|
|
|
dictOptions.update(optProperties)
|
|
|
|
|
return dictOptions
|
|
|
|
|
optDevice = optProperties["dev"]
|
|
|
|
|
dataPart = filter(lambda x: x[0]==optDevice, self.varDiskData)
|
|
|
|
|
dev, format, mount, options, part, size = dataPart[0]
|
|
|
|
@ -419,7 +493,8 @@ class convertDictOpt:
|
|
|
|
|
dictUpdateProperty["mountPoint"] = optMountPoint
|
|
|
|
|
if optFileSystem:
|
|
|
|
|
if not optFileSystem in self.getAllSupportFileSystemOpt():
|
|
|
|
|
raise InstallError(_("Wrong options '%s'")%optFileSystem)
|
|
|
|
|
raise InstallError(_("Wrong file system options '%s'")\
|
|
|
|
|
%optFileSystem)
|
|
|
|
|
dictOptions.update(self.getDefaultOptFileSystem(optFileSystem))
|
|
|
|
|
if optFileSystem == "noformat":
|
|
|
|
|
if not format:
|
|
|
|
@ -429,7 +504,6 @@ class convertDictOpt:
|
|
|
|
|
options = ["noatime"]
|
|
|
|
|
dictOptions["fileSystem"] = format
|
|
|
|
|
dictOptions["options"] = options.split(",")
|
|
|
|
|
|
|
|
|
|
if optFileSystem in self._propertiesFileSystem:
|
|
|
|
|
dictUpdateProperty["fileSystem"] = dictOptions["fileSystem"]
|
|
|
|
|
optOptions = optProperties["options"]
|
|
|
|
@ -455,10 +529,13 @@ class convertDictOpt:
|
|
|
|
|
return dictDefault
|
|
|
|
|
else:
|
|
|
|
|
# Swap options
|
|
|
|
|
dictOptions = {}
|
|
|
|
|
optFileSystem = "swap"
|
|
|
|
|
if optFileSystem != format:
|
|
|
|
|
dictUpdateProperty["isFormat"] = True
|
|
|
|
|
return self.getDefaultOptSwap()
|
|
|
|
|
dictOptions.update(self.getDefaultOptSwap())
|
|
|
|
|
dictOptions.update(optProperties)
|
|
|
|
|
return dictOptions
|
|
|
|
|
|
|
|
|
|
class cl_install(color_print):
|
|
|
|
|
"""Primary class for templates appling and system installation"""
|
|
|
|
@ -468,6 +545,10 @@ class cl_install(color_print):
|
|
|
|
|
self.clVars = None
|
|
|
|
|
self.clTempl = None
|
|
|
|
|
self.color = True
|
|
|
|
|
self.listDisksOptions = []
|
|
|
|
|
self.listBindsOptions = []
|
|
|
|
|
self.listSwapsOptions = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def colorPrint(self,*argv,**kwarg):
|
|
|
|
|
if self.color:
|
|
|
|
@ -536,6 +617,7 @@ class cl_install(color_print):
|
|
|
|
|
self.clVars.Get('os_root_dev'))
|
|
|
|
|
self.printSUCCESS(_("File system")+": %s"%
|
|
|
|
|
self.getFieldByField("format","mount","/",
|
|
|
|
|
firstPrefix="os_install_disk",
|
|
|
|
|
secondPrefix="os_install_disk"))
|
|
|
|
|
self.printSUCCESS(_("Swap disk")+": %s"%
|
|
|
|
|
self.getFieldByField("dev","mount","swap",
|
|
|
|
@ -566,16 +648,17 @@ class cl_install(color_print):
|
|
|
|
|
sleep(1)
|
|
|
|
|
self.defaultPrint("\b\b \n")
|
|
|
|
|
|
|
|
|
|
def prepareBoot(self,targetDistr):
|
|
|
|
|
self.installBootloader(targetDistr)
|
|
|
|
|
def prepareBoot(self,targetDistr, bootDisk="0"):
|
|
|
|
|
self.installBootloader(targetDistr, bootDisk="0")
|
|
|
|
|
|
|
|
|
|
def getTargetDistributive(self, disk):
|
|
|
|
|
def getTargetDistributive(self,disk,fileSystem="reiserfs",isFormat=False):
|
|
|
|
|
#if buildermode:
|
|
|
|
|
#return ScratchDistributive(disk,mdirectory="/mnt/install",
|
|
|
|
|
#check=True)
|
|
|
|
|
#else:
|
|
|
|
|
return PartitionDistributive(disk,mdirectory="/mnt/install",
|
|
|
|
|
check=True)
|
|
|
|
|
check=True, fileSystem=fileSystem,
|
|
|
|
|
isFormat=isFormat)
|
|
|
|
|
|
|
|
|
|
def applyTemplates(self,directory):
|
|
|
|
|
"""Apply templates for root of system."""
|
|
|
|
@ -597,8 +680,14 @@ class cl_install(color_print):
|
|
|
|
|
listSwaps = map(convObj, listSwaps)
|
|
|
|
|
except InstallError,e:
|
|
|
|
|
self.printERROR(str(e))
|
|
|
|
|
if convObj.listFileSystemCorrupted:
|
|
|
|
|
self.printWARNING(_("See 'man mount' for file system") + " "+\
|
|
|
|
|
", ".join(convObj.listFileSystemCorrupted))
|
|
|
|
|
return False
|
|
|
|
|
print "LD", listDisks
|
|
|
|
|
# cmd options
|
|
|
|
|
self.listDisksOptions = listDisks
|
|
|
|
|
self.listBindsOptions = listBinds
|
|
|
|
|
self.listSwapsOptions = listSwaps
|
|
|
|
|
installAllDevices = map(lambda x: x['dev'],listSwaps) +\
|
|
|
|
|
map(lambda x: x['dev'],listDisks)
|
|
|
|
|
# detect duplicate partition
|
|
|
|
@ -820,7 +909,7 @@ class cl_install(color_print):
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def installBootloader(self,target):
|
|
|
|
|
def installBootloader(self,target, grubDisk="0"):
|
|
|
|
|
"""Install boot loader
|
|
|
|
|
|
|
|
|
|
Perform grub installation to disk, which has root partition
|
|
|
|
@ -828,25 +917,78 @@ class cl_install(color_print):
|
|
|
|
|
pipe = Popen(["/sbin/grub",
|
|
|
|
|
"--device-map=%s/boot/grub/device.map"%target.getDirectory(),
|
|
|
|
|
"--batch"], stdin=PIPE, stdout=PIPE,stderr=PIPE)
|
|
|
|
|
pipe.stdin.write("root (hd%s)\n"%
|
|
|
|
|
self.getFieldByField("grub","install","/"))
|
|
|
|
|
bootDisk = self.getFieldByField("grub","mount","/boot",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
if not bootDisk:
|
|
|
|
|
bootDisk = self.getFieldByField("grub","mount","/",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
pipe.stdin.write("root (hd%s)\n" %bootDisk)
|
|
|
|
|
# TODO: change hd0 for bootloader install to other disks
|
|
|
|
|
# may be another parameters
|
|
|
|
|
pipe.stdin.write("setup (hd0)\n")
|
|
|
|
|
pipe.stdin.write("setup (hd%s)\n"%grubDisk)
|
|
|
|
|
pipe.stdin.write("quit\n")
|
|
|
|
|
pipe.stdin.close()
|
|
|
|
|
# TODO: break if command is hang (KeyboardInterrupt is supported)
|
|
|
|
|
if pipe.wait() != 0:
|
|
|
|
|
raise DistributiveError("Cann't install bootloader")
|
|
|
|
|
|
|
|
|
|
def installSystem(self):
|
|
|
|
|
def generateTableData(self):
|
|
|
|
|
"""Get data from print table"""
|
|
|
|
|
title = _("New partition table")
|
|
|
|
|
allDevicesOpt = self.listDisksOptions + self.listSwapsOptions
|
|
|
|
|
listIsFormat = []
|
|
|
|
|
for dev in self.clVars.Get('os_disk_dev'):
|
|
|
|
|
devCmdOpt = filter(lambda x: x['dev']==dev, allDevicesOpt)
|
|
|
|
|
if devCmdOpt:
|
|
|
|
|
if devCmdOpt[0]["isFormat"]:
|
|
|
|
|
listIsFormat.append(_("Yes"))
|
|
|
|
|
else:
|
|
|
|
|
listIsFormat.append("")
|
|
|
|
|
else:
|
|
|
|
|
listIsFormat.append("")
|
|
|
|
|
|
|
|
|
|
fileSystemData = zip(self.clVars.Get('os_install_disk_format'),
|
|
|
|
|
self.clVars.Get('os_disk_format'))
|
|
|
|
|
listFileSystem = map(lambda x: x[0] if x[0] else x[1], fileSystemData)
|
|
|
|
|
#fileSystemData = zip(listFileSystem,
|
|
|
|
|
#self.clVars.Get('os_disk_format'))
|
|
|
|
|
#listFileSystem = map(lambda x:\
|
|
|
|
|
#x[0] if x[0]==x[1] else "%s -> %s" %(x[1], x[0]),
|
|
|
|
|
#fileSystemData)
|
|
|
|
|
listMountPoint = map(lambda x: "" if x=="swap" else x,
|
|
|
|
|
self.clVars.Get('os_install_disk_mount'))
|
|
|
|
|
partData = zip(self.clVars.Get('os_disk_size'),
|
|
|
|
|
self.clVars.Get('os_disk_part'))
|
|
|
|
|
listSize = map(lambda x: "" if x[1]=="extended" else x[0], partData)
|
|
|
|
|
|
|
|
|
|
headerList = [_("Size"),_("Device"),_("Directory"),_("File system"),
|
|
|
|
|
_("Format"), _("Partition")]
|
|
|
|
|
dataList = zip(listSize,
|
|
|
|
|
self.clVars.Get('os_disk_dev'),
|
|
|
|
|
listMountPoint,
|
|
|
|
|
listFileSystem,
|
|
|
|
|
listIsFormat,
|
|
|
|
|
self.clVars.Get('os_disk_part'))
|
|
|
|
|
return title, headerList, dataList
|
|
|
|
|
|
|
|
|
|
def installSystem(self, force=False, bootDisk=None):
|
|
|
|
|
"""install System by current variable enviroment"""
|
|
|
|
|
sourceDistr = None
|
|
|
|
|
targetDistr = None
|
|
|
|
|
error = None
|
|
|
|
|
try:
|
|
|
|
|
targetDistr = self.getTargetDistributive(\
|
|
|
|
|
self.clVars.Get('os_install_root_dev'))
|
|
|
|
|
rootPartdev = self.clVars.Get('os_install_root_dev')
|
|
|
|
|
rootPartCmdList = filter(lambda x: x['dev']==rootPartdev,
|
|
|
|
|
self.listDisksOptions)
|
|
|
|
|
rootPartCmdDict = rootPartCmdList[0]
|
|
|
|
|
rootPartFileSystem = self.getFieldByField("format","dev",
|
|
|
|
|
rootPartdev,
|
|
|
|
|
firstPrefix="os_install_disk")
|
|
|
|
|
rootPartIsFormat=rootPartCmdDict['isFormat']
|
|
|
|
|
|
|
|
|
|
targetDistr = self.getTargetDistributive(rootPartdev,
|
|
|
|
|
fileSystem=rootPartFileSystem,
|
|
|
|
|
isFormat=rootPartIsFormat)
|
|
|
|
|
distRep = DistributiveRepository()
|
|
|
|
|
distName = self.clVars.Get('cl_image')
|
|
|
|
|
if distName:
|
|
|
|
@ -854,15 +996,94 @@ class cl_install(color_print):
|
|
|
|
|
sourceDistr = distRep.getDistributiveByFile(distName)
|
|
|
|
|
self.printInfo(sourceDistr,targetDistr)
|
|
|
|
|
# wait 10 sec
|
|
|
|
|
waittime = 3
|
|
|
|
|
self.printSUCCESS(_("Installation will start pass %d seconds.")
|
|
|
|
|
%waittime)
|
|
|
|
|
self.wait(waittime)
|
|
|
|
|
# format partition if needed
|
|
|
|
|
return True
|
|
|
|
|
#waittime = 3
|
|
|
|
|
#self.printSUCCESS(_("Installation will start pass %d seconds.")
|
|
|
|
|
#%waittime)
|
|
|
|
|
bootDiskGrub = ""
|
|
|
|
|
if bootDisk:
|
|
|
|
|
listbootDiskGrub = map(lambda x: x[1],
|
|
|
|
|
filter(lambda x: "/dev/"+x[0]==bootDisk,
|
|
|
|
|
zip(self.clVars.Get('os_device_dev'),
|
|
|
|
|
self.clVars.Get('os_device_map'))))
|
|
|
|
|
if listbootDiskGrub:
|
|
|
|
|
bootDiskGrub=listbootDiskGrub[0]
|
|
|
|
|
else:
|
|
|
|
|
raise InstallError(_("Cann't found disk %s")%bootDisk)
|
|
|
|
|
if not force:
|
|
|
|
|
title, headerList, dataList = self.generateTableData()
|
|
|
|
|
tableObj = tableReport(title, headerList, dataList)
|
|
|
|
|
cl_overriding.printSUCCESS("")
|
|
|
|
|
tableObj.printReport()
|
|
|
|
|
cl_overriding.printSUCCESS("")
|
|
|
|
|
dialogMessage = _("Continue with the installation of \
|
|
|
|
|
the system") + " (yes/no)"
|
|
|
|
|
dialogRes = dialogYesNo(dialogMessage)
|
|
|
|
|
if dialogRes is None:
|
|
|
|
|
return True
|
|
|
|
|
elif dialogRes is False:
|
|
|
|
|
return True
|
|
|
|
|
#self.wait(waittime)
|
|
|
|
|
# cmd options
|
|
|
|
|
#self.listDisksOptions
|
|
|
|
|
#self.listBindsOptions
|
|
|
|
|
#self.listSwapsOptions
|
|
|
|
|
|
|
|
|
|
noRootPartDisksOptions = filter(lambda x: x['mountPoint']!="/",
|
|
|
|
|
self.listDisksOptions)
|
|
|
|
|
flagMultipartition = False
|
|
|
|
|
objMultiPartitions = False
|
|
|
|
|
# Disk multipartitions
|
|
|
|
|
if noRootPartDisksOptions:
|
|
|
|
|
flagMultipartition = True
|
|
|
|
|
objMultiPartitions = MultiPartitions()
|
|
|
|
|
for diskOptions in noRootPartDisksOptions:
|
|
|
|
|
dev = diskOptions["dev"]
|
|
|
|
|
mountPoint = diskOptions["mountPoint"]
|
|
|
|
|
fileSystem = diskOptions["fileSystem"]
|
|
|
|
|
isFormat = diskOptions["isFormat"]
|
|
|
|
|
objMultiPartitions.addPartition(dev=dev,
|
|
|
|
|
mountPoint=mountPoint,
|
|
|
|
|
fileSystem=fileSystem,
|
|
|
|
|
isFormat=isFormat)
|
|
|
|
|
# Swap multipartitions
|
|
|
|
|
if self.listSwapsOptions:
|
|
|
|
|
flagMultipartition = True
|
|
|
|
|
if not objMultiPartitions:
|
|
|
|
|
objMultiPartitions = MultiPartitions()
|
|
|
|
|
for diskOptions in self.listSwapsOptions:
|
|
|
|
|
dev = diskOptions["dev"]
|
|
|
|
|
mountPoint = "swap"
|
|
|
|
|
fileSystem = diskOptions["fileSystem"]
|
|
|
|
|
isFormat = diskOptions["isFormat"]
|
|
|
|
|
objMultiPartitions.addPartition(dev=dev,
|
|
|
|
|
mountPoint=mountPoint,
|
|
|
|
|
fileSystem=fileSystem,
|
|
|
|
|
isFormat=isFormat)
|
|
|
|
|
# Bind multipartitions
|
|
|
|
|
if self.listBindsOptions:
|
|
|
|
|
flagMultipartition = True
|
|
|
|
|
if not objMultiPartitions:
|
|
|
|
|
objMultiPartitions = MultiPartitions()
|
|
|
|
|
for diskOptions in self.listBindsOptions:
|
|
|
|
|
dev = diskOptions["srcMountPoint"]
|
|
|
|
|
mountPoint = diskOptions["destMountPoint"]
|
|
|
|
|
fileSystem = "bind"
|
|
|
|
|
isFormat = diskOptions["isFormat"]
|
|
|
|
|
objMultiPartitions.addPartition(dev=dev,
|
|
|
|
|
mountPoint=mountPoint,
|
|
|
|
|
fileSystem=fileSystem,
|
|
|
|
|
isFormat=isFormat)
|
|
|
|
|
if flagMultipartition:
|
|
|
|
|
# Set Multipartition
|
|
|
|
|
targetDistr.multipartition=objMultiPartitions
|
|
|
|
|
# Format all partitions
|
|
|
|
|
targetDistr.formatAllPartitions()
|
|
|
|
|
else:
|
|
|
|
|
# Format root partition
|
|
|
|
|
if targetDistr.isFormat:
|
|
|
|
|
targetDistr.formatPartition(targetDistr.partition,
|
|
|
|
|
format=targetDistr.fileSystem)
|
|
|
|
|
self.printSUCCESS(_("Formating partition"))
|
|
|
|
|
targetDistr.formatPartition(
|
|
|
|
|
self.getFieldByField("format","install","/") or "reiserfs")
|
|
|
|
|
# install distributive
|
|
|
|
|
self.printSUCCESS(_("Unpacking system image into target"))
|
|
|
|
|
targetDistr.installFrom(sourceDistr)
|
|
|
|
@ -870,9 +1091,14 @@ class cl_install(color_print):
|
|
|
|
|
# join templates
|
|
|
|
|
self.printSUCCESS(_("Update config"))
|
|
|
|
|
self.applyTemplates(targetDistr.getDirectory())
|
|
|
|
|
# mount bind mount points
|
|
|
|
|
targetDistr.postinstallMountBind()
|
|
|
|
|
# change boot config
|
|
|
|
|
self.printSUCCESS(_("Prepare system for reboot"))
|
|
|
|
|
self.prepareBoot(targetDistr)
|
|
|
|
|
if bootDiskGrub:
|
|
|
|
|
self.prepareBoot(targetDistr, bootDiskGrub)
|
|
|
|
|
else:
|
|
|
|
|
self.prepareBoot(targetDistr)
|
|
|
|
|
else:
|
|
|
|
|
self.printWARNING("No update available.")
|
|
|
|
|
return False
|
|
|
|
@ -901,7 +1127,7 @@ class cl_install(color_print):
|
|
|
|
|
self.printERROR(line)
|
|
|
|
|
return False
|
|
|
|
|
self.printSUCCESS(_("System successfully installed"))
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def setLinuxName(self,shortname):
|
|
|
|
|
self.clVars.Set('os_install_linux_shortname',shortname,True)
|
|
|
|
|