|
|
|
@ -23,6 +23,8 @@ from subprocess import Popen
|
|
|
|
|
from os import path
|
|
|
|
|
from itertools import *
|
|
|
|
|
from operator import itemgetter
|
|
|
|
|
from calculate.install.distr import FlashDistributive, DistributiveError, \
|
|
|
|
|
IsoDistributive
|
|
|
|
|
from calculate.lib.datavars import (TableVariable, Variable, VariableError,
|
|
|
|
|
ReadonlyVariable, ReadonlyTableVariable,
|
|
|
|
|
SourceReadonlyVariable, VariableInterface,
|
|
|
|
@ -35,7 +37,7 @@ from calculate.lib.utils.device import (getUdevDeviceInfo, getDeviceType,
|
|
|
|
|
getUUIDDict, getCommonDeviceName)
|
|
|
|
|
from calculate.install.variables.autopartition import Sizes
|
|
|
|
|
from calculate.lib.utils.files import (listDirectory, pathJoin, readFile, FStab,
|
|
|
|
|
isMount, getProgPath)
|
|
|
|
|
isMount, getProgPath, DiskSpace)
|
|
|
|
|
from calculate.install.fs_manager import FileSystemManager
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, _
|
|
|
|
@ -2152,47 +2154,26 @@ class VariableOsInstallDiskSingle(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Installation disk
|
|
|
|
|
"""
|
|
|
|
|
type = "choice"
|
|
|
|
|
type = "choiceedit"
|
|
|
|
|
opt = ["--disk", "-d"]
|
|
|
|
|
metavalue = 'DISK'
|
|
|
|
|
untrusted = True
|
|
|
|
|
value = ""
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Installation disk")
|
|
|
|
|
self.help = _("set the USB Flash device")
|
|
|
|
|
|
|
|
|
|
def availDevs(self):
|
|
|
|
|
"""
|
|
|
|
|
Available devices
|
|
|
|
|
"""
|
|
|
|
|
if self.Get('cl_install_type') == 'flash':
|
|
|
|
|
flashDrives = self.Select('os_device_dev',
|
|
|
|
|
where='os_device_type',
|
|
|
|
|
eq="flash")
|
|
|
|
|
return self.Select('os_disk_dev',
|
|
|
|
|
where='os_disk_parent',
|
|
|
|
|
_in=flashDrives)
|
|
|
|
|
else:
|
|
|
|
|
return self.Get('os_disk_dev') + self.Get('os_bind_path')
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.Get('cl_install_type') == 'flash':
|
|
|
|
|
disks = self.availDevs()
|
|
|
|
|
if disks:
|
|
|
|
|
return disks[0]
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
# TODO: любой раздел vfat, неформатированный или раздел на flash
|
|
|
|
|
# ??????
|
|
|
|
|
diskParentMap = dict(zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_parent')))
|
|
|
|
|
deviceParentMap = dict(self.ZipVars('os_device_dev', 'os_device_name'))
|
|
|
|
|
disks = self.select('os_disk_dev', os_disk_part__ne="")
|
|
|
|
|
return map(lambda x: (x, "%s (%s)" % (x,
|
|
|
|
|
deviceParentMap.get(
|
|
|
|
|
diskParentMap.get(x, x),
|
|
|
|
|
_("Unknown")))),
|
|
|
|
|
self.availDevs()) + [("", "")]
|
|
|
|
|
disks)
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
# проверить, чтобы был выбран именно раздел
|
|
|
|
@ -2234,6 +2215,7 @@ class VariableOsInstallFormatSingleSet(Variable):
|
|
|
|
|
type = "bool"
|
|
|
|
|
opt = ["--format"]
|
|
|
|
|
untrusted = True
|
|
|
|
|
value = "off"
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Format the USB Flash")
|
|
|
|
@ -2249,22 +2231,34 @@ class VariableOsInstallFormatSingleSet(Variable):
|
|
|
|
|
flash_dev = self.Get('os_root_flash_dev')
|
|
|
|
|
return flash_dev and dev == flash_dev
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
dev = self.Get('os_install_disk_single')
|
|
|
|
|
if self.must_be_formatted(dev):
|
|
|
|
|
return "on"
|
|
|
|
|
if self.cannot_be_formatted(dev):
|
|
|
|
|
return "off"
|
|
|
|
|
return "on"
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
devs = self.Get('os_disk_dev')
|
|
|
|
|
dev = self.Get('os_install_disk_single')
|
|
|
|
|
if value == "off":
|
|
|
|
|
if self.must_be_formatted(dev):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("{device} must be formatted").format(device=dev))
|
|
|
|
|
else:
|
|
|
|
|
if dev not in devs:
|
|
|
|
|
return
|
|
|
|
|
if value == "on":
|
|
|
|
|
if self.cannot_be_formatted(dev):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("You cannot format the USB Flash which "
|
|
|
|
|
"contains the current system"))
|
|
|
|
|
else:
|
|
|
|
|
if self.must_be_formatted(dev):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("{device} must be formatted").format(device=dev))
|
|
|
|
|
if dev:
|
|
|
|
|
try:
|
|
|
|
|
with FlashDistributive(dev) as f:
|
|
|
|
|
dn = f.getDirectory()
|
|
|
|
|
df = DiskSpace()
|
|
|
|
|
free_size = df.get_free(dev)
|
|
|
|
|
squash_fn = path.join(dn, "livecd.squashfs")
|
|
|
|
|
if not path.exists(squash_fn):
|
|
|
|
|
source = self.Get('cl_image')
|
|
|
|
|
if isinstance(source, IsoDistributive):
|
|
|
|
|
image_size = source.get_squash_size()
|
|
|
|
|
if image_size > free_size:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Not enough free space on the "
|
|
|
|
|
"USB Flash"))
|
|
|
|
|
except DistributiveError:
|
|
|
|
|
pass
|
|
|
|
|