summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--schemas/metadata.xsd6
-rw-r--r--schemas/xinclude.xsd41
-rwxr-xr-xsrc/sbin/bcfg2-repo-validate49
3 files changed, 71 insertions, 25 deletions
diff --git a/schemas/metadata.xsd b/schemas/metadata.xsd
index 7d07c4971..58f9e8029 100644
--- a/schemas/metadata.xsd
+++ b/schemas/metadata.xsd
@@ -1,4 +1,5 @@
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en">
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xi="http://www.w3.org/2001/XInclude" xml:lang="en">
<xsd:annotation>
<xsd:documentation>
@@ -10,6 +11,8 @@
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml.xsd"/>
+ <xsd:import namespace="http://www.w3.org/2001/XInclude"
+ schemaLocation="xinclude.xsd"/>
<xsd:complexType name='groupType'>
<xsd:choice minOccurs='0' maxOccurs='unbounded'>
@@ -37,6 +40,7 @@
<xsd:choice minOccurs='0' maxOccurs='unbounded'>
<xsd:element name='Group' type='groupType'/>
<xsd:element name='Groups' type='groupsType'/>
+ <xsd:element ref="xi:include"/>
</xsd:choice>
<xsd:attribute name='version' type='xsd:string'/>
<xsd:attribute name='origin' type='xsd:string'/>
diff --git a/schemas/xinclude.xsd b/schemas/xinclude.xsd
new file mode 100644
index 000000000..de58df4e0
--- /dev/null
+++ b/schemas/xinclude.xsd
@@ -0,0 +1,41 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ targetNamespace="http://www.w3.org/2001/XInclude"
+ finalDefault="extension">
+ <xs:annotation>
+ <xs:documentation>
+ The official XInclude XML Schema document is not normative or
+ deterministic. This schema implements only the features of
+ XInclude that are used in Bcfg2 in a manner that is deterministic
+ (i.e., passes XML validation).
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:element name="include" type="xi:includeType" />
+ <xs:complexType name="includeType" mixed="true">
+ <xs:choice minOccurs="0" maxOccurs="unbounded" >
+ <xs:element ref="xi:fallback" />
+ </xs:choice>
+ <xs:attribute name="href" use="optional" type="xs:anyURI"/>
+ <xs:attribute name="parse" use="optional" default="xml"
+ type="xi:parseType" />
+ <xs:attribute name="xpointer" use="optional" type="xs:string"/>
+ <xs:attribute name="encoding" use="optional" type="xs:string"/>
+ <xs:attribute name="accept" use="optional" type="xs:string"/>
+ <xs:attribute name="accept-language" use="optional" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:simpleType name="parseType">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="xml"/>
+ <xs:enumeration value="text"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="fallback" type="xi:fallbackType" />
+ <xs:complexType name="fallbackType" mixed="true">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="xi:include"/>
+ </xs:choice>
+ </xs:complexType>
+</xs:schema>
diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate
index 271f498cd..d4eb0ffd2 100755
--- a/src/sbin/bcfg2-repo-validate
+++ b/src/sbin/bcfg2-repo-validate
@@ -30,7 +30,7 @@ if __name__ == '__main__':
if setup['stdin']:
file_list = map(lambda s: s.strip(), sys.stdin.readlines())
info_list = [f for f in file_list if os.path.basename(f) == 'info.xml']
- metadata_list = fnmatch.filter(file_list, "*/Metadata/groups.xml")
+ metadata_list = fnmatch.filter(file_list, "*/Metadata/*.xml")
clients_list = fnmatch.filter(file_list, "*/Metadata/clients.xml")
bundle_list = fnmatch.filter(file_list, "*/Bundler/*.xml")
genshibundle_list = fnmatch.filter(file_list, "*/Bundler/*.genshi")
@@ -71,24 +71,30 @@ if __name__ == '__main__':
pkgcfg_list = glob.glob("%s/Packages/config.xml" % repo)
gp_list = glob.glob('%s/GroupPatterns/config.xml' % repo)
- # include files in metadata_list
- ref_bundles = set()
- xdata = lxml.etree.parse("%s/Metadata/groups.xml" % repo)
- included = set([ent.get('href') for ent in \
- xdata.findall('./{http://www.w3.org/2001/XInclude}include')])
- while included:
- try:
- filename = included.pop()
- except KeyError:
- continue
- metadata_list.append("%s/Metadata/%s" % (repo, filename))
- groupdata = lxml.etree.parse("%s/Metadata/%s" % (repo, filename))
- group_ents = [ent.get('href') for ent in \
- groupdata.
- findall('./{http://www.w3.org/2001/XInclude}include')]
- for ent in group_ents:
- included.add(ent)
- included.discard(filename)
+ # include files in metadata_list
+ ref_bundles = set()
+ xdata = lxml.etree.parse("%s/Metadata/groups.xml" % repo)
+ included = set([ent.get('href') for ent in
+ xdata.findall('./{http://www.w3.org/2001/XInclude}include')])
+ while included:
+ try:
+ filename = included.pop()
+ except KeyError:
+ continue
+ if not setup['stdin'] or filepath in file_list:
+ metadata_list.append("%s/Metadata/%s" % (repo, filename))
+ groupdata = lxml.etree.parse("%s/Metadata/%s" % (repo, filename))
+ group_ents = [ent.get('href') for ent in \
+ groupdata.
+ findall('./{http://www.w3.org/2001/XInclude}include')]
+ for ent in group_ents:
+ included.add(ent)
+ included.discard(filename)
+
+ # get all XIncluded bundles
+ xdata.xinclude()
+ for bundle in xdata.findall("//Bundle"):
+ ref_bundles.add("%s/Bundler/%s" % (repo, bundle.get('name')))
# check for multiple default group definitions
default_groups = []
@@ -101,11 +107,6 @@ if __name__ == '__main__':
for grp in default_groups:
print(" %s" % grp.get('name'))
- # get all XIncluded bundles
- xdata.xinclude()
- for bundle in xdata.findall("//Bundle"):
- ref_bundles.add("%s/Bundler/%s" % (repo, bundle.get('name')))
-
# verify attributes for configuration entries
# (as defined in doc/server/configurationentries)
# TODO: See if it is possible to do this in the schema instead