extras-buildsys/utils/pushscript Comps.py,1.2,1.3
Michael Schwendt (mschwendt)
fedora-extras-commits at redhat.com
Thu Jan 25 23:38:30 UTC 2007
- Previous message (by thread): rpms/cobbler/FC-5 .cvsignore, 1.11, 1.12 cobbler.spec, 1.10, 1.11 sources, 1.11, 1.12
- Next message (by thread): rpms/cobbler/devel .cvsignore, 1.13, 1.14 cobbler.spec, 1.15, 1.16 sources, 1.15, 1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: mschwendt
Update of /cvs/fedora/extras-buildsys/utils/pushscript
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32487
Modified Files:
Comps.py
Log Message:
* catch the typos in packagereq elements/attributes which
broke pirut+yum so badly -- note: this is no full dtd/schema check
Index: Comps.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Comps.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Comps.py 9 Nov 2006 00:57:08 -0000 1.2
+++ Comps.py 25 Jan 2007 23:38:28 -0000 1.3
@@ -17,6 +17,7 @@
import errno, os, sys
import commands, shutil, tempfile
+import xml.parsers.expat
import Utils
@@ -33,6 +34,36 @@
return m.hexdigest()
+class PushCompsException(Exception):
+ pass
+
+# Small extra check of well-formed comps.xml to catch typos which
+# broke comps support in pirut+yum badly.
+def startelhandler(name, attrs):
+ if name=='packagereq':
+ for (a,v) in attrs.items():
+ if a=='type' and v not in ['mandatory', 'default', 'optional', 'conditional']:
+ raise PushCompsException
+
+def _check(filename):
+ p = xml.parsers.expat.ParserCreate()
+ p.StartElementHandler = startelhandler
+ isopen = False
+ try:
+ f = open(filename,'r')
+ isopen = True
+ p.ParseFile(f)
+ f.close()
+ except IOError:
+ if isopen:
+ f.close()
+ return False
+ except PushCompsException:
+ f.close()
+ return False
+ return True
+
+
class CompsUpdater:
def __init__(self,cfg):
@@ -118,6 +149,10 @@
if os.path.exists(compsnew):
os.remove(compsnew)
return
+
+ if not _check(compsvalid):
+ print 'WARNING: %s comps fails check' % dist
+ return
# Install new comps file only if fingerprint differs.
# First repo gets a new copy, further repos a hardlink.
@@ -133,7 +168,7 @@
# This copy of comps.xml is the same, don't overwrite it,
# but use it as link source.
linkloc = compstarget
- return
+ continue
print ' Updating %s' % compstarget
if os.path.exists(compstarget):
os.remove(compstarget)
- Previous message (by thread): rpms/cobbler/FC-5 .cvsignore, 1.11, 1.12 cobbler.spec, 1.10, 1.11 sources, 1.11, 1.12
- Next message (by thread): rpms/cobbler/devel .cvsignore, 1.13, 1.14 cobbler.spec, 1.15, 1.16 sources, 1.15, 1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list