Blame SOURCES/0001.patch

d91bcd
From f5e4b38043ce566da472853d48382c5c1f7871f2 Mon Sep 17 00:00:00 2001
d91bcd
From: Brent Baude <bbaude@redhat.com>
d91bcd
Date: Mon, 22 May 2017 13:41:55 -0500
d91bcd
Subject: [PATCH] Atomic/util.py: Add logic to install lookup for shortnames
d91bcd
d91bcd
If a shortname is used to run an image, we need to transform the short
d91bcd
name into the fq-name when doing the lookup in the installed images
d91bcd
data.
d91bcd
d91bcd
Reported in BZ #1454292
d91bcd
---
d91bcd
 Atomic/backends/_docker.py |  9 +++++++--
d91bcd
 Atomic/util.py             | 13 +++++++++++--
d91bcd
 2 files changed, 18 insertions(+), 4 deletions(-)
d91bcd
d91bcd
diff --git a/Atomic/backends/_docker.py b/Atomic/backends/_docker.py
d91bcd
index 53a67adc..04659eed 100644
d91bcd
--- a/Atomic/backends/_docker.py
d91bcd
+++ b/Atomic/backends/_docker.py
d91bcd
@@ -467,10 +467,15 @@ def uninstall(self, iobject, name=None, **kwargs):
d91bcd
         atomic.display(cmd)
d91bcd
         if args.display:
d91bcd
             return 0
d91bcd
-        if cmd:
d91bcd
-            return util.check_call(cmd, env=atomic.cmd_env())
d91bcd
 
d91bcd
         install_data = util.InstallData.get_install_data_by_id(iobject.id)
d91bcd
+
d91bcd
+        if cmd:
d91bcd
+            result = util.check_call(cmd, env=atomic.cmd_env())
d91bcd
+            if result == 0:
d91bcd
+                util.InstallData.delete_by_id(iobject.id, ignore=ignore)
d91bcd
+            return result
d91bcd
+
d91bcd
         system_package_nvra = install_data.get("system_package_nvra", None)
d91bcd
         if system_package_nvra:
d91bcd
             RPMHostInstall.uninstall_rpm(system_package_nvra)
d91bcd
diff --git a/Atomic/util.py b/Atomic/util.py
d91bcd
index f6116bb8..5f6590f8 100644
d91bcd
--- a/Atomic/util.py
d91bcd
+++ b/Atomic/util.py
d91bcd
@@ -857,8 +857,11 @@ def read_install_data(cls):
d91bcd
     def write_install_data(cls, new_data):
d91bcd
         install_data = cls.read_install_data()
d91bcd
         with file_lock(ATOMIC_INSTALL_JSON):
d91bcd
-            for x in new_data:
d91bcd
-                install_data[x] = new_data[x]
d91bcd
+            if len(new_data) < 1:
d91bcd
+                install_data = {}
d91bcd
+            else:
d91bcd
+                for x in new_data:
d91bcd
+                    install_data[x] = new_data[x]
d91bcd
             temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False)
d91bcd
             json.dump(install_data, temp_file)
d91bcd
             temp_file.close()
d91bcd
@@ -908,6 +911,12 @@ def image_installed(cls, img_object):
d91bcd
             return True
d91bcd
         if install_data.get("{}:{}".format(img_object.input_name, img_object.tag), None):
d91bcd
             return True
d91bcd
+        try:
d91bcd
+            from Atomic.discovery import RegistryInspectError
d91bcd
+            if install_data.get(img_object.fq_name, None):
d91bcd
+                return True
d91bcd
+        except RegistryInspectError:
d91bcd
+            pass
d91bcd
         return False
d91bcd
 
d91bcd
 class Decompose(object):