dpolovinkin / rpms / anaconda

Forked from rpms/anaconda 3 years ago
Clone

Blame SOURCES/0032-rescue-find-root-partition-of-ostree-atomic-installa.patch

fbcaed
From 2fe1fea904f40256387dea56405a369c22354e2c Mon Sep 17 00:00:00 2001
fbcaed
From: Radek Vykydal <rvykydal@redhat.com>
fbcaed
Date: Tue, 9 Dec 2014 11:01:18 +0100
fbcaed
Subject: [PATCH 32/32] rescue: find root partition of ostree (atomic)
fbcaed
 installations (#1152041)
fbcaed
fbcaed
---
fbcaed
 pyanaconda/rescue.py | 37 +++++++++++++++++++++++++++++++++++++
fbcaed
 1 file changed, 37 insertions(+)
fbcaed
fbcaed
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
fbcaed
index e0c4e13..fbf3f06 100644
fbcaed
--- a/pyanaconda/rescue.py
fbcaed
+++ b/pyanaconda/rescue.py
fbcaed
@@ -264,6 +264,42 @@ def _unlock_devices(intf, storage):
fbcaed
                         device.format.passphrase = None
fbcaed
                         try_passphrase = None
fbcaed
 
fbcaed
+def findExistingOstreePartitions(devicetree):
fbcaed
+    import blivet
fbcaed
+    if not os.path.exists(blivet.getTargetPhysicalRoot()):
fbcaed
+        util.makedirs(blivet.getTargetPhysicalRoot())
fbcaed
+
fbcaed
+    roots = []
fbcaed
+    for device in devicetree.leaves:
fbcaed
+        if not device.format.linuxNative or not device.format.mountable or \
fbcaed
+           not device.controllable:
fbcaed
+            continue
fbcaed
+
fbcaed
+        try:
fbcaed
+            device.setup()
fbcaed
+        except Exception: # pylint: disable=broad-except
fbcaed
+            log.warning("setup of %s failed", [device.name])
fbcaed
+            continue
fbcaed
+
fbcaed
+        options = device.format.options + ",ro"
fbcaed
+        try:
fbcaed
+            device.format.mount(options=options, mountpoint=iutil.getSysroot())
fbcaed
+        except Exception: # pylint: disable=broad-except
fbcaed
+            log.warning("mount of %s as %s failed", device.name, device.format.type)
fbcaed
+            device.teardown()
fbcaed
+            continue
fbcaed
+
fbcaed
+        if not os.access(iutil.getSysroot() + "/ostree", os.R_OK):
fbcaed
+            device.teardown(recursive=True)
fbcaed
+            continue
fbcaed
+
fbcaed
+        name = _("Ostree on %s") % device.name
fbcaed
+        roots.append(blivet.Root(mounts=None, swaps=None, name=device.name))
fbcaed
+
fbcaed
+    return roots
fbcaed
+
fbcaed
+
fbcaed
+
fbcaed
 def doRescue(intf, rescue_mount, ksdata):
fbcaed
     import blivet
fbcaed
 
fbcaed
@@ -323,6 +359,7 @@ def doRescue(intf, rescue_mount, ksdata):
fbcaed
     blivet.storageInitialize(sto, ksdata, [])
fbcaed
     _unlock_devices(intf, sto)
fbcaed
     roots = blivet.findExistingInstallations(sto.devicetree)
fbcaed
+    roots.extend(findExistingOstreePartitions(sto.devicetree))
fbcaed
 
fbcaed
     if not roots:
fbcaed
         root = None
fbcaed
-- 
fbcaed
1.9.3
fbcaed