From 14c755b269e2539ba9e00585b2b50003d02d79ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Fri, 13 Oct 2017 14:40:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B0=20=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=B5=D0=BA=20=D0=BC=D0=BE=D0=BD=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F,=20=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BC=D0=B0=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * в таблице отображается второй root раздел --- pym/install/variables/autopartition.py | 13 ++- pym/install/variables/disk.py | 116 ++++++++++++++++++++----- 2 files changed, 104 insertions(+), 25 deletions(-) diff --git a/pym/install/variables/autopartition.py b/pym/install/variables/autopartition.py index 8c764af..bfab259 100644 --- a/pym/install/variables/autopartition.py +++ b/pym/install/variables/autopartition.py @@ -618,7 +618,7 @@ class DiskFilter(VariableInterface): factory = self.Get('cl_autopartition_factory') return [str(x) for x, mount in zip(getattr(factory, self.field), factory.disk_mount) - if mount] + if mount and not mount.startswith("/boot/efi")] class VariableClAutopartitionDiskDev(DiskFilter, ReadonlyVariable): """ @@ -681,6 +681,7 @@ class VariableClAutopartitionDiskDataFull(ReadonlyTableVariable): source = ['cl_autopartition_disk_dev_full', 'cl_autopartition_disk_mount_full', 'cl_autopartition_disk_format_full', + 'cl_autopartition_disk_perform_format_full', 'cl_autopartition_disk_size_full', 'cl_autopartition_disk_part_full', 'cl_autopartition_disk_type_full'] @@ -719,6 +720,16 @@ class VariableClAutopartitionDiskFormatFull(ReadonlyVariable): return var_factory.disk_format +class VariableClAutopartitionDiskPerformFormatFull(ReadonlyVariable): + """ + Autopartition disk filesystem + """ + type = "bool-list" + + def get(self): + return ["on" if mp else "off" + for mp in self.Get('cl_autopartition_disk_mount_full')] + class VariableClAutopartitionDiskPartFull(ReadonlyVariable): """ Autopartition partition type (primary,extended,logical,gpt) diff --git a/pym/install/variables/disk.py b/pym/install/variables/disk.py index f080513..4a1cf08 100644 --- a/pym/install/variables/disk.py +++ b/pym/install/variables/disk.py @@ -870,21 +870,77 @@ class VariableOsLocationBriefData(LocationHelper, TableVariable): def init(self): self.label = _("Layout") + def get_autopartition(self, hr=HumanReadable.No): + # при авторазметке получаем только информацию о + # /boot/efi разделах + if self.GetBool('cl_autopartition_uefi_set'): + boot = [[dev, mp, fs, _format, size] + for dev, mp, fs, _format, size in self.ZipVars( + 'os_install_disk_dev', + 'os_install_disk_mount', + 'os_install_disk_format', + 'os_install_disk_perform_format', + 'os_install_disk_size', humanreadable=hr) + if mp.startswith('/boot/efi')] + else: + boot = [] + # исключаем из устройств авторазметки информацию о efi разделах + # так как она не достоверная + devices = [[dev, mp, fs, _format, size] + for dev, mp, fs, _format, size in self.ZipVars( + 'cl_autopartition_disk_dev_full', + 'cl_autopartition_disk_mount_full', + 'cl_autopartition_disk_format_full', + 'cl_autopartition_disk_perform_format_full', + 'cl_autopartition_disk_size_full', + humanreadable=hr) + if not mp.startswith('/boot/efi') + ] + binds = [[dev, mp, "", "", ""] + for dev, mp in self.ZipVars( + 'cl_autopartition_bind_path', + 'cl_autopartition_bind_mountpoint', humanreadable=hr)] + autodevs = self.Get('cl_autopartition_disk_dev_full') + bootdevs = [x[0] for x in boot] + + def keysort(dev): + if dev in autodevs: + return autodevs.index(dev), -1 + else: + return -1, bootdevs.index(dev) + + return sorted(boot + devices, + key=lambda x: keysort(x[0])) + binds or [[]] + + def get_manual(self, hr=HumanReadable.No): + devs = self.Get('os_disk_dev') + + def keysort(dev): + if dev in devs: + return devs.index(dev), -1 + else: + return -1, dev + + devices = map(list, self.ZipVars( + 'os_install_disk_dev', + 'os_install_disk_mount', + 'os_install_disk_format', + 'os_install_disk_perform_format', + 'os_install_disk_size', + humanreadable=hr)) + + binds = [[dev, mp, "", "", ""] + for dev, mp in self.ZipVars( + 'os_install_bind_path', + 'os_install_bind_mountpoint', humanreadable=hr)] + return sorted(devices, + key=lambda x: keysort(x[0])) + binds or [[]] + def get(self, hr=HumanReadable.No): - for varname, value in ifilter(lambda x: type(x[1]) != list, - imap(lambda x: (x, self.Get(x)), - ifilter(None, - chain(*self.orig_source)))): - raise VariableError( - _("Source variable %s does not contain a list") % varname) - return list( - chain(* - map(lambda k: map(list, - izip_longest( - *map(lambda x: self.Get(x, - humanreadable=hr) if x else '', - k), fillvalue='')), - self.orig_source))) or [[]] + if self.GetBool('cl_autopartition_set'): + return self.get_autopartition(hr) + else: + return self.get_manual(hr) class VariableOsLocationData(LocationHelper, TableVariable): @@ -1772,9 +1828,9 @@ class VariableOsInstallDiskSize(SourceReadonlyVariable): return { dev: size for dev, size in chain( self.ZipVars('os_disk_dev', 'os_disk_size'), + self.ZipVars('os_location_source', 'os_location_size'), self.ZipVars('cl_autopartition_disk_dev_full', - 'cl_autopartition_disk_size_full'), - self.ZipVars('os_location_source', 'os_location_size')) + 'cl_autopartition_disk_size_full')) } else: return { @@ -1784,14 +1840,26 @@ class VariableOsInstallDiskSize(SourceReadonlyVariable): } def getMapHumanReadable(self): - return { - device.udev.get_devname(name=dev): size - for dev, size in chain( - zip(self.Get('os_disk_dev'), - self.Get('os_disk_size', humanreadable=True)), - zip(self.Get('os_location_source'), - self.Get('os_location_size', humanreadable=True))) - } + if self.GetBool("cl_autopartition_set"): + return { + dev: size for dev, size in chain( + self.ZipVars('os_disk_dev', 'os_disk_size', + humanreadable=True), + self.ZipVars('os_location_source', 'os_location_size', + humanreadable=True), + self.ZipVars('cl_autopartition_disk_dev_full', + 'cl_autopartition_disk_size_full', + humanreadable=True)) + } + else: + return { + device.udev.get_devname(name=dev): size + for dev, size in chain( + zip(self.Get('os_disk_dev'), + self.Get('os_disk_size', humanreadable=True)), + zip(self.Get('os_location_source'), + self.Get('os_location_size', humanreadable=True))) + } class VariableOsInstallDiskType(SourceReadonlyVariable):