From: Adam Williamson <awilliam(a)redhat.com>
This is one potential approach to help with #1183880 . It
changes the deleteAll behaviour as follows:
* Partitions known to be shared with other OSes won't be deleted
* Boot partitions won't be deleted if there are unknown parts
You can delete these partitions only by specifically targeting
them. It also adds a variant of the ConfirmDeleteDialog for
boot partitions, with text specifically explaining that they
might be needed for other OSes to boot.
---
pyanaconda/ui/gui/spokes/custom.py | 31 ++++++++++++++++++----
.../ui/gui/spokes/lib/custom_storage_helpers.py | 8 +++---
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index ce1d475..0046160 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -69,6 +69,7 @@
from blivet.errors import NotEnoughFreeSpaceError
from blivet.devicelibs import raid, crypto
from blivet.devices import LUKSDevice
+from blivet.platform import platform
from pyanaconda.storage_utils import ui_storage_logger, device_type_from_autopart
from pyanaconda.storage_utils import DEVICE_TEXT_PARTITION, DEVICE_TEXT_MAP,
DEVICE_TEXT_MD
@@ -1952,9 +1953,12 @@ def on_remove_clicked(self, button):
# on it. Thus, we first need to confirm with the user and then
# schedule actions to delete the thing.
dialog = ConfirmDeleteDialog(self.data)
+ protected = platform.bootStage1ConstraintDict["format_types"]
+ bootpart = device.format.type in protected
snapshots = (device.direct and not device.isleaf)
dialog.refresh(getattr(device.format, "mountpoint", ""),
- device.name, root_name, snapshots=snapshots)
+ device.name, root_name, snapshots=snapshots,
+ bootpart=bootpart)
with self.main_window.enlightbox(dialog.window):
rc = dialog.run()
@@ -1963,16 +1967,33 @@ def on_remove_clicked(self, button):
return
if dialog.deleteAll:
- for dev in (s._device for s in page.members):
- self._destroy_device(dev)
- else:
- self._destroy_device(device)
+ otherpgs = (pg for pg in self._accordion.allPages if
+ pg.pageTitle != page.pageTitle)
+ otherdevs = []
+ for otherpg in otherpgs:
+ otherdevs.extend([mem._device.id for mem in otherpg.members])
+ # we never want to delete known-shared devs here. we also
+ # exclude 'device' as we'll unconditionally delete it later
+ for dev in (s._device for s in page.members if
+ s._device.id not in otherdevs and
+ s._device.id != device.id):
+ # we only want to delete boot partitions if they're not
+ # shared *and* we have no unknown partitions
+ if (not self.unusedDevices or dev.format.type not in protected):
+ log.info("deleteall: removed %s", dev.name)
+ self._destroy_device(dev)
+ else:
+ log.info("deleteall: didn't remove %s", dev.name)
+
+ # We do this even in deleteAll case, see above comment
+ self._destroy_device(device)
log.info("ui: removed device %s", device.name)
# Now that devices have been removed from the installation root,
# refreshing the display will have the effect of making them disappear.
# It's like they never existed.
+ self._storage_playground.roots =
findExistingInstallations(self._storage_playground.devicetree)
self._updateSpaceDisplay()
self._do_refresh()
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index 8f3b6d6..cbb4523 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -377,7 +377,7 @@ def on_delete_confirm_clicked(self, button, *args):
self.window.destroy()
# pylint: disable=arguments-differ
- def refresh(self, mountpoint, device, rootName, snapshots=False):
+ def refresh(self, mountpoint, device, rootName, snapshots=False, bootpart=False):
GUIObject.refresh(self)
label = self.builder.get_object("confirmLabel")
@@ -385,7 +385,7 @@ def refresh(self, mountpoint, device, rootName, snapshots=False):
rootName = rootName.replace("_", "__")
self._removeAll.set_label(
C_("GUI|Custom Partitioning|Confirm Delete Dialog",
- "Delete _all other file systems in the %s root as well.")
+ "Delete _all other file systems which are only used by %s as
well.")
% rootName)
self._removeAll.set_sensitive(rootName is not None)
@@ -394,7 +394,9 @@ def refresh(self, mountpoint, device, rootName, snapshots=False):
else:
txt = device
- if not snapshots:
+ if bootpart:
+ label_text = _("%s may be a system boot partition! Deleting it may break
other operating systems. Are you sure you want to delete it?") % txt
+ elif not snapshots:
label_text = _("Are you sure you want to delete all of the data on
%s?") % txt
else:
label_text = _("Are you sure you want to delete all of the data on %s,
including snapshots and/or subvolumes?") % txt
--
To view this commit on github, visit
https://github.com/rhinstaller/anaconda/commit/80a8455130751f41a9611c57d3...