Fix mbr and some bugs. Fix detect support fs.

master3.3
Mike Hiretsky 13 years ago
parent 8a24079a29
commit 99cd12b323

@ -681,17 +681,14 @@ class Install(color_print):
sourceDistr = None
try:
self.clVars.printVars()
#if self.clVars.Get('cl_autopartition_scheme'):
# self.startTask(_("Creating new partition table"),
# progress=True)
# AutoPartition().recreatePartitionTable(
# self.clVars.Get('cl_autopartition_table'),
# self.clVars.Get('cl_autopartition_device'),
# self.clVars.Get('cl_autopartition_scheme'),
# str(int(self.clVars.Get('hr_memory_size'))/1024),
# str(int(self.clVars.Get('cl_autopartition_root_size'))
# *1024))
# self.endTask()
if self.clVars.Get('cl_autopartition_set') == 'auto':
self.startTask(_("Creating new partition table"),
progress=True)
AutoPartition().recreatePartitionTable(
self.clVars.Get('cl_autopartition_table'),
self.clVars.Get('cl_autopartition_device'),
self.clVars.Get('cl_autopartition_disk_data'))
self.endTask()
targetDistr = self.clVars.Get('cl_target')
sourceDistr = self.clVars.Get('cl_image')
self.setTaskNumber(25)

@ -114,11 +114,15 @@ class Wsdl:
if methodname == "install":
self.fixInstallLocalization(sid,dv)
dv.processRefresh()
if info:
checkonly = info.CheckOnly
else:
checkonly = False
errors = map(lambda x:ReturnedMessage(**x),
dv.checkGroups(info,allvars=not info.CheckOnly))
dv.checkGroups(info,allvars=not checkonly))
if errors:
return errors
if info.CheckOnly:
if checkonly:
returnmess = ReturnedMessage(type = '', message = None)
return [returnmess]
install_meth = type("CommonInstall",(self.Common,

@ -35,7 +35,7 @@ import operator
from calculate.lib.cl_lang import setLocalTranslate
setLocalTranslate('cl_install3',sys.modules[__name__])
class Sizes:
class Sizes(object):
kB = kilobyte = 1000
K = kibibyte = 1024
M = mibibyte = K * 1024
@ -44,7 +44,7 @@ class Sizes:
Gb = gigabyte = Mb * 1000
T = tibibyte = G * 1024
Tb = terabyte = Gb * 1000
def __getattr__(self,name):
if name.startswith('from_'):
return lambda x:x*getattr(Sizes,name[5:])
@ -65,13 +65,13 @@ class AutoPartition:
"""
Autopartition maker
"""
def recreatePartitionTable(self,table,device,scheme,memory,rootsize):
def recreatePartitionTable(self,table,device,data):
"""
"""
mapDispatch = {'dos':self.recreatePartitionTableDos,
'gpt':self.recreatePartitionTableGpt}
if table in mapDispatch:
mapDispatch[table](device,scheme,memory,rootsize)
mapDispatch[table](device,data)
else:
raise AutoPartitionError(
_('Autopartitioning for %s is not supported')%table)
@ -88,15 +88,16 @@ class AutoPartition:
WRITE_AND_QUIT = "w\nq\n"
fdiskProg = getProgPath('/sbin/fdisk')
fdisk = process(fdiskProg,device)
fdisk = process(fdiskProg,device[0])
fdisk.write(NEW_PARTITION_TABLE)
num = 1
for size in map(lambda x:Sizes.to_K(x) if x.isdigit() else x,
map(itemgetter(3),data)):
for size in map(lambda x:str(Sizes().to_K(int(x))) \
if x.isdigit() else x,
map(operator.itemgetter(3),data)):
if num == 4:
fdisk.write(NEW_EXTENDED_PARTITION+MAX_SIZE)
num += 1
size = MAX_SIZE if size == "allsize" else "+%sK\n"%size
size = MAX_SIZE if size == "allfree" else "+%sK\n"%size
if num < 4:
fdisk.write(NEW_PRIMARY_PARTITION+size)
else:
@ -106,7 +107,7 @@ class AutoPartition:
fdisk.success()
for waittime in (0.1,0.2,0.5,1,2,4):
if path.exists(device+str(num-1)):
if path.exists(device[0]+str(num-1)):
return True
else:
sleep(waittime)
@ -114,7 +115,7 @@ class AutoPartition:
_("Failed to found partition %s after creating partition table")
%dev)
def recreatePartitionTableGpt(self,device,sizes):
def recreatePartitionTableGpt(self,device,data):
"""
Create GPT partition table by /sbin/gdisk
"""
@ -125,17 +126,18 @@ class AutoPartition:
WRITE_AND_QUIT = "w\ny\n"
fdiskProg = getProgPath('/usr/sbin/gdisk')
fdisk = process(fdiskProg,device)
fdisk = process(fdiskProg,device[0])
fdisk.write(NEW_PARTITION_TABLE)
num = 1
biosBootCreated = False
for size in map(lambda x:Sizes.to_K(x) if x.isdigit() else x,
map(itemgetter(3),data)):
for size in map(lambda x:str(Sizes().to_K(int(x))) \
if x.isdigit() else x,
map(operator.itemgetter(3),data)):
if num == 4:
fdisk.write(NEW_BIOSBOOT_PARTITION%"+2M")
biosBootCreated = True
num += 1
if size == "allsize":
if size == "allfree":
if biosBootCreated:
size = MAX_SIZE
else:
@ -149,7 +151,7 @@ class AutoPartition:
fdisk.write(WRITE_AND_QUIT)
fdisk.success()
for waittime in (0.1,0.2,0.5,1,2,4):
if path.exists(device+str(num-1)):
if path.exists(device[0]+str(num-1)):
return True
else:
sleep(waittime)
@ -291,8 +293,8 @@ class VariableClAutopartitionRootSize(Variable):
else:
size = 1024*10 # in M
deviceSize = self.Get('cl_autopartition_device_size')
if Sizes.from_M(size) >= deviceSize:
size = max(Sizes.to_M(deviceSize),Sizes.to_M(MINROOTSIZE))
if Sizes().from_M(size) >= deviceSize:
size = max(Sizes().to_M(deviceSize),Sizes().to_M(MINROOTSIZE))
return str(size)
def set(self,value):
@ -318,7 +320,7 @@ class VariableClAutopartitionRootSize(Variable):
def check(self,value):
if self.Get('cl_autopartition_device') and \
self.Get('cl_autopartition_set') == "auto":
if int(value) < Sizes.to_M(MINROOTSIZE):
if int(value) < Sizes().to_M(MINROOTSIZE):
raise VariableError(
_("Root partition size should not be less {size}").format(
size="7 Gb"))
@ -571,7 +573,7 @@ class VariableClAutopartitionDeviceSize(ReadonlyVariable):
where='os_device_dev',
_in=devices))
# TODO: remove set 10G
return str(1024*1024*1024*10)
#return str(1024*1024*1024*10)
return str(reduce(operator.add,sizeDevice))
class VariableClAutopartitionFreeSize(ReadonlyVariable):

@ -839,7 +839,7 @@ class VariableOsLocationFormat(LocationVariable,Variable):
osInstallRootType = self.Get('os_install_root_type')
availFS = set(self.Select('os_format_type',
where='os_format_use',
eq='on'))
eq='yes'))
def wrap(info):
dev,mount,fs = info
if mount and not fs and dev.startswith('/dev/'):
@ -1188,8 +1188,10 @@ class VariableOsInstallDiskSize(ReadonlyVariable):
self.Get('os_install_disk_dev'))
def humanReadable(self):
return map(humanreadableSize,
self.Get())
diskSize = dict(zip(self.Get('os_location_source'),
self.Get('os_location_size',humanreadable=True)))
return map(lambda x:diskSize.get(x,''),
self.Get('os_install_disk_dev'))
class VariableOsInstallDiskType(ReadonlyVariable):
"""
@ -1212,9 +1214,10 @@ class VariableOsInstallDiskParent(ReadonlyVariable):
def get(self):
diskParent = dict(self.ZipVars('os_disk_dev','os_disk_parent'))
# replace value for autopartition
diskParent.update(zip(self.Get('cl_autopartition_disk_dev'),
[self.Get('cl_autopartition_device')]*
len(self.Get('cl_autopartition_disk_dev'))))
if self.Get('cl_autopartition_set') == 'auto':
diskParent.update(zip(self.Get('cl_autopartition_disk_dev'),
self.Get('cl_autopartition_device')*
len(self.Get('cl_autopartition_disk_dev'))))
return map(lambda x:diskParent.get(x,''),
self.Get('os_install_disk_dev'))
@ -1315,8 +1318,11 @@ class VariableOsInstallMbr(LocationVariable,Variable):
raise VariableError(
_("For flash installation need only one disk"))
for mbrDisk in value:
tableOnBootDisk = self.Select('os_device_table',
where="os_device_dev",eq=mbrDisk,limit=1)
if self.Get('cl_autopartition_set') == 'auto':
tableOnBootDisk = self.Get('cl_autopartition_table')
else:
tableOnBootDisk = self.Select('os_device_table',
where="os_device_dev",eq=mbrDisk,limit=1)
if not tableOnBootDisk:
raise VariableError(
_("Disk '%s' without partition table "

@ -107,6 +107,7 @@ class VariableClMigrateData(UserVariable):
opt = ["--users","-u"]
metavalue = 'USERS'
source = ['cl_migrate_user','cl_migrate_user_pwd']
untrusted = True
def init(self):
self.help = _("add a user to the installed system")

Loading…
Cancel
Save