Blame SOURCES/BZ-1296282-verifytree-fix-comps-schema.patch

5b4f08
diff -up yum-utils-1.1.31/verifytree.py.orig yum-utils-1.1.31/verifytree.py
5b4f08
--- yum-utils-1.1.31/verifytree.py.orig	2016-07-21 14:46:21.050199284 +0200
5b4f08
+++ yum-utils-1.1.31/verifytree.py	2016-07-21 14:46:43.277058501 +0200
5b4f08
@@ -47,8 +47,22 @@ plan_number = 13
5b4f08
 case_numbers = {'REPODATA': 56, 'CORE_PACKAGES': 57, 'COMPS': 58, 
5b4f08
                 'BOOT_IMAGES': 59}
5b4f08
 
5b4f08
-# URL for the RELAX NG schema for comps
5b4f08
-SCHEMA = 'http://cvs.fedoraproject.org/viewcvs/*checkout*/comps/comps.rng'
5b4f08
+def get_schema_path():
5b4f08
+    """Return the local path to the RELAX NG comps schema."""
5b4f08
+    # Depending on whether our distro uses versioned or unversioned docdirs
5b4f08
+    # (the former is true for Fedora < 20, see bug 998579), the schema file
5b4f08
+    # should be provided by yum at either of the following locations:
5b4f08
+    paths = ['/usr/share/doc/yum%s/comps.rng' % s
5b4f08
+             for s in ('', '-' + yum.__version__)]
5b4f08
+    for path in paths:
5b4f08
+        # Better than os.path.exists() as this also ensures we can actually
5b4f08
+        # read the file
5b4f08
+        try:
5b4f08
+            with open(path):
5b4f08
+                return path
5b4f08
+        except IOError:
5b4f08
+            continue
5b4f08
+    raise IOError(paths)
5b4f08
 
5b4f08
 def testopia_create_run(plan):
5b4f08
     '''Create a run of the given test plan. Returns the run ID.'''
5b4f08
@@ -230,9 +244,19 @@ def main():
5b4f08
 
5b4f08
         if not (retval & BAD_COMPS):
5b4f08
             print "  verifying comps.xml grammar with xmllint"
5b4f08
-            comps = newrepo.getGroups()
5b4f08
-            r = os.system("xmllint --noout --nowarning --relaxng %s %s" % 
5b4f08
-                (SCHEMA,comps))
5b4f08
+            try:
5b4f08
+                schema = get_schema_path()
5b4f08
+            except IOError as e:
5b4f08
+                print '  could not read schema file, paths tried:'
5b4f08
+                for path in e.args[0]:
5b4f08
+                    print '    ' + path
5b4f08
+                print ('  make sure you have the latest version of yum '
5b4f08
+                       'properly installed')
5b4f08
+                r = 1
5b4f08
+            else:
5b4f08
+                comps = newrepo.getGroups()
5b4f08
+                r = os.system("xmllint --noout --nowarning --relaxng %s %s" %
5b4f08
+                    (schema, comps))
5b4f08
             if r != 0:
5b4f08
                 retval = retval | BAD_COMPS
5b4f08
                 report('COMPS','FAILED')