|
|
8fd212 |
From 62af1d7f96b8ed8eb8f2732787576161ae5da79f Mon Sep 17 00:00:00 2001
|
|
|
8fd212 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
8fd212 |
Date: Thu, 13 Oct 2022 10:47:52 +0200
|
|
|
8fd212 |
Subject: [PATCH] Revert "Remove the Blivet.roots attribute"
|
|
|
8fd212 |
|
|
|
8fd212 |
This reverts commit 19a826073345ca6b57a8f9a95ec855892320300e.
|
|
|
8fd212 |
---
|
|
|
8fd212 |
blivet/blivet.py | 21 +++++++++++++++++++++
|
|
|
8fd212 |
blivet/devicefactory.py | 3 +++
|
|
|
8fd212 |
2 files changed, 24 insertions(+)
|
|
|
8fd212 |
|
|
|
8fd212 |
diff --git a/blivet/blivet.py b/blivet/blivet.py
|
|
|
8fd212 |
index bf72ee9c..dc066b03 100644
|
|
|
8fd212 |
--- a/blivet/blivet.py
|
|
|
8fd212 |
+++ b/blivet/blivet.py
|
|
|
8fd212 |
@@ -88,6 +88,7 @@ class Blivet(object):
|
|
|
8fd212 |
self.devicetree = DeviceTree(ignored_disks=self.ignored_disks,
|
|
|
8fd212 |
exclusive_disks=self.exclusive_disks,
|
|
|
8fd212 |
disk_images=self.disk_images)
|
|
|
8fd212 |
+ self.roots = []
|
|
|
8fd212 |
|
|
|
8fd212 |
@property
|
|
|
8fd212 |
def short_product_name(self):
|
|
|
8fd212 |
@@ -1314,5 +1315,25 @@ class Blivet(object):
|
|
|
8fd212 |
p = partition.disk.format.parted_disk.getPartitionByPath(partition.path)
|
|
|
8fd212 |
partition.parted_partition = p
|
|
|
8fd212 |
|
|
|
8fd212 |
+ for root in new.roots:
|
|
|
8fd212 |
+ root.swaps = [new.devicetree.get_device_by_id(d.id, hidden=True) for d in root.swaps]
|
|
|
8fd212 |
+ root.swaps = [s for s in root.swaps if s]
|
|
|
8fd212 |
+
|
|
|
8fd212 |
+ removed = set()
|
|
|
8fd212 |
+ for (mountpoint, old_dev) in root.mounts.items():
|
|
|
8fd212 |
+ if old_dev is None:
|
|
|
8fd212 |
+ continue
|
|
|
8fd212 |
+
|
|
|
8fd212 |
+ new_dev = new.devicetree.get_device_by_id(old_dev.id, hidden=True)
|
|
|
8fd212 |
+ if new_dev is None:
|
|
|
8fd212 |
+ # if the device has been removed don't include this
|
|
|
8fd212 |
+ # mountpoint at all
|
|
|
8fd212 |
+ removed.add(mountpoint)
|
|
|
8fd212 |
+ else:
|
|
|
8fd212 |
+ root.mounts[mountpoint] = new_dev
|
|
|
8fd212 |
+
|
|
|
8fd212 |
+ for mnt in removed:
|
|
|
8fd212 |
+ del root.mounts[mnt]
|
|
|
8fd212 |
+
|
|
|
8fd212 |
log.debug("finished Blivet copy")
|
|
|
8fd212 |
return new
|
|
|
8fd212 |
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
|
|
|
8fd212 |
index 8105bfc7..6f460f6d 100644
|
|
|
8fd212 |
--- a/blivet/devicefactory.py
|
|
|
8fd212 |
+++ b/blivet/devicefactory.py
|
|
|
8fd212 |
@@ -383,6 +383,7 @@ class DeviceFactory(object):
|
|
|
8fd212 |
# used for error recovery
|
|
|
8fd212 |
self.__devices = []
|
|
|
8fd212 |
self.__actions = []
|
|
|
8fd212 |
+ self.__roots = []
|
|
|
8fd212 |
|
|
|
8fd212 |
def _is_container_encrypted(self):
|
|
|
8fd212 |
return all(isinstance(p, LUKSDevice) for p in self.device.container.parents)
|
|
|
8fd212 |
@@ -994,10 +995,12 @@ class DeviceFactory(object):
|
|
|
8fd212 |
_blivet_copy = self.storage.copy()
|
|
|
8fd212 |
self.__devices = _blivet_copy.devicetree._devices
|
|
|
8fd212 |
self.__actions = _blivet_copy.devicetree._actions
|
|
|
8fd212 |
+ self.__roots = _blivet_copy.roots
|
|
|
8fd212 |
|
|
|
8fd212 |
def _revert_devicetree(self):
|
|
|
8fd212 |
self.storage.devicetree._devices = self.__devices
|
|
|
8fd212 |
self.storage.devicetree._actions = self.__actions
|
|
|
8fd212 |
+ self.storage.roots = self.__roots
|
|
|
8fd212 |
|
|
|
8fd212 |
|
|
|
8fd212 |
class PartitionFactory(DeviceFactory):
|
|
|
8fd212 |
--
|
|
|
8fd212 |
2.38.1
|
|
|
8fd212 |
|