File virtinst-use-latest-opensuse-version-when-unknown-media.patch of Package virt-manager.7890

References: bsc#1085757

When a version openSUSE is under development, the lookup fails to
detect the version of openSUSE ISO media (it changes with every build).
When 'opensuse-unknown' is detected, look up the most current version
of openSUSE and default to that. This is the same way fedora does it.

Index: virt-manager-1.5.0/virtinst/osdict.py
===================================================================
--- virt-manager-1.5.0.orig/virtinst/osdict.py
+++ virt-manager-1.5.0/virtinst/osdict.py
@@ -241,6 +241,12 @@ class _OSDB(object):
                 "Converting that to the latest fedora OS version=%s",
                 location, osname)
 
+        if osname == "opensuse-unknown":
+            osname = self.latest_opensuse_version()
+            logging.debug("Detected location=%s as os=opensuse-unknown. "
+                "Converting that to the latest opensuse OS version=%s",
+                location, osname)
+
         return osname
 
     def list_types(self):
@@ -275,6 +281,16 @@ class _OSDB(object):
                 # First fedora* occurrence should be the newest
                 return osinfo.name
 
+    def latest_opensuse_version(self):
+        os_info = None
+        for osinfo in self.list_os():
+            if (osinfo.name.startswith("opensuse") and
+                "unknown" not in osinfo.name and
+                "tumbleweed" not in osinfo.name and
+                "factory" not in osinfo.name and
+                "42" not in osinfo.name):
+                # openSUSE Leap 42 is not the latest anymore
+                return osinfo.name
 
 #####################
 # OsVariant classes #
openSUSE Build Service is sponsored by