[fedora-virt-maint] rpms/python-virtinst/F-10 virtinst-0.400.3-safe-os-detect.patch, NONE, 1.1 python-virtinst.spec, 1.56, 1.57

Cole Robinson crobinso at fedoraproject.org
Thu Oct 22 13:38:01 UTC 2009


Author: crobinso

Update of /cvs/pkgs/rpms/python-virtinst/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv7329

Modified Files:
	python-virtinst.spec 
Added Files:
	virtinst-0.400.3-safe-os-detect.patch 
Log Message:
Ensure unknown OS detection doesn't break the install


virtinst-0.400.3-safe-os-detect.patch:
 OSDistro.py |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

--- NEW FILE virtinst-0.400.3-safe-os-detect.patch ---
# HG changeset patch
# User Cole Robinson <crobinso at redhat.com>
# Date 1241726968 14400
# Node ID db997572bdc8a8fc4c567fbf165f853167dfa462
# Parent  9768e52d4d624f83853f7f23f85402c8a078eb6f
Make sure autodetected OS type/variant are in the osdict.

If not, log a message and set the values to None, rather than barf later
down the line.

diff -r 9768e52d4d62 -r db997572bdc8 virtinst/OSDistro.py
--- a/virtinst/OSDistro.py	Thu May 07 15:50:06 2009 -0400
+++ b/virtinst/OSDistro.py	Thu May 07 16:09:28 2009 -0400
@@ -28,6 +28,7 @@
 import ConfigParser
 
 import virtinst
+from virtinst.Guest import Guest
 from virtinst import _util
 from virtinst import _virtinst as _
 
@@ -118,8 +119,9 @@
         if iskernel is True:
             # FIXME: We should probably do this for both kernel and boot
             # disk?
+            os_type, os_variant = store.get_osdict_info()
             return (store.acquireKernel(guest, fetcher, progresscb),
-                    store.os_type, store.os_variant)
+                    os_type, os_variant)
         elif iskernel is False:
             return store.acquireBootDisk(fetcher, progresscb)
         else:
@@ -145,7 +147,7 @@
     import urlgrabber
     progress = urlgrabber.progress.BaseMeter()
     store = _acquireMedia(None, None, location, progress, arch, "/var/tmp")
-    return (store.os_type, store.os_variant)
+    return store.get_osdict_info()
 
 
 def distroFromTreeinfo(fetcher, progresscb, uri, arch, vmtype=None,
@@ -246,6 +248,28 @@
             raise RuntimeError(_("Could not find boot.iso in %s tree." % \
                                self.name))
 
+    def get_osdict_info(self):
+        """
+        Return (distro, variant) tuple, checking to make sure they are valid
+        osdict entries
+        """
+        if not self.os_type:
+            return (None, None)
+
+        if self.os_type not in Guest.list_os_types():
+            logging.debug("%s set os_type to %s, which is not in osdict." %
+                          (self, self.os_type))
+            return (None, None)
+
+        if (self.os_variant and
+            self.os_variant not in Guest.list_os_variants(self.os_type)):
+            logging.debug("%s set os_variant to %s, which is not in osdict"
+                          " for distro %s." %
+                          (self, self.os_variant, self.os_type))
+            return (self.os_type, None)
+
+        return (self.os_type, self.os_variant)
+
     def _hasTreeinfo(self, fetcher, progresscb):
         # all Red Hat based distros should have .treeinfo, perhaps others
         # will in time


Index: python-virtinst.spec
===================================================================
RCS file: /cvs/pkgs/rpms/python-virtinst/F-10/python-virtinst.spec,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -p -r1.56 -r1.57
--- python-virtinst.spec	5 Oct 2009 18:06:08 -0000	1.56
+++ python-virtinst.spec	22 Oct 2009 13:38:00 -0000	1.57
@@ -11,7 +11,7 @@
 Summary: Python modules and utilities for installing virtual machines
 Name: python-%{appname}
 Version: 0.400.3
-Release: 4%{_extra_release}
+Release: 5%{_extra_release}
 Source0: http://virt-manager.org/download/sources/%{appname}/%{appname}-%{version}.tar.gz
 Patch1: %{appname}-%{version}-fix-virtimage-scratch.patch
 Patch2: %{appname}-%{version}-hostdev-libvirt-calls.patch
@@ -22,6 +22,8 @@ Patch5: %{appname}-%{version}-updated-tr
 Patch6: %{appname}-%{version}-preview-detection.patch
 # Add F12 to os dictionary
 Patch7: %{appname}-%{version}-f12-distro.patch
+# Ensure unknown OS detection doesn't break the install
+Patch8: %{appname}-%{version}-safe-os-detect.patch
 License: GPLv2+
 Group: Development/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -54,6 +56,7 @@ and install new VMs) and virt-clone (clo
 %patch5 -p1
 %patch6 -p1
 %patch7 -p1
+%patch8 -p1
 
 %build
 python setup.py build
@@ -87,6 +90,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/virt-convert
 
 %changelog
+* Thu Oct 22 2009 Cole Robinson <crobinso at redhat.com> - 0.400.3-5.fc10
+- Ensure unknown OS detection doesn't break the install
+
 * Mon Oct 05 2009 Cole Robinson <crobinso at redhat.com> - 0.400.3-4.fc10
 - Fix detection of fedora preview trees (bz 499718)
 - Add F12 to os dictionary




More information about the Fedora-virt-maint mailing list