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

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