|
|
|
@ -50,8 +50,7 @@ class DeviceHelper(VariableInterface):
|
|
|
|
|
|
|
|
|
|
def getBlockDevices(self):
|
|
|
|
|
"""Get interest devices from sys block path"""
|
|
|
|
|
return filter(self.rePassDevice.search,
|
|
|
|
|
device.udev.get_block_devices())
|
|
|
|
|
return [x for x in device.udev.get_block_devices() if self.rePassDevice.search(x)]
|
|
|
|
|
|
|
|
|
|
def separateDevice(self, dev):
|
|
|
|
|
"""
|
|
|
|
@ -59,8 +58,7 @@ class DeviceHelper(VariableInterface):
|
|
|
|
|
|
|
|
|
|
Using for sort. (Example: sda2 ("sda",2), md5p1 ("md",5,"p",1)
|
|
|
|
|
"""
|
|
|
|
|
return map(lambda x: int(x) if x.isdigit() else x,
|
|
|
|
|
re.findall('\d+|\D+', dev))
|
|
|
|
|
return [int(x) if x.isdigit() else x for x in re.findall('\d+|\D+', dev)]
|
|
|
|
|
|
|
|
|
|
def mapUdevProperty(self, var, prop, default):
|
|
|
|
|
"""Get each element from var through udev [prop]"""
|
|
|
|
@ -180,8 +178,7 @@ class VariableOsDeviceDev(DeviceHelper, ReadonlyVariable):
|
|
|
|
|
if device.udev.is_device(device.udev.get_device_info(x)) or
|
|
|
|
|
self.re_disk_raid.match(device.udev.get_device_type(path=x)))
|
|
|
|
|
|
|
|
|
|
return list(sorted((x for x in devnames),
|
|
|
|
|
key=self.separateDevice))
|
|
|
|
|
return list(sorted((x for x in devnames), key=self.separateDevice))
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceFulltype(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
@ -221,15 +218,13 @@ class VariableOsDeviceType(ReadonlyVariable):
|
|
|
|
|
# get usb device by '/dev/disk/by-id'(usb devices contain 'usb' in name)
|
|
|
|
|
diskIdPath = '/dev/disk/by-id'
|
|
|
|
|
if device.devfs.exists(diskIdPath):
|
|
|
|
|
self.usbdevices = \
|
|
|
|
|
map(lambda x: \
|
|
|
|
|
device.devfs.realpath(diskIdPath, x).rpartition('/')[2],
|
|
|
|
|
filter(lambda x: x.startswith('usb-'),
|
|
|
|
|
device.devfs.listdir(diskIdPath, fullpath=False)))
|
|
|
|
|
self.usbdevices = [device.devfs.realpath(diskIdPath, x).rpartition('/')[2] for x
|
|
|
|
|
in device.devfs.listdir(diskIdPath, fullpath=False)
|
|
|
|
|
if x.startswith('usb-')]
|
|
|
|
|
else:
|
|
|
|
|
self.usbdevices = []
|
|
|
|
|
return map(self.getType,
|
|
|
|
|
self.Get('os_device_dev'))
|
|
|
|
|
return [self.getType(x) for x in self.Get('os_device_dev')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceParent(ReadonlyVariable):
|
|
|
|
@ -313,8 +308,7 @@ class VariableOsDeviceMap(ReadonlyVariable):
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return map(lambda x: str(x[0]),
|
|
|
|
|
enumerate(self.Get('os_device_dev')))
|
|
|
|
|
return [str(x[0]) for x in enumerate(self.Get('os_device_dev'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceArraySet(ReadonlyVariable):
|
|
|
|
@ -334,9 +328,7 @@ class VariableOsDeviceArraySet(ReadonlyVariable):
|
|
|
|
|
else:
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
return map(lambda x: isArray(*x),
|
|
|
|
|
zip(self.Get('os_device_dev'),
|
|
|
|
|
self.Get('os_device_name')))
|
|
|
|
|
return [isArray(*x) for x in zip(self.Get('os_device_dev'), self.Get('os_device_name'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceSsdSet(ReadonlyVariable):
|
|
|
|
@ -361,9 +353,7 @@ class VariableOsDeviceSsdSet(ReadonlyVariable):
|
|
|
|
|
else:
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
return map(lambda x: isSsd(*x),
|
|
|
|
|
zip(self.Get('os_device_dev'),
|
|
|
|
|
self.Get('os_device_name')))
|
|
|
|
|
return [isSsd(*x) for x in zip(self.Get('os_device_dev'), self.Get('os_device_name'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceSyspath(ReadonlyVariable):
|
|
|
|
@ -403,10 +393,9 @@ class VariableOsDeviceVirtualSet(ReadonlyVariable):
|
|
|
|
|
else:
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
return map(lambda x: isVirtual(*x),
|
|
|
|
|
zip(self.Get('os_device_dev'),
|
|
|
|
|
self.Get('os_device_name'),
|
|
|
|
|
self.Get('os_device_syspath')))
|
|
|
|
|
return [isVirtual(*x) for x in zip(self.Get('os_device_dev'),
|
|
|
|
|
self.Get('os_device_name'),
|
|
|
|
|
self.Get('os_device_syspath'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceTable(ReadonlyVariable):
|
|
|
|
@ -444,8 +433,8 @@ class VariableOsDeviceTable(ReadonlyVariable):
|
|
|
|
|
else:
|
|
|
|
|
return getTable(dev)
|
|
|
|
|
|
|
|
|
|
return map(getByAutopartition,
|
|
|
|
|
self.Get('os_device_dev'))
|
|
|
|
|
return [getByAutopartition(x) for x in self.Get('os_device_dev')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceName(ReadonlyVariable):
|
|
|
|
@ -475,8 +464,7 @@ class VariableOsDeviceName(ReadonlyVariable):
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return map(self.getName,
|
|
|
|
|
self.Get('os_device_dev'))
|
|
|
|
|
return [self.getName(x) for x in self.Get('os_device_dev')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDeviceSize(ReadonlyVariable):
|
|
|
|
@ -487,12 +475,10 @@ class VariableOsDeviceSize(ReadonlyVariable):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
"""Get device size"""
|
|
|
|
|
return map(lambda x: getPartitionSize(name=x, inBytes=True),
|
|
|
|
|
self.Get('os_device_dev'))
|
|
|
|
|
return [getPartitionSize(name=x, inBytes=True) for x in self.Get('os_device_dev')]
|
|
|
|
|
|
|
|
|
|
def humanReadable(self):
|
|
|
|
|
return map(humanreadableSize,
|
|
|
|
|
self.Get())
|
|
|
|
|
return [humanreadableSize(x) for x in self.Get()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
@ -536,8 +522,7 @@ class VariableOsDiskDev(DeviceHelper, ReadonlyVariable):
|
|
|
|
|
return list(sorted((x for x in dev_names), key=self.separateDevice))
|
|
|
|
|
|
|
|
|
|
def humanReadable(self):
|
|
|
|
|
return map(self.getPerfectName,
|
|
|
|
|
self.Get())
|
|
|
|
|
return [self.getPerfectName(x) for x in self.Get()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
|
|
|
|
@ -550,8 +535,7 @@ class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
|
|
|
|
|
disk_hash = self.Get('os_disk_dev')
|
|
|
|
|
fstab = FStab('/etc/fstab', devs=disk_hash)
|
|
|
|
|
rootdev = self.Get('os_root_dev')
|
|
|
|
|
return map(lambda x: '/' if x == rootdev else fstab.getBy(eq=x) or "",
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
return ['/' if x == rootdev else fstab.getBy(eq=x) or "" for x in self.Get('os_disk_dev')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskContent(ReadonlyVariable):
|
|
|
|
@ -564,8 +548,7 @@ class VariableOsDiskContent(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
TODO: need to write
|
|
|
|
|
"""
|
|
|
|
|
return map(lambda x: "",
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
return ["" for x in self.Get('os_disk_dev')]
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskFormat(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
@ -593,8 +576,7 @@ class VariableOsDiskFormat(ReadonlyVariable):
|
|
|
|
|
pass
|
|
|
|
|
return fs
|
|
|
|
|
|
|
|
|
|
return map(getFormat,
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
return [getFormat(x) for x in self.Get('os_disk_dev')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskType(ReadonlyVariable):
|
|
|
|
@ -607,8 +589,8 @@ class VariableOsDiskType(ReadonlyVariable):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
"""Get partition scheme"""
|
|
|
|
|
types = map(lambda x: (x, device.udev.get_device_type(name=x)),
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
|
|
|
|
|
types = [(x, device.udev.get_device_type(name=x)) for x in self.Get('os_disk_dev')]
|
|
|
|
|
lvmUsedDisks = {}
|
|
|
|
|
raidUsedDisks = {}
|
|
|
|
|
|
|
|
|
@ -622,7 +604,6 @@ class VariableOsDiskType(ReadonlyVariable):
|
|
|
|
|
",".join(
|
|
|
|
|
lvmUsedDisks[diskName]))
|
|
|
|
|
return diskName, diskType
|
|
|
|
|
|
|
|
|
|
for dev, diskType in types:
|
|
|
|
|
prop = device.udev.get_device_info(name=dev)
|
|
|
|
|
if self.re_raid.search(diskType):
|
|
|
|
@ -642,9 +623,8 @@ class VariableOsDiskType(ReadonlyVariable):
|
|
|
|
|
lvmUsedDisks[x].append(dev)
|
|
|
|
|
else:
|
|
|
|
|
lvmUsedDisks[x] = [dev]
|
|
|
|
|
return map(lambda x: x[1],
|
|
|
|
|
map(forMember,
|
|
|
|
|
types))
|
|
|
|
|
|
|
|
|
|
return [x[1] for x in map(forMember, types)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskRaid(ReadonlyVariable):
|
|
|
|
@ -672,8 +652,7 @@ class VariableOsDiskLvm(DeviceHelper, ReadonlyVariable):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
"""Get each element from var through udev [prop]"""
|
|
|
|
|
return map(self.getLvmName,
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
return [self.getLvmName(x) for x in self.Get('os_disk_dev')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskUuid(DeviceHelper, ReadonlyVariable):
|
|
|
|
@ -723,10 +702,9 @@ class VariableOsDiskId(DeviceHelper, ReadonlyVariable):
|
|
|
|
|
'21686148-6449-6e6f-744e-656564454649': 'EF02',
|
|
|
|
|
'c12a7328-f81f-11d2-ba4b-00a0c93ec93b': 'EF00',
|
|
|
|
|
'0fc63daf-8483-4772-8e79-3d69d8477de4': '8300'}
|
|
|
|
|
return map(lambda x: mapTypeUUID.get(x, x),
|
|
|
|
|
map(lambda x: x.rpartition("x")[2],
|
|
|
|
|
self.mapUdevProperty('os_disk_dev', 'ID_PART_ENTRY_TYPE',
|
|
|
|
|
'')))
|
|
|
|
|
return [mapTypeUUID.get(x, x) for x
|
|
|
|
|
in [y.rpartition("x")[2] for y
|
|
|
|
|
in self.mapUdevProperty('os_disk_dev', 'ID_PART_ENTRY_TYPE','')]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskGrub(ReadonlyVariable):
|
|
|
|
@ -753,10 +731,10 @@ class VariableOsDiskGrub(ReadonlyVariable):
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
return map(getGrubMap,
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_type'),
|
|
|
|
|
self.Get('os_disk_parent')))
|
|
|
|
|
return [getGrubMap(x) for x
|
|
|
|
|
in zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_type'),
|
|
|
|
|
self.Get('os_disk_parent'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskPart(ReadonlyVariable):
|
|
|
|
@ -766,7 +744,7 @@ class VariableOsDiskPart(ReadonlyVariable):
|
|
|
|
|
If gpt then gpt
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
def generator():
|
|
|
|
|
for disk_dev, disk_type in self.ZipVars(
|
|
|
|
@ -786,12 +764,10 @@ class VariableOsDiskSize(ReadonlyVariable):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
"""Get disk size"""
|
|
|
|
|
return map(lambda x: getPartitionSize(name=x, inBytes=True),
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
return [getPartitionSize(name=x, inBytes=True) for x in self.Get('os_disk_dev')]
|
|
|
|
|
|
|
|
|
|
def humanReadable(self):
|
|
|
|
|
return map(humanreadableSize,
|
|
|
|
|
self.Get())
|
|
|
|
|
return [humanreadableSize(x) for x in self.Get()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsDiskName(DeviceHelper, ReadonlyVariable):
|
|
|
|
@ -817,9 +793,7 @@ class VariableOsDiskOptions(ReadonlyVariable):
|
|
|
|
|
def getFormat(dev):
|
|
|
|
|
return fstab.getBy(what=fstab.OPTS, eq=dev)
|
|
|
|
|
|
|
|
|
|
return map(getFormat,
|
|
|
|
|
self.Get('os_disk_dev'))
|
|
|
|
|
|
|
|
|
|
return [getFormat(x) for x in self.Get('os_disk_dev')]
|
|
|
|
|
|
|
|
|
|
################################################
|
|
|
|
|
# Bind mount points
|
|
|
|
@ -1042,11 +1016,11 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
|
|
|
|
|
return path.normpath(val)
|
|
|
|
|
return val
|
|
|
|
|
|
|
|
|
|
return map(normpath, value)
|
|
|
|
|
return [normpath(x) for x in value]
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
return map(lambda x: (x, self.getPerfectName(x) or x),
|
|
|
|
|
self.fixOsDiskDev(self.availDevs(choice=True))) + [("", "")]
|
|
|
|
|
return [(x, self.getPerfectName(x) or x) for x
|
|
|
|
|
in self.fixOsDiskDev(self.availDevs(choice=True))] + [("", "")]
|
|
|
|
|
|
|
|
|
|
def fixOsDiskDev(self, sourcelist=None):
|
|
|
|
|
"""
|
|
|
|
@ -1081,23 +1055,21 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
|
|
|
|
|
###########################
|
|
|
|
|
# check wrong dev
|
|
|
|
|
###########################
|
|
|
|
|
disks = filter(lambda x: x.startswith('/dev/'), value)
|
|
|
|
|
disks = [x for x in value if x.startswith('/dev/')]
|
|
|
|
|
# get original /dev names
|
|
|
|
|
cnDisks = (device.udev.get_device_info(name=x).get('DEVNAME', x)
|
|
|
|
|
for x in disks)
|
|
|
|
|
wrongDevices = list(set(cnDisks) -
|
|
|
|
|
set(self.fixOsDiskDev()))
|
|
|
|
|
wrongDevices = list(set(cnDisks) - set(self.fixOsDiskDev()))
|
|
|
|
|
if wrongDevices:
|
|
|
|
|
raise VariableError(_("Wrong device '%s'") % wrongDevices[0])
|
|
|
|
|
wrongSource = filter(lambda x: x and not x.startswith('/'), value)
|
|
|
|
|
wrongSource = [x for x in value if x and not x.startswith('/')]
|
|
|
|
|
if wrongSource:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Wrong bind mount point '%s'") % wrongSource[0])
|
|
|
|
|
##########################
|
|
|
|
|
# detect duplicate devices
|
|
|
|
|
##########################
|
|
|
|
|
dupDevices = list(set(filter(lambda x: disks.count(x) > 1,
|
|
|
|
|
disks)))
|
|
|
|
|
dupDevices = [x for x in disks if disks.count(x) > 1]
|
|
|
|
|
if dupDevices:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Device '%s' is used more than once") % dupDevices[0])
|
|
|
|
@ -1141,12 +1113,10 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
return ""
|
|
|
|
|
return mount
|
|
|
|
|
|
|
|
|
|
return map(installMountPoint,
|
|
|
|
|
filter(lambda x: x[0] in source,
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_mount')) + \
|
|
|
|
|
zip(self.Get('os_bind_path'),
|
|
|
|
|
self.Get('os_bind_mountpoint'))))
|
|
|
|
|
return [installMountPoint(x) for x
|
|
|
|
|
in list(zip(self.Get('os_disk_dev'),self.Get('os_disk_mount'))) + \
|
|
|
|
|
list(zip(self.Get('os_bind_path'),self.Get('os_bind_mountpoint')))
|
|
|
|
|
if x[0] in source]
|
|
|
|
|
|
|
|
|
|
def set(self, value):
|
|
|
|
|
"""Add abilitiy not specify root"""
|
|
|
|
@ -1157,7 +1127,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
return val
|
|
|
|
|
|
|
|
|
|
value = map(normpath, value)
|
|
|
|
|
return map(lambda x: x or "/", value)
|
|
|
|
|
return [x or "/" for x in value]
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
if self.Get('cl_install_type') == 'flash':
|
|
|
|
@ -1177,10 +1147,8 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
osInstallRootType = self.Get('os_install_root_type')
|
|
|
|
|
if osInstallRootType != "flash" and \
|
|
|
|
|
not "/usr" in value:
|
|
|
|
|
for mp, size in filter(lambda x: x[0] == '/' and x[1].isdigit() and \
|
|
|
|
|
int(x[1]) < minroot,
|
|
|
|
|
izip(value,
|
|
|
|
|
self.Get("os_location_size"))):
|
|
|
|
|
for mp, size in (x for x in zip(value, self.Get("os_location_size"))
|
|
|
|
|
if x[0] == '/' and x[1].isdigit() and int(x[1]) < minroot):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("The root partition should be at least %s") % "7 Gb")
|
|
|
|
|
source = self.Get("os_location_source")
|
|
|
|
@ -1189,15 +1157,13 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
################################
|
|
|
|
|
if not source:
|
|
|
|
|
return
|
|
|
|
|
if not filter(lambda x: x == "/", value):
|
|
|
|
|
if not [x for x in value if x == "/"]:
|
|
|
|
|
raise VariableError(_("To install the system, you need to "
|
|
|
|
|
"specify the root device"))
|
|
|
|
|
################################
|
|
|
|
|
disks = filter(lambda x: x[0].startswith('/dev/') and x[1],
|
|
|
|
|
zip(source, value))
|
|
|
|
|
disksDevs = map(lambda x: x[0], disks)
|
|
|
|
|
binds = filter(lambda x: not x[0].startswith('/dev/') and x[1],
|
|
|
|
|
zip(source, value))
|
|
|
|
|
disks = [x for x in zip(source, value) if x[0].startswith('/dev/') and x[1]]
|
|
|
|
|
disksDevs = [x[0] for x in disks]
|
|
|
|
|
binds = [x for x in zip(source, value) if not x[0].startswith('/dev/') and x[1]]
|
|
|
|
|
##########################
|
|
|
|
|
# detect efi specifing
|
|
|
|
|
##########################
|
|
|
|
@ -1213,18 +1179,16 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
##########################
|
|
|
|
|
# detect duplicate mps
|
|
|
|
|
##########################
|
|
|
|
|
dupMP = list(set(filter(lambda x: value.count(x) > 1,
|
|
|
|
|
filter(lambda x: x and x != "swap",
|
|
|
|
|
value))))
|
|
|
|
|
dupMP = list(set([x for x in [y for y in value if y and y != "swap"] if value.count(x) > 1]))
|
|
|
|
|
if dupMP:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Mount point '%s' is used more than once") % dupMP[0])
|
|
|
|
|
#########################
|
|
|
|
|
# detect wrong bind
|
|
|
|
|
#########################
|
|
|
|
|
wrongBind = filter(lambda x: not x[0].startswith("/") or
|
|
|
|
|
not x[1].startswith("/"),
|
|
|
|
|
binds)
|
|
|
|
|
wrongBind = [x for x in binds
|
|
|
|
|
if not x[0].startswith("/") or
|
|
|
|
|
not x[1].startswith("/")]
|
|
|
|
|
if wrongBind:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Incorrect mount point (bind '%(bindSrc)s' to "
|
|
|
|
@ -1234,8 +1198,8 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
#########################################
|
|
|
|
|
# Check '/' in start path of dest pointst
|
|
|
|
|
#########################################
|
|
|
|
|
wrongMP = filter(lambda x: x and not x.startswith("/") and x != "swap",
|
|
|
|
|
value)
|
|
|
|
|
wrongMP = [x for x in value
|
|
|
|
|
if x and not x.startswith("/") and x != "swap"]
|
|
|
|
|
if wrongMP:
|
|
|
|
|
raise VariableError(_("Wrong mount point '%s'") % wrongMP[0])
|
|
|
|
|
#########################################
|
|
|
|
@ -1269,12 +1233,11 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
# check cross bind mount points
|
|
|
|
|
###############################
|
|
|
|
|
DEVICE, MP = 0, 1
|
|
|
|
|
srcMountPoints = map(lambda x: x[DEVICE], binds)
|
|
|
|
|
destMountPoints = map(lambda x: x[MP], binds)
|
|
|
|
|
wrongBind = filter(lambda x: x in destMountPoints, srcMountPoints)
|
|
|
|
|
srcMountPoints = (x[DEVICE] for x in binds)
|
|
|
|
|
destMountPoints = (x[MP] for x in binds)
|
|
|
|
|
wrongBind = [x for x in srcMountPoints if x in destMountPoints]
|
|
|
|
|
if wrongBind:
|
|
|
|
|
incompBind = filter(lambda x: x[1] == wrongBind[0],
|
|
|
|
|
zip(srcMountPoints, destMountPoints))
|
|
|
|
|
incompBind = [x for x in zip(srcMountPoints, destMountPoints) if x[1] == wrongBind[0]]
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Source directory %(src)s is already used "
|
|
|
|
|
"for binding '%(bindSrc)s' to '%(bindDst)s'") \
|
|
|
|
@ -1286,10 +1249,10 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
#######################################
|
|
|
|
|
osInstallRootType = self.Get('os_install_root_type')
|
|
|
|
|
if osInstallRootType == "flash":
|
|
|
|
|
if filter(lambda x: x and x != '/', value):
|
|
|
|
|
if [x for x in value if x and x != '/']:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Flash install does not support multipartition mode"))
|
|
|
|
|
if filter(lambda x: x == "swap", value):
|
|
|
|
|
if [x for x in value if x == "swap"]:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Flash install does not support swap disks"))
|
|
|
|
|
########################################
|
|
|
|
@ -1298,8 +1261,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
|
|
|
|
|
installTypes = zip(self.Get('os_install_disk_dev'),
|
|
|
|
|
self.Get('os_install_disk_type'))
|
|
|
|
|
for checkType in ("raid", "lvm"):
|
|
|
|
|
memberData = filter(lambda x: checkType + "member" in x[1],
|
|
|
|
|
installTypes)
|
|
|
|
|
memberData = [x for x in installTypes if checkType + "member" in x[1]]
|
|
|
|
|
if memberData:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Unable to use {part} partition used by active "
|
|
|
|
@ -1317,13 +1279,12 @@ class VariableOsLocationFormat(LocationHelper, Variable):
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.Get('cl_autopartition_set') == "on":
|
|
|
|
|
return self.Get('cl_autopartition_disk_format') + \
|
|
|
|
|
map(lambda x: "", self.Get('cl_autopartition_bind_path'))
|
|
|
|
|
["" for x in self.Get('cl_autopartition_bind_path')]
|
|
|
|
|
else:
|
|
|
|
|
mount = self.Get("os_location_dest")
|
|
|
|
|
source = self.Get("os_location_source")
|
|
|
|
|
value = [""] * len(source)
|
|
|
|
|
return map(self.defaultFormat(),
|
|
|
|
|
zip(source, mount, value))
|
|
|
|
|
return [self.defaultFormat()(x) for x in zip(source, mount, value)]
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
if self.Get('cl_install_type') == "flash":
|
|
|
|
@ -1381,11 +1342,10 @@ class VariableOsLocationFormat(LocationHelper, Variable):
|
|
|
|
|
return wrap
|
|
|
|
|
|
|
|
|
|
def set(self, value):
|
|
|
|
|
value = map(lambda x: "vfat" if x == "uefi" else x, value)
|
|
|
|
|
value = ["vfat" if x == "uefi" else x for x in value]
|
|
|
|
|
mount = self.Get("os_location_dest")
|
|
|
|
|
source = self.Get("os_location_source")
|
|
|
|
|
return map(self.defaultFormat(),
|
|
|
|
|
zip(source, mount, value))
|
|
|
|
|
return [self.defaultFormat()(x) for x in zip(source, mount, value)]
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
osInstallRootType = self.Get('os_install_root_type')
|
|
|
|
@ -1423,17 +1383,14 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.Get('cl_autopartition_set') == "on":
|
|
|
|
|
return map(lambda x: "on",
|
|
|
|
|
self.Get('cl_autopartition_disk_format')) + \
|
|
|
|
|
map(lambda x: "",
|
|
|
|
|
self.Get('cl_autopartition_bind_path'))
|
|
|
|
|
return ["on" for x in self.Get('cl_autopartition_disk_format')] + \
|
|
|
|
|
["" for x in self.Get('cl_autopartition_bind_path')]
|
|
|
|
|
else:
|
|
|
|
|
mount = self.Get("os_location_dest")
|
|
|
|
|
source = self.Get("os_location_source")
|
|
|
|
|
fs = self.Get("os_location_format")
|
|
|
|
|
value = [""] * len(source)
|
|
|
|
|
return map(self.defaultPerformFormat(),
|
|
|
|
|
zip(source, mount, fs, value))
|
|
|
|
|
return [self.defaultPerformFormat()(x) for x in zip(source, mount, fs, value)]
|
|
|
|
|
|
|
|
|
|
fixNtfs = lambda self, x: {'ntfs-3g': 'ntfs'}.get(x, x)
|
|
|
|
|
|
|
|
|
@ -1531,11 +1488,9 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
|
|
|
|
|
self.Get('os_location_dest'),
|
|
|
|
|
self.Get('os_location_format'),
|
|
|
|
|
value)
|
|
|
|
|
return map(self.defaultPerformFormat(),
|
|
|
|
|
map(lambda x: [x[DEV], x[MP], x[FS], ""] \
|
|
|
|
|
if x[FORMAT] == "off" and not x[DEV].startswith("/dev/")
|
|
|
|
|
else x,
|
|
|
|
|
info))
|
|
|
|
|
return [self.defaultPerformFormat()(x) for x
|
|
|
|
|
in [[y[DEV], y[MP], y[FS], ""]
|
|
|
|
|
if y[FORMAT] == "off" and not y[DEV].startswith("/dev/") else y for y in info]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsLocationSize(LocationHelper, SourceReadonlyVariable):
|
|
|
|
@ -1678,8 +1633,7 @@ class VariableOsInstallDiskDev(ReadonlyVariable, DeviceHelper):
|
|
|
|
|
self.Get('os_install_disk_dev_base'))
|
|
|
|
|
|
|
|
|
|
def humanReadable(self):
|
|
|
|
|
return map(lambda x: self.getPerfectName(x, defaultValue=x),
|
|
|
|
|
self.Get())
|
|
|
|
|
return [self.getPerfectName(x, defaultValue=x) for x in self.Get()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallDiskUuid(ReadonlyVariable):
|
|
|
|
@ -1691,7 +1645,7 @@ class VariableOsInstallDiskUuid(ReadonlyVariable):
|
|
|
|
|
def get(self):
|
|
|
|
|
diskDev = self.Get('os_install_disk_dev')
|
|
|
|
|
hashUUID = getUUIDDict(revers=True)
|
|
|
|
|
return map(lambda x: hashUUID.get(x, "")[5:], diskDev)
|
|
|
|
|
return [hashUUID.get(x, "")[5:] for x in diskDev]
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallDiskPartuuid(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
@ -1756,9 +1710,8 @@ class VariableOsInstallDiskUse(ReadonlyVariable):
|
|
|
|
|
def get(self):
|
|
|
|
|
"""Get real id (by cl_uuid_set) device"""
|
|
|
|
|
if self.Get('cl_uuid_set') == "on":
|
|
|
|
|
return map(lambda x: "UUID=%s" % x[0] if x[0] else x[1],
|
|
|
|
|
zip(self.Get('os_install_disk_uuid'),
|
|
|
|
|
self.Get('os_install_disk_dev')))
|
|
|
|
|
return ["UUID=%s" % x[0] if x[0] else x[1] for x
|
|
|
|
|
in zip(self.Get('os_install_disk_uuid'), self.Get('os_install_disk_dev'))]
|
|
|
|
|
else:
|
|
|
|
|
return self.Get('os_install_disk_dev')
|
|
|
|
|
|
|
|
|
@ -1820,11 +1773,11 @@ class VariableOsInstallDiskPerformFormat(ReadonlyVariable):
|
|
|
|
|
type = "bool-list"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
_format = map(lambda x: x[2],
|
|
|
|
|
filter(lambda x: x[0].startswith('/dev/') and x[1],
|
|
|
|
|
zip(self.Get('os_location_source'),
|
|
|
|
|
self.Get('os_location_dest'),
|
|
|
|
|
self.Get('os_location_perform_format'))))
|
|
|
|
|
_format = [x[2] for x
|
|
|
|
|
in zip(self.Get('os_location_source'),
|
|
|
|
|
self.Get('os_location_dest'),
|
|
|
|
|
self.Get('os_location_perform_format'))
|
|
|
|
|
if x[0].startswith('/dev/') and x[1]]
|
|
|
|
|
if self.GetBool('cl_autopartition_set'):
|
|
|
|
|
efiformat = ['on' for x in self.Get('os_install_uefi')]
|
|
|
|
|
res = efiformat + _format
|
|
|
|
@ -1880,9 +1833,7 @@ class VariableOsInstallDiskName(Variable):
|
|
|
|
|
else:
|
|
|
|
|
return diskLabel.get(dev, '')
|
|
|
|
|
|
|
|
|
|
return map(changeLabel,
|
|
|
|
|
self.ZipVars('os_install_disk_dev',
|
|
|
|
|
'os_install_disk_mount'))
|
|
|
|
|
return [changeLabel(x) for x in self.ZipVars('os_install_disk_dev','os_install_disk_mount')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallDiskSize(SourceReadonlyVariable):
|
|
|
|
@ -2118,7 +2069,7 @@ class VariableOsInstallUefi(LocationHelper, Variable):
|
|
|
|
|
return self.select('os_device_efi',
|
|
|
|
|
os_device_dev=efidev, limit=1) or efidev
|
|
|
|
|
return efidev
|
|
|
|
|
return filter(lambda x: x != "off", map(transform, value))
|
|
|
|
|
return [x for x in map(transform, value) if x != "off"]
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
deviceParentMap = self.ZipVars('os_device_dev',
|
|
|
|
@ -2209,8 +2160,7 @@ class VariableOsInstallMbr(LocationHelper, Variable):
|
|
|
|
|
return self.Get('cl_autopartition_mbr')
|
|
|
|
|
if self.Get('os_install_root_type') in ("flash", "usb-hdd"):
|
|
|
|
|
rootdev = self.Get('os_install_root_dev')
|
|
|
|
|
device = filter(lambda x: x in rootdev,
|
|
|
|
|
self.Get('os_device_dev'))
|
|
|
|
|
device = [x for x in self.Get('os_device_dev') if x in rootdev]
|
|
|
|
|
if device:
|
|
|
|
|
return [device[0]]
|
|
|
|
|
else:
|
|
|
|
@ -2233,7 +2183,7 @@ class VariableOsInstallMbr(LocationHelper, Variable):
|
|
|
|
|
|
|
|
|
|
def set(self, value):
|
|
|
|
|
# support off value
|
|
|
|
|
return filter(lambda x: x != "off", value)
|
|
|
|
|
return [x for x in value if x != "off"]
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
if self.GetBool('cl_autopartition_set'):
|
|
|
|
@ -2435,9 +2385,8 @@ class VariableOsInstallFstabMountConf(DeviceHelper, ReadonlyVariable):
|
|
|
|
|
bindData = self.ZipVars('os_install_bind_path',
|
|
|
|
|
'os_install_bind_mountpoint')
|
|
|
|
|
|
|
|
|
|
bindLines = "\n".join(map(lambda x: "%s\t%s\tnone\tbind\t0 0" \
|
|
|
|
|
% (x[0], x[1]), bindData))
|
|
|
|
|
return "\n".join(filter(lambda x: x, [rootLine, otherLines, bindLines]))
|
|
|
|
|
bindLines = "\n".join(("%s\t%s\tnone\tbind\t0 0" % (x[0], x[1]) for x in bindData))
|
|
|
|
|
return "\n".join((x for x in [rootLine, otherLines, bindLines] if x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallFstabEfiConf(VariableOsInstallFstabMountConf):
|
|
|
|
@ -2464,7 +2413,7 @@ class VariableOsInstallFstabEfiConf(VariableOsInstallFstabMountConf):
|
|
|
|
|
for used, mp, fs, opts, dev in devicesForFstab
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return "\n".join(filter(lambda x: x, [efiLines]))
|
|
|
|
|
return "\n".join((x for x in [efiLines] if x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallFstabSwapConf(VariableOsInstallFstabMountConf):
|
|
|
|
@ -2473,13 +2422,12 @@ class VariableOsInstallFstabSwapConf(VariableOsInstallFstabMountConf):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return "\n".join(map(lambda x: "%s\tnone\tswap\tsw\t0 0" % \
|
|
|
|
|
self._commentFstab(x[0], "swap", x[2]),
|
|
|
|
|
self.Select(['os_install_disk_use',
|
|
|
|
|
'os_install_disk_mount',
|
|
|
|
|
'os_install_disk_dev'],
|
|
|
|
|
where='os_install_disk_mount',
|
|
|
|
|
eq='swap')))
|
|
|
|
|
return "\n".join(("%s\tnone\tswap\tsw\t0 0" % self._commentFstab(x[0], "swap", x[2]) for x
|
|
|
|
|
in self.Select(['os_install_disk_use',
|
|
|
|
|
'os_install_disk_mount',
|
|
|
|
|
'os_install_disk_dev'],
|
|
|
|
|
where='os_install_disk_mount',
|
|
|
|
|
eq='swap')))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClInstallType(Variable):
|
|
|
|
|