Permalink
Browse files

Enable basic xml schema validation for the build description files.

  • Loading branch information...
1 parent cbc299c commit 545a847c20100f8c73df84cc7a1d62e48d69660e @dieterv committed Dec 30, 2010
Showing with 205 additions and 95 deletions.
  1. +24 −20 bin/build_installer.py
  2. +27 −28 wix/2.22.6.win32.xml
  3. +29 −28 wix/2.22.6.win64.xml
  4. +125 −19 wix/build.xsd
View
@@ -67,12 +67,17 @@
XML_LINT = None
# Everything we need to know about xml namespaces.
+BUILD_NS = 'http://schemas.pygtk.org/2010/build'
WIX_NS = 'http://schemas.microsoft.com/wix/2006/wi'
WIX_UTIL_NS = 'http://schemas.microsoft.com/wix/UtilExtension'
+
+# Namespace map used when creating new elements
WIX_NSMAP = {None : WIX_NS,
'util': WIX_UTIL_NS}
-XP_NSMAP = {'w': WIX_NS,
+# Namespace map used with XPath queries
+XP_NSMAP = {'b': BUILD_NS,
+ 'w': WIX_NS,
'u': WIX_UTIL_NS}
@@ -235,15 +240,14 @@ def parse_build_description(self):
if not isfile(buildfile):
error('Unable to load build description "%s".' % buildfile)
- #schema = etree.XMLSchema(file=schemafile)
- #parser = etree.XMLParser(schema=schema)
- #self.buildfile = etree.parse(buildfile, parser=parser).getroot()
- self.buildfile = etree.parse(buildfile).getroot()
+ schema = etree.XMLSchema(file=schemafile)
+ parser = etree.XMLParser(schema=schema)
+ self.buildfile = etree.parse(buildfile, parser=parser).getroot()
info('Loaded build description "%s" ("%s").' % (self.args[0], buildfile))
def build(self):
- for interpreter in self.buildfile.xpath('/Build/Interpreters/*'):
+ for interpreter in self.buildfile.xpath('/b:Build/b:Interpreters/*', namespaces=XP_NSMAP):
version = interpreter.get('Version')
global PYTHON_FULLVERSION
@@ -314,15 +318,15 @@ def do_prepare(self):
os.rename(join(self.builddir, 'PyGTK.wxs'), self.wxsfile)
def do_build(self):
- for feature in self.buildfile.xpath('/Build/Product/Features/*'):
+ for feature in self.buildfile.xpath('/b:Build/b:Product/b:Features/*', namespaces=XP_NSMAP):
info('Preparing feature "%s"...' % feature.get('Id'), 1)
self.build_feature(feature)
def build_feature(self, feature):
for child in feature.iterchildren():
- if child.tag == 'Feature':
+ if child.tag == '{%s}Feature' % BUILD_NS:
self.build_feature(child)
- elif child.tag == 'Package':
+ elif child.tag == '{%s}Package' % BUILD_NS:
info('Preparing source package "%s"' % child.get('Id'), 2)
sourcepackage = SourcePackage.from_packagetype(self.options,
@@ -370,18 +374,18 @@ def transform_includes(self, wxsfile):
def transform(element):
for child in element.iterchildren():
- if child.tag == 'Feature':
+ if child.tag == '{%s}Feature' % BUILD_NS:
transform(child)
- elif child.tag == 'Package':
+ elif child.tag == '{%s}Package' % BUILD_NS:
pi = etree.ProcessingInstruction('include', child.get('wxifile_%s' % PYTHON_VERSION))
package.addnext(pi)
- for feature in self.buildfile.xpath('/Build/Product/Features/*'):
+ for feature in self.buildfile.xpath('/b:Build/b:Product/b:Features/*', namespaces=XP_NSMAP):
transform(feature)
def transform_features(self, wxsfile):
def transform(element, parent):
- if element.tag == 'Feature':
+ if element.tag == '{%s}Feature' % BUILD_NS:
feature = etree.SubElement(parent,
'Feature',
Id = element.get('Id'),
@@ -407,7 +411,7 @@ def transform(element, parent):
else:
error('Error computing Level for Feature "%s"' % element.get('Id'), 2)
- if len(element.xpath('Package')) == 0:
+ if len(element.xpath('b:Package', namespaces=XP_NSMAP)) == 0:
# A Feature should always reference at least one component.
# If we do not do this, the SelectionTree widget seems to
# ignore the AllowAdvertise, InstallDefault and
@@ -417,7 +421,7 @@ def transform(element, parent):
for child in element.iterchildren():
transform(child, feature)
- elif element.tag == 'Package':
+ elif element.tag == '{%s}Package' % BUILD_NS:
def traverse(child, parent):
if child.tag == '{%s}Component' % WIX_NS:
etree.SubElement(parent, 'ComponentRef', Id=child.get('Id'))
@@ -433,7 +437,7 @@ def traverse(child, parent):
feature = wxsfile.xpath('/w:Wix/w:Product/w:Feature', namespaces=XP_NSMAP)[0]
- for child in self.buildfile.xpath('/Build/Product/Features/*'):
+ for child in self.buildfile.xpath('/b:Build/b:Product/b:Features/*', namespaces=XP_NSMAP):
transform(child, feature)
def transform_reformat(self):
@@ -576,7 +580,7 @@ def do_patch(self):
filesdir = join(self.builddir, 'File')
- for child in self.package.xpath('RemoveFile'):
+ for child in self.package.xpath('b:RemoveFile', namespaces=XP_NSMAP):
if isabs(child.get('Id')):
error('Invalid RemoveFile action: Id attribute should not be an absolute path ("%s")' % child.get('Id'), 4)
@@ -587,7 +591,7 @@ def do_patch(self):
else:
error('Invalid RemoveFile action: "%s" does not exist in "%s"' % (child.get('Id'), filesdir), 4)
- for child in self.package.xpath('CopyFile'):
+ for child in self.package.xpath('b:CopyFile', namespaces=XP_NSMAP):
if isabs(child.get('Src')):
error('Invalid CopyFile action: Src attribute should not be an absolute path ("%s")' % child.get('Src'), 4)
@@ -653,7 +657,7 @@ def transform_shortcuts(self, element):
prefix = '%s_' % self.package.get('Id')
include = self.include.xpath('/w:Include', namespaces=XP_NSMAP)[0]
- for child in self.package.xpath('Shortcut'):
+ for child in self.package.xpath('b:Shortcut', namespaces=XP_NSMAP):
programmenufolder = etree.SubElement(include,
'{%s}DirectoryRef' % WIX_NS,
Id='ProgramMenuFolder')
@@ -701,7 +705,7 @@ def transform_shortcuts(self, element):
Type='integer',
KeyPath='yes')
- for child in self.package.xpath('InternetShortcut'):
+ for child in self.package.xpath('b:InternetShortcut', namespaces=XP_NSMAP):
programmenufolder = etree.SubElement(include,
'{%s}DirectoryRef' % WIX_NS,
Id='ProgramMenuFolder')
View
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<Build>
-<!-- <Build xmlns="http://schemas.pygtk.org/2010/build"> -->
+<Build xmlns="http://schemas.pygtk.org/2010/build">
<Interpreters>
<Interpreter Version="2.6" />
<Interpreter Version="2.7" />
@@ -87,22 +86,22 @@
Absent = "allow"
Level = "2">
- <Package Id = "pygtksourceview2"
- Type = "MsiSourcePackage"
+ <Package Type = "MsiSourcePackage"
+ Id = "pygtksourceview2"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtksourceview/2.10/"
Msi_26 = "pygtksourceview-2.10.1.win32-py2.6.msi"
Msi_27 = "pygtksourceview-2.10.1.win32-py2.7.msi"
Digest_26 = "123d751255edd7cb4d0f8e8253574058"
Digest_27 = "c5c017fbf1ac99929a6d7a2be4f2b514" />
- <Package Id = "libgtksourceview"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "libgtksourceview"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/gtksourceview/2.10/"
Archive = "gtksourceview-2.10.0.zip"
Digest = "246460cc82a233f0aaffe2075b4455ef" />
- <Package Id = "libgtksourceview_dev"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "libgtksourceview_dev"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/gtksourceview/2.10/"
Archive = "gtksourceview-dev-2.10.0.zip"
Digest = "4510027ea0ab4fcb0e0d68fa596bccb5" />
@@ -114,22 +113,22 @@
Absent = "allow"
Level = "2">
- <Package Id = "pygoocanvas"
- Type = "MsiSourcePackage"
+ <Package Type = "MsiSourcePackage"
+ Id = "pygoocanvas"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygoocanvas/0.14/"
Msi_26 = "pygoocanvas-0.14.2.win32-py2.6.msi"
Msi_27 = "pygoocanvas-0.14.2.win32-py2.7.msi"
Digest_26 = "effa78d13f535213e338beb41badf419"
Digest_27 = "9fc8a8795c31e0c469958530adb80d93" />
- <Package Id = "libgoocanvas"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "libgoocanvas"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/goocanvas/0.15/"
Archive = "goocanvas-0.15-win32.zip"
Digest = "18117c424950b6c014780af849508838" />
- <Package Id = "libgoocanvas_dev"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "libgoocanvas_dev"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/goocanvas/0.15/"
Archive = "goocanvas-dev-0.15-win32.zip"
Digest = "c1068163ef67986598bce6dad5524e75" />
@@ -141,8 +140,8 @@
Absent = "allow"
Level = "2">
- <Package Id = "pyrsvg"
- Type = "MsiSourcePackage"
+ <Package Type = "MsiSourcePackage"
+ Id = "pyrsvg"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/gnome-python-desktop/2.32/"
Msi_26 = "pyrsvg-2.32.1.win32-py2.6.msi"
Msi_27 = "pyrsvg-2.32.1.win32-py2.7.msi"
@@ -190,20 +189,20 @@
Level = "2"
Absent = "allow">
- <Package Id = "libiconv"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "libiconv"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/"
Archive = "libiconv-1.9.1.bin.woe32.zip"
Digest = "a18e9420d6a354b585a77230996b4171" />
- <Package Id = "gettext_tools"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "gettext_tools"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/"
Archive = "gettext-tools_0.18.1.1-2_win32.zip"
Digest = "e38076f290198adf75c7c3f5a7886653" />
- <Package Id = "gettext_tools_dev"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "gettext_tools_dev"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/"
Archive = "gettext-tools-dev_0.18.1.1-2_win32.zip"
Digest = "e5a6f32b28ba8a08173e1f6e2a8db0c1">
@@ -217,14 +216,14 @@
<RemoveFile Id="src/tml/packaging/gettext_0.18.1.1-2_win32.sh" />
</Package>
- <Package Id = "intltool"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "intltool"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/intltool/0.40/"
Archive = "intltool_0.40.4-1_win32.zip"
Digest = "d03b3270a4ddafdc0d4e9bcc6dcc6b65" />
- <Package Id = "intltool_dev"
- Type = "ArchiveSourcePackage"
+ <Package Type = "ArchiveSourcePackage"
+ Id = "intltool_dev"
Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/intltool/0.40/"
Archive = "intltool-dev_0.40.4-1_win32.zip"
Digest = "7e64b0128891406d89daea91cf9fd046" />
@@ -397,8 +396,8 @@
anyway. See https://bugzilla.gnome.org/show_bug.cgi?id=637742.
<Package Type = "ArchiveSourcePackage"
Id = "pixman"
- Url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/"
- Archive = "pixman_0.20.0-1_win32.zip"
+ Url = ""
+ Archive = ""
Digest = "" /> -->
<Package Type = "ArchiveSourcePackage"
Oops, something went wrong.

0 comments on commit 545a847

Please sign in to comment.