Merge branch 'master' of git.calculate.ru:calculate-install

netsetup
Mike Hiretsky 14 years ago
commit c80516ba1c

@ -612,17 +612,27 @@ class MultiPartitions:
class PartitionDistributive(Distributive):
formatUtilities = { 'ext2':'/sbin/mkfs.ext2 %s',
'ext3':'/sbin/mkfs.ext3 %s',
'ext4':'/sbin/mkfs.ext4 %s',
'jfs':'/sbin/mkfs.jfs -f %s',
'reiserfs':'/sbin/mkfs.reiserfs -f %s',
'xfs':'/sbin/mkfs.xfs -f %s',
'vfat':'/usr/sbin/mkfs.vfat -F 32 %s',
'ntfs-3g':'/usr/sbin/mkfs.ntfs -FQ %s',
'ntfs':'/usr/sbin/mkfs.ntfs -FQ %s',
formatUtilities = { 'ext2':'/sbin/mkfs.ext2 %s %s',
'ext3':'/sbin/mkfs.ext3 %s %s',
'ext4':'/sbin/mkfs.ext4 %s %s',
'jfs':'/sbin/mkfs.jfs %s -f %s',
'reiserfs':'/sbin/mkfs.reiserfs %s -f %s',
'xfs':'/sbin/mkfs.xfs %s -f %s',
'vfat':'/usr/sbin/mkfs.vfat %s -F 32 %s',
'ntfs-3g':'/usr/sbin/mkfs.ntfs %s -FQ %s',
'ntfs':'/usr/sbin/mkfs.ntfs %s -FQ %s',
'swap':'/sbin/mkswap %s'
}
labelForUtilities = { 'ext2':'-L %s',
'ext3':'-L %s',
'ext4':'-L %s',
'jfs':'-L %s',
'reiserfs':'-l %s',
'xfs':'-L %s',
'vfat':'-n %s',
'ntfs-3g':'-L %s',
'ntfs':'-L %s',
}
formatId = { 'ext2' : '83',
'ext3' : '83',
@ -636,7 +646,8 @@ class PartitionDistributive(Distributive):
def __init__(self,partition,parent=None,mdirectory="/mnt/calculate",
check=False,multipartition=None,flagRemoveDir=True,
fileSystem="reiserfs", isFormat=True,systemId=None):
fileSystem="reiserfs", isFormat=True,systemId=None,
rootLabel="Calculate"):
"""Initialize partition distributive
mdirectory - directory for mount
@ -652,6 +663,7 @@ class PartitionDistributive(Distributive):
self.isFormat = isFormat
self.DirectoryObject = None
self.systemId = systemId
self.rootLabel = rootLabel
def _mountPartition(self,partition,directory,opts=""):
"""Mount partition to directory"""
@ -745,7 +757,11 @@ class PartitionDistributive(Distributive):
if fileSystem=="swap":
self.formatSwapPartition(dev)
else:
self.formatPartition(dev, format=fileSystem)
if dev == self.partition:
self.formatPartition(dev, format=fileSystem,
label=self.rootLabel)
else:
self.formatPartition(dev, format=fileSystem)
changeidPartitions = map(lambda x: (x[3],x[1]),
filter(lambda x: x[3],
dataPartitions))
@ -753,7 +769,7 @@ class PartitionDistributive(Distributive):
self.changeSystemID(dev,systemid)
return True
def formatPartition(self, dev,format="reiserfs"):
def formatPartition(self, dev,format="reiserfs",label=""):
"""Format partition"""
if not format in self.formatUtilities:
raise DistributiveError(
@ -770,7 +786,13 @@ class PartitionDistributive(Distributive):
if not os.access(dev,os.W_OK):
raise DistributiveError(_("Cann't format partition") + " %s:\n%s"%
(dev,_("Permission denied")))
execStr = self.formatUtilities[format]%dev
if label:
labelStr = self.labelForUtilities.get(format,"")
if labelStr:
labelStr = labelStr%label
else:
labelStr = ""
execStr = self.formatUtilities[format]%(labelStr,dev)
res,errmes = self.runOsCommand(execStr)
if res == 0:
return True
@ -783,7 +805,8 @@ class PartitionDistributive(Distributive):
if self.multipartition:
self.formatAllPartitions()
elif self.isFormat:
self.formatPartition(self.partition,format=self.fileSystem)
self.formatPartition(self.partition,format=self.fileSystem,
label=self.rootLabel)
def changeSystemID(self,dev,systemid):
parentDir = path.split(dev)[0]

@ -1009,7 +1009,9 @@ class fillVars(object, glob_attr):
def get_os_install_lang(self):
"""Supported languages"""
return clLocale().getLangs()
return list(set(clLocale().getLangs()) &
set(["en_US","de_DE","es_ES","fr_FR","it_IT","pl_PL","pt_BR",
"uk_UA","bg_BG","ru_RU"]))
def get_os_install_scratch(self):
"""Install system in scratch mode"""

@ -24,7 +24,7 @@ import traceback
from os import path
from cl_utils import runOsCommand,appendProgramToEnvFile, \
removeProgramToEnvFile,pathJoin, \
scanDirectory,process
scanDirectory,process,getTupleVersion
from cl_kernel_utils import KernelConfig,InitRamFs
@ -878,10 +878,13 @@ class cl_install(color_print, SignalInterrupt):
def getTargetDistributive(self,disk,fileSystem="reiserfs",isFormat=False,
systemId=None,buildermode=False):
"""Get target distributive by params"""
rootLabelName = "%s-%s"%(self.clVars.Get('os_install_linux_shortname'),
self.clVars.Get('os_install_linux_ver'))
if buildermode:
return ScratchPartitionDistributive(disk,mdirectory="/mnt/install",
check=True, fileSystem=fileSystem,
isFormat=isFormat, systemId=systemId)
isFormat=isFormat, systemId=systemId,
rootLabel=rootLabelName)
elif self.clVars.Get('os_install_root_type')=="flash":
return FlashDistributive(disk,mdirectory="/mnt/install",
check=True, fileSystem=fileSystem,
@ -889,7 +892,8 @@ class cl_install(color_print, SignalInterrupt):
else:
target = PartitionDistributive(disk,mdirectory="/mnt/install",
check=True, fileSystem=fileSystem,
isFormat=isFormat, systemId=systemId)
isFormat=isFormat, systemId=systemId,
rootLabel=rootLabelName)
noRootPartDisksOptions = filter(lambda x: x['mountPoint']!="/",
self.listDisksOptions)
flagMultipartition = False
@ -945,6 +949,13 @@ class cl_install(color_print, SignalInterrupt):
target.multipartition=objMultiPartitions
return target
def closeClTemplate(self):
if self.clTempl:
if self.clTempl.cltObj:
self.clTempl.cltObj.closeFiles()
self.clTempl.closeFiles()
self.clTempl = None
def applyTemplates(self,directory):
"""Apply templates for root of system."""
#self.clVars.Set("cl_root_path",directory, True)
@ -1778,7 +1789,15 @@ class cl_install(color_print, SignalInterrupt):
self.printInfo(sourceDistr,targetDistr)
distRep = DistributiveRepository()
minver = "10.8"
instver = \
getTupleVersion(self.clVars.Get('os_install_linux_ver'))
distName = self.clVars.Get('cl_image')
if distName and instver < getTupleVersion(minver):
self.printERROR(
_("Installation is supported for system not less version"
" %s")%minver)
distName = ""
if distName:
# print info
sourceDistr = distRep.getDistributiveByFile(distName)
@ -1844,8 +1863,7 @@ the system") + " (yes/no)"
if error:
self.printByResult(False)
try:
if self.clTempl:
self.clTempl.closeFiles()
self.closeClTemplate()
if sourceDistr:
self.printMessageForTest(_("Releasing source distributive"))
sourceDistr.close()
@ -1875,7 +1893,7 @@ the system") + " (yes/no)"
def setAllLocaleByLang(self,lang):
"""Set all locale variable by specified lang"""
locale = clLocale()
if not locale.isLangExists(lang):
if not lang in self.clVars.Get('os_install_lang'):
return False
self.clVars.Set('os_install_locale_lang',lang, True)
self.clVars.Set('os_install_locale_locale',

@ -65,6 +65,13 @@ CMD_OPTIONS = [{'shortOption':"d",
'choices':['cld','cds','cls','css','cldg','cldx'],
'help':_("select operation system")
},
{'shortOption':"m",
'longOption':"march",
'optVal':"ARCH",
'type':'choice',
'choices':['i686','x86_64'],
'help':_("select processor architecture")
},
{'shortOption':"l",
'longOption':"lang",
'optVal':"LANG",
@ -260,6 +267,8 @@ class install_cmd(share_cmd):
"""Check and set disk, swap and bind cmd options"""
if self.optobj.values.s:
self.logicObj.setLinuxName(self.optobj.values.s.upper())
if self.optobj.values.m:
self.logicObj.clVars.Set('os_install_arch_machine',self.optobj.values.m)
if self.optobj.values.build:
self.logicObj.clVars.Set('os_install_scratch',"on",True)
else:

@ -23,6 +23,7 @@ from cl_utils import _error
# Перевод сообщений для программы
from cl_lang import lang
lang().setLanguage(sys.modules[__name__])
import cl_overriding
class share_cmd(color_print, _error):
"""Класс общих методов обработки опций командной строки"""
@ -52,6 +53,7 @@ class share_cmd(color_print, _error):
varsNames.append(optCmd)
if "xml" in optObj.__dict__.keys() and optObj.xml:
format = "xml"
cl_overriding.exit = lambda x: ""
self.logicObj.clVars.printVars(varsFilter, varsNames,
outFormat=format)

Loading…
Cancel
Save