Kaydet (Commit) 4a542b49 authored tarafından Clement Lefebvre's avatar Clement Lefebvre

Add support for LUKS and LVM in the UI

Support in the actual installer will follow in another commit.
üst 6c5bdc58
......@@ -629,6 +629,13 @@ class Setup(object):
real_name = None
grub_device = None
disks = []
automated = True
disk = None
diskname = None
passphrase1 = None
passphrase2 = None
lvm = False
luks = False
target_disk = None
gptonefi = False
# Optionally skip all mouting/partitioning for advanced users with custom setups (raid/dmcrypt/etc)
......@@ -658,6 +665,12 @@ class Setup(object):
print "passwords: %s - %s" % (self.password1, self.password2)
print "grub_device: %s " % self.grub_device
print "skip_mount: %s" % self.skip_mount
print "automated: %s" % self.automated
if self.automated:
print "disk: %s (%s)" % (self.disk, self.diskname)
print "luks: %s" % self.luks
print "lvm: %s" % self.lvm
print "passphrase: %s - %s" % (self.passphrase1, self.passphrase2)
if (not self.skip_mount):
print "target_disk: %s " % self.target_disk
if self.gptonefi:
......
......@@ -57,6 +57,41 @@ with open(RESOURCE_DIR + 'disk-partitions.html') as f:
DISK_TEMPLATE = re.sub('<style>[\s\S]+?</style>', lambda match: match.group().replace('{', '{{').replace('}', '}}'), DISK_TEMPLATE)
def get_disks():
disks = []
exclude_devices = ['/dev/sr0', '/dev/sr1', '/dev/cdrom', '/dev/dvd', '/dev/fd0']
live_device = commands.getoutput("findmnt -n -o source /run/live/medium").split('\n')[0]
live_device = re.sub('[0-9]+$', '', live_device) # remove partition numbers if any
if live_device is not None and live_device.startswith('/dev/'):
exclude_devices.append(live_device)
print "Excluding %s (detected as the live device)" % live_device
lsblk = shell_exec('LC_ALL=en_US.UTF-8 lsblk -rindo TYPE,NAME,RM,SIZE,MODEL | sort -k3,2')
for line in lsblk.stdout:
try:
elements = line.strip().split(" ", 4)
if len(elements) < 4:
print "Can't parse blkid output: %s" % elements
continue
elif len(elements) < 5:
print "Can't find model in blkid output: %s" % elements
type, device, removable, size, model = elements[0], elements[1], elements[2], elements[3], elements[1]
else:
type, device, removable, size, model = elements
device = "/dev/" + device
if type == "disk" and device not in exclude_devices:
# convert size to manufacturer's size for show, e.g. in GB, not GiB!
unit_index = 'BKMGTPEZY'.index(size.upper()[-1])
l10n_unit = [_('B'), _('kB'), _('MB'), _('GB'), _('TB'), 'PB', 'EB', 'ZB', 'YB'][unit_index]
size = "%s %s" % (str(int(float(size[:-1]) * (1024/1000)**unit_index)), l10n_unit)
model = model.replace("\\x20", " ")
description = '{} ({})'.format(model.strip(), size)
if int(removable):
description = _('Removable:') + ' ' + description
disks.append((device, description))
except Exception, detail:
print "Could not parse blkid output: %s (%s)" % (line, detail)
return disks
def build_partitions(_installer):
global installer
installer = _installer
......@@ -185,44 +220,9 @@ class PartitionSetup(Gtk.TreeStore):
installer.setup.partition_setup = self
self.html_disks, self.html_chunks = {}, defaultdict(list)
def _get_attached_disks():
disks = []
exclude_devices = ['/dev/sr0', '/dev/sr1', '/dev/cdrom', '/dev/dvd', '/dev/fd0']
live_device = commands.getoutput("findmnt -n -o source /run/live/medium").split('\n')[0]
live_device = re.sub('[0-9]+$', '', live_device) # remove partition numbers if any
if live_device is not None and live_device.startswith('/dev/'):
exclude_devices.append(live_device)
print "Excluding %s (detected as the live device)" % live_device
lsblk = shell_exec('LC_ALL=en_US.UTF-8 lsblk -rindo TYPE,NAME,RM,SIZE,MODEL | sort -k3,2')
for line in lsblk.stdout:
try:
elements = line.strip().split(" ", 4)
if len(elements) < 4:
print "Can't parse blkid output: %s" % elements
continue
elif len(elements) < 5:
print "Can't find model in blkid output: %s" % elements
type, device, removable, size, model = elements[0], elements[1], elements[2], elements[3], elements[1]
else:
type, device, removable, size, model = elements
device = "/dev/" + device
if type == "disk" and device not in exclude_devices:
# convert size to manufacturer's size for show, e.g. in GB, not GiB!
unit_index = 'BKMGTPEZY'.index(size.upper()[-1])
l10n_unit = [_('B'), _('kB'), _('MB'), _('GB'), _('TB'), 'PB', 'EB', 'ZB', 'YB'][unit_index]
size = "%s %s" % (str(int(float(size[:-1]) * (1024/1000)**unit_index)), l10n_unit)
model = model.replace("\\x20", " ")
description = '{} ({})'.format(model.strip(), size)
if int(removable):
description = _('Removable:') + ' ' + description
disks.append((device, description))
except Exception, detail:
print "Could not parse blkid output: %s (%s)" % (line, detail)
return disks
os.popen('mkdir -p ' + TMP_MOUNTPOINT)
installer.setup.gptonefi = is_efi_supported()
self.disks = _get_attached_disks()
self.disks = get_disks()
print 'Disks: ', self.disks
already_done_full_disk_format = False
for disk_path, disk_description in self.disks:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment