rpms/python-virtinst/F-8 virtinst-0.300.2-f10-treeinfo.patch, NONE, 1.1 python-virtinst.spec, 1.36, 1.37

Cole Robinson crobinso at fedoraproject.org
Tue Nov 25 19:32:28 UTC 2008


Author: crobinso

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

Modified Files:
	python-virtinst.spec 
Added Files:
	virtinst-0.300.2-f10-treeinfo.patch 
Log Message:
Future proof URL fetching by looking for .treeinfo (bz 458164)


virtinst-0.300.2-f10-treeinfo.patch:

--- NEW FILE virtinst-0.300.2-f10-treeinfo.patch ---
diff -rup --exclude='*.orig' orig/virtinst/OSDistro.py new/virtinst/OSDistro.py
--- orig/virtinst/OSDistro.py	2008-09-15 14:28:56.344281000 -0400
+++ new/virtinst/OSDistro.py	2008-09-15 15:15:41.181364000 -0400
@@ -24,6 +24,7 @@ import os
 import gzip
 import re
 import tempfile
+import ConfigParser
 
 from virtinst import _virtinst as _
 from ImageFetcher import ImageFetcher
@@ -51,14 +52,46 @@ class Distro:
 # Base image store for any Red Hat related distros which have
 # a common layout
 class RedHatDistro(Distro):
+    def __init__(self, uri, type=None, scratchdir=None):
+        Distro.__init__(self, uri, type, scratchdir)
+        self.treeinfo = None
+
+    def hasTreeinfo(self, fetcher, progresscb):
+        # all Red Hat based distros should have .treeinfo / execute only once
+        if not (self.treeinfo is None):
+            return True
+
+        if not fetcher.hasFile(".treeinfo", progresscb):
+            return False
+
+        logging.debug("Detected .treeinfo file")
+
+        tmptreeinfo = fetcher.acquireFile(".treeinfo", progresscb)
+        try:
+            self.treeinfo = ConfigParser.SafeConfigParser()
+            self.treeinfo.read(tmptreeinfo)
+        finally:
+            os.unlink(tmptreeinfo)
+
+        return True
 
     def acquireKernel(self, fetcher, progresscb):
-        if self.type is None:
-            kernelpath = "images/pxeboot/vmlinuz"
-            initrdpath = "images/pxeboot/initrd.img"
+        if self.hasTreeinfo(fetcher, progresscb):
+            if self.type == "xen":
+                type = "xen"
+            else:
+                type = self.treeinfo.get("general", "arch")
+
+            kernelpath = self.treeinfo.get("images-%s" % type, "kernel")
+            initrdpath = self.treeinfo.get("images-%s" % type, "initrd")
         else:
-            kernelpath = "images/%s/vmlinuz" % (self.type)
-            initrdpath = "images/%s/initrd.img" % (self.type)
+            # fall back to old code
+            if self.type is None:
+                kernelpath = "images/pxeboot/vmlinuz"
+                initrdpath = "images/pxeboot/initrd.img"
+            else:
+                kernelpath = "images/%s/vmlinuz" % (self.type)
+                initrdpath = "images/%s/initrd.img" % (self.type)
 
         kernel = fetcher.acquireFile(kernelpath, progresscb)
         try:
@@ -76,43 +109,63 @@ class RedHatDistro(Distro):
             os.unlink(kernel)
 
     def acquireBootDisk(self, fetcher, progresscb):
-        return fetcher.acquireFile("images/boot.iso", progresscb)
+        if self.hasTreeinfo(fetcher, progresscb):
+            if self.type == "xen":
+                type = "xen"
+            else:
+                type = self.treeinfo.get("general", "arch")
+            return fetcher.acquireFile(self.treeinfo.get("images-%s" % type, "boot.iso"), progresscb)
+        else:
+            return fetcher.acquireFile("images/boot.iso", progresscb)
 
 # Fedora distro check
 class FedoraDistro(RedHatDistro):
     def isValidStore(self, fetcher, progresscb):
-        if fetcher.hasFile(".treeinfo", progresscb):
-            logging.debug("Detected a Fedora distro")
-            return True
-        if fetcher.hasFile("fedora.css", progresscb):
-            logging.debug("Detected a Fedora distro")
-            return True
-        if fetcher.hasFile("Fedora", progresscb):
-            logging.debug("Detected a Fedora distro")
-            return True
-        return False
+        if self.hasTreeinfo(fetcher, progresscb):
+            m = re.match(".*Fedora.*", self.treeinfo.get("general", "family"))
+            return (m != None)
+        else:
+            # fall back to old code
+            if fetcher.hasFile("fedora.css", progresscb):
+                logging.debug("Detected a Fedora distro")
+                return True
+            if fetcher.hasFile("Fedora", progresscb):
+                logging.debug("Detected a Fedora distro")
+                return True
+            return False
 
-# Fedora distro check
+# Red Hat Enterprise Linux distro check
 class RHELDistro(RedHatDistro):
     def isValidStore(self, fetcher, progresscb):
-        if fetcher.hasFile("Server", progresscb):
-            logging.debug("Detected a RHEL 5 Server distro")
-            return True
-        if fetcher.hasFile("Client", progresscb):
-            logging.debug("Detected a RHEL 5 Client distro")
-            return True
-        if fetcher.hasFile("RedHat", progresscb):
-            logging.debug("Detected a RHEL 4 distro")
-            return True
+        if self.hasTreeinfo(fetcher, progresscb):
+            m = re.match(".*Red Hat Enterprise Linux.*", self.treeinfo.get("general", "family"))
+            return (m != None)
+        else:
+            # fall back to old code
+            if fetcher.hasFile("Server", progresscb):
+                logging.debug("Detected a RHEL 5 Server distro")
+                return True
+            if fetcher.hasFile("Client", progresscb):
+                logging.debug("Detected a RHEL 5 Client distro")
+                return True
+            if fetcher.hasFile("RedHat", progresscb):
+                logging.debug("Detected a RHEL 4 distro")
+                return True
         return False
 
 # CentOS distro check
 class CentOSDistro(RedHatDistro):
     def isValidStore(self, fetcher, progresscb):
-        if fetcher.hasFile("CentOS", progresscb):
-            logging.debug("Detected a CentOS distro")
-            return True
-        return False
+        if self.hasTreeinfo(fetcher, progresscb):
+            m = re.match(".*CentOS.*", self.treeinfo.get("general", "family"))
+            return (m != None)
+        else:
+            # fall back to old code
+            if fetcher.hasFile("CentOS", progresscb):
+                logging.debug("Detected a CentOS distro")
+                return True
+            return False
+
 
 # Scientific Linux distro check
 class SLDistro(RedHatDistro):
diff -rup virtinst-0.300.2/virtinst/OSDistro.py new/virtinst/OSDistro.py
--- virtinst-0.300.2/virtinst/OSDistro.py	2008-11-10 12:00:34.213059000 -0500
+++ new/virtinst/OSDistro.py	2008-11-10 12:02:16.212090000 -0500
@@ -64,13 +64,20 @@ class RedHatDistro(Distro):
         if not fetcher.hasFile(".treeinfo", progresscb):
             return False
 
-        logging.debug("Detected .treeinfo file")
-
         tmptreeinfo = fetcher.acquireFile(".treeinfo", progresscb)
         try:
+            # Seems urlgrabber will report an ftp file always exists. Check
+            # The returned contents to make sure we retrieved something useful
+            treefile = open(tmptreeinfo, "r")
+            if not treefile.read():
+                return False
+
             self.treeinfo = ConfigParser.SafeConfigParser()
             self.treeinfo.read(tmptreeinfo)
+
+            logging.debug("Detected a valid .treeinfo file")
         finally:
+            treefile.close()
             os.unlink(tmptreeinfo)
 
         return True
diff -rup virtinst-0.300.2/virtinst/FullVirtGuest.py new/virtinst/FullVirtGuest.py
--- virtinst-0.300.2/virtinst/FullVirtGuest.py	2008-11-25 13:39:47.479190000 -0500
+++ new/virtinst/FullVirtGuest.py	2008-11-25 13:38:39.101843000 -0500
@@ -44,6 +44,8 @@ class FullVirtGuest(Guest.XenGuest):
                                           "fedora6": { "label": "Fedora Core 6", "distro": "fedora" }, \
                                           "fedora7": { "label": "Fedora 7", "distro": "fedora" }, \
                                           "fedora8": { "label": "Fedora 8", "distro": "fedora" }, \
+                                          "fedora9": { "label": "Fedora 9", "distro": "fedora" }, \
+                                          "fedora10": { "label": "Fedora 10", "distro": "fedora" },
                                           "sles10": { "label": "Suse Linux Enterprise Server", "distro": "suse" }, \
                                           "debianEtch": { "label": "Debian Etch", "distro": "debian" }, \
                                           "debianLenny": { "label": "Debian Lenny", "distro": "debian" }, \


Index: python-virtinst.spec
===================================================================
RCS file: /cvs/pkgs/rpms/python-virtinst/F-8/python-virtinst.spec,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- python-virtinst.spec	19 Mar 2008 19:01:39 -0000	1.36
+++ python-virtinst.spec	25 Nov 2008 19:31:58 -0000	1.37
@@ -11,7 +11,7 @@
 Summary: Python modules for starting Xen guest installations
 Name: python-%{appname}
 Version: 0.300.2
-Release: 4%{_extra_release}
+Release: 5%{_extra_release}
 Source0: http://virt-manager.org/download/sources/%{appname}/%{appname}-%{version}.tar.gz
 
 Patch1: %{appname}-%{version}-satellite-distro.patch
@@ -22,6 +22,7 @@
 Patch6: %{appname}-%{version}-force-option.patch
 Patch7: %{appname}-%{version}-remove-file-exist-check.patch
 Patch8: %{appname}-%{version}-install-f9.patch
+Patch9: %{appname}-%{version}-f10-treeinfo.patch
 
 License: GPLv2+
 Group: Development/Libraries
@@ -60,6 +61,7 @@
 %patch6 -p1
 %patch7 -p1
 %patch8 -p1
+%patch9 -p1
 
 %build
 python setup.py build
@@ -89,6 +91,9 @@
 %{_bindir}/virt-image
 
 %changelog
+* Wed Nov 25 2008 Cole Robinson <crobinso at redhat.com> - 0.300.2-5.fc8
+- Future proof URL fetching by looking for .treeinfo (bz 458164)
+
 * Wed Mar 19 2008 Daniel P. Berrange <berrange at redhat.com> - 0.300.2-4.fc8
 - Fix file check to allow installing rawhide/f9 guests
 - Add --force option to cli utils to not prompt for input.




More information about the fedora-extras-commits mailing list