Blob Blame History Raw
From 67a9b1477ef706b6b47fc5f37d864076b653c017 Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Fri, 3 Oct 2014 11:04:35 -0400
Subject: [PATCH 21/21] Graphically handle errors arising from ostree repo pull
 problems.

This requires setting up a new glib main context as well, so ostree doesn't
nuke the one we're currently using and make it impossible to do anything
with GTK.

Resolves: rhbz#1131382
---
 pyanaconda/packaging/rpmostreepayload.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
index aba85bb..8be6d3b 100644
--- a/pyanaconda/packaging/rpmostreepayload.py
+++ b/pyanaconda/packaging/rpmostreepayload.py
@@ -22,7 +22,9 @@
 
 import os
 import shutil
+import sys
 
+from pyanaconda import constants
 from pyanaconda import iutil
 from pyanaconda.i18n import _
 from pyanaconda.progress import progressQ
@@ -88,6 +90,9 @@ class RPMOSTreePayload(ArchivePayload):
             progressQ.send_message("Writing objects")
 
     def install(self):
+        mainctx = GLib.MainContext.new()
+        mainctx.push_thread_default()
+
         cancellable = None
         from gi.repository import OSTree
         ostreesetup = self.data.ostreesetup
@@ -120,7 +125,16 @@ class RPMOSTreePayload(ArchivePayload):
 
         progress = OSTree.AsyncProgress.new()
         progress.connect('changed', self._pullProgressCb)
-        repo.pull(ostreesetup.remote, [ostreesetup.ref], 0, progress, cancellable)
+
+        try:
+            repo.pull(ostreesetup.remote, [ostreesetup.ref], 0, progress, cancellable)
+        except GLib.GError as e:
+            exn = PayloadInstallError("Failed to pull from repository: %s" % e)
+            log.error(str(exn))
+            if errors.errorHandler.cb(exn) == errors.ERROR_RAISE:
+                progressQ.send_quit(1)
+                iutil.ipmi_report(constants.IPMI_ABORTED)
+                sys.exit(1)
 
         progressQ.send_message(_("Preparing deployment of %s") % (ostreesetup.ref, ))
 
@@ -164,6 +178,8 @@ class RPMOSTreePayload(ArchivePayload):
                 log.info("Copying bootloader data: " + fname)
                 shutil.copytree(srcpath, os.path.join(physboot, fname))
 
+        mainctx.pop_thread_default()
+
     def prepareMountTargets(self, storage):
         ostreesetup = self.data.ostreesetup
 
-- 
1.9.3