Commit e982d31b authored by intrigeri's avatar intrigeri

Import bugfix/15590-14849-14720-14810-installer-fixes-for-3.9 (at commit...

Import bugfix/15590-14849-14720-14810-installer-fixes-for-3.9 (at commit d9b8247f) as a quilt patch (Closes: Tails#15590, Tails#14849, Tails#14720, Tails#14810)
parent f63c292c
From: kurono <andres.gomez@cern.ch>
Date: Wed, 20 Jun 2018 18:51:47 +0200
Subject: bugfix/15590-14849-14720-14810-installer-fixes-for-3.9
---
data/tails-installer.ui | 2 +-
tails_installer/creator.py | 33 +++++++++++++++++++++------------
tails_installer/gui.py | 31 ++++++++++++++++---------------
4 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/data/tails-installer.ui b/data/tails-installer.ui
index e4c5468..62900da 100644
--- a/data/tails-installer.ui
+++ b/data/tails-installer.ui
@@ -346,7 +346,7 @@
<property name="margin_right">18</property>
<property name="margin_bottom">6</property>
<property name="shadow_type">in</property>
- <property name="min_content_height">200</property>
+ <property name="min_content_height">130</property>
<child>
<object class="GtkTextView" id="textview_log">
<property name="visible">True</property>
diff --git a/tails_installer/creator.py b/tails_installer/creator.py
index 2a949ae..3cf054f 100755
--- a/tails_installer/creator.py
+++ b/tails_installer/creator.py
@@ -88,7 +88,6 @@ class TailsInstallerCreator(object):
log = None
ext_fstypes = set(['ext2', 'ext3', 'ext4'])
valid_fstypes = set(['vfat', 'msdos']) | ext_fstypes
- force_reinstall = False
drive = property(fget=lambda self: self.drives[self._drive],
fset=lambda self, d: self._set_drive(d))
@@ -605,10 +604,12 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
'parent': None,
'parent_udi': None,
'parent_size': None,
+ 'parent_data': None,
'size': block.props.size,
'mounted_partitions': set(),
'is_device_big_enough_for_installation': True,
'is_device_big_enough_for_upgrade': True,
+ 'is_device_big_enough_for_reinstall': True,
'removable': drive.props.removable,
}
@@ -655,12 +656,16 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
if not self.is_device_big_enough_for_installation(
data['parent_size']
if data['parent_size']
- else data['size']) \
- and not self.device_can_be_upgraded(data):
- self.log.warning(
- 'Device is too small for installation: %s'
- % data['device'])
- data['is_device_big_enough_for_installation'] = False
+ else data['size']):
+ if not self.device_can_be_upgraded(data):
+ self.log.warning(
+ 'Device is too small for installation: %s'
+ % data['device'])
+ data['is_device_big_enough_for_installation'] = False
+ # Since reinstalling is a special case where full overitting
+ # is done, the size of the device has to be bigger than
+ # min_installation_device_size in all cases.
+ data['is_device_big_enough_for_reinstall'] = False
# To be more accurate we would need to either mount the candidate
# device (which causes UX problems down the road) or to recursively
@@ -714,11 +719,15 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
continue
self.drives[data['device']] = data
- # Remove parent drives if a valid partition exists
- if not self.force_reinstall:
- for parent in [d['parent'] for d in self.drives.values()]:
- if parent in self.drives:
- del(self.drives[parent])
+ # Remove parent drives if a valid partition exists.
+ # This is always made to avoid listing both the devices
+ # and their parents in the gui dropdown list.
+ # But we keep the parent data in case of a reinstallation.
+ for d in self.drives.values():
+ if d['parent'] is not None and d['parent'] in self.drives:
+ self.drives[d['device']]['parent_data']\
+ = self.drives[d['parent']].copy()
+ del(self.drives[d['parent']])
self.log.debug(pformat(mounted_parts))
diff --git a/tails_installer/gui.py b/tails_installer/gui.py
index 7fb6a10..7cec7dc 100755
--- a/tails_installer/gui.py
+++ b/tails_installer/gui.py
@@ -193,13 +193,15 @@ class TailsInstallerThread(threading.Thread):
if not self.live.can_read_partition_table():
self.live.log.info('Clearing unreadable partition table.')
self.live.clear_all_partition_tables()
- if self.parent.force_reinstall:
- parent = _to_unicode(self.live.drive['parent'])
- self.rescan_devices(force_partitions=False)
- if parent in self.live.drives and \
- 'device' in self.live.drives[parent]:
- self.live.drive = self.live.drives[parent]['device']
- self.live.save_full_drive()
+ # If there is a partition already in place and we need
+ # to reinstall, then we need to change the selected
+ # device for its saved parent, if it exists
+ if self.parent.force_reinstall and \
+ self.live.drive['parent_data'] is not None:
+ parent_data = self.live.drive['parent_data']
+ self.live.drives[parent_data['device']] = parent_data
+ self.live.drive = parent_data['device']
+ self.live.save_full_drive()
self.live.partition_device()
self.rescan_devices(force_partitions=True)
self.live.switch_drive_to_system_partition()
@@ -445,7 +447,6 @@ class TailsInstallerWindow(Gtk.ApplicationWindow):
return
self.force_reinstall = True
self.opts.partition = True
- self.live.force_reinstall = True
self.__button_force_reinstall.set_visible(False)
self.on_start_clicked(button)
@@ -454,7 +455,6 @@ class TailsInstallerWindow(Gtk.ApplicationWindow):
def on_target_changed(self, combobox_target):
# get selected device
- self.__button_force_reinstall.set_visible(False)
drive = self.get_selected_drive()
if drive == None:
return
@@ -463,13 +463,14 @@ class TailsInstallerWindow(Gtk.ApplicationWindow):
if self.live.device_can_be_upgraded(device):
self.opts.partition = False
self.force_reinstall = False
- self.live.force_reinstall = False
self.__button_start.set_label(_('Upgrade'))
- self.__button_force_reinstall.set_visible(True)
+ if device['is_device_big_enough_for_reinstall']:
+ self.__button_force_reinstall.set_visible(True)
+ else:
+ self.__button_force_reinstall.set_visible(False)
else:
self.opts.partition = True
self.force_reinstall = True
- self.live.force_reinstall = False
self.__button_start.set_label(_('Install'))
self.__button_force_reinstall.set_visible(False)
@@ -520,8 +521,6 @@ class TailsInstallerWindow(Gtk.ApplicationWindow):
def update_start_button(self):
if self.source_available and self.target_available:
self.__button_start.set_sensitive(True)
- if not self.opts.partition:
- self.__button_force_reinstall.set_visible(True)
else:
self.__button_start.set_sensitive(False)
@@ -746,7 +745,9 @@ class TailsInstallerWindow(Gtk.ApplicationWindow):
{'vendor': self.live.drive['vendor'],
'model': self.live.drive['model'],
'device': self.live.drive['device'],
- 'size': _format_bytes_in_gb(self.live.drive['size'])
+ 'size': _format_bytes_in_gb(self.live.drive['parent_size']
+ if self.live.drive['parent_size']
+ else self.live.drive['size'])
},
False):
self.confirmed = True
0001-bugfix-15590-14849-14720-14810-installer-fixes-for-3.patch
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