self.verbose = False
self.force = False
self.reinstall = False
+ self.dir = ''
class Database:
XmlElement(fpd, "/PlatformHeader/PlatformName")
for farfile in XmlList(self.dom, "/FrameworkDatabase/FarList/Filename"):
- farGuid = farfile.getAttribute("FarGuid")
+ farGuid = Guid(farfile.getAttribute("FarGuid"))
self.installedFars[farGuid] = XmlElementData(farfile)
self.packageList = XmlNode(self.dom, "/FrameworkDatabase/PackageList")
gpath = ["PlatformSurfaceArea", "PlatformHeader", "GuidValue"]
vpath = ["PlatformSurfaceArea", "PlatformHeader", "Version"]
- return string.lower(XmlElement(Dom, "/".join(gpath[strip:]))), \
- XmlElement(Dom, "/".join(vpath[strip:]))
+ return Guid(XmlElement(Dom, "/".join(gpath[strip:]))), \
+ XmlElement(Dom, "/".join(vpath[strip:]))
def GetSpdGuidVersion(Dom, strip=0):
gpath = ["PackageSurfaceArea", "SpdHeader", "GuidValue"]
vpath = ["PackageSurfaceArea", "SpdHeader", "Version"]
- return string.lower(XmlElement(Dom, "/".join(gpath[strip:]))), \
- XmlElement(Dom, "/".join(vpath[strip:]))
+ return Guid(XmlElement(Dom, "/".join(gpath[strip:]))), \
+ XmlElement(Dom, "/".join(vpath[strip:]))
def InstallFar(farfile, workspaceLocation=""):
msa = XmlParseString(far.read(msafilePath))
for package in XmlList(msa, "/ModuleSurfaceArea/PackageDependencies/Package"):
- guid = package.getAttribute("PackageGuid")
+ guid = Guid(package.getAttribute("PackageGuid"))
version = package.getAttribute("PackageVersion")
# Does anyone provide this package?
# Go through the dependencies
for dependency in XmlList(fpd, "/PlatformSurfaceArea/FrameworkModules/ModuleSA") + \
XmlList(fpd, "/PlatformSurfaceArea/FrameworkModules/ModuleSA/Libraries/Instance"):
- packagesNeeded.add((string.lower(dependency.getAttribute("PackageGuid")),
- dependency.getAttribute("PackageVersion")))
+ packagesNeeded.add((Guid(dependency.getAttribute("PackageGuid")),
+ dependency.getAttribute("PackageVersion")))
# Let's see if all the packages are in the workspace
for guid, version in packagesNeeded:
installError = True
# Check the fars
- thisFarGuid = string.lower(XmlElement(manifest, "/FrameworkArchiveManifest/FarHeader/GuidValue"))
+ thisFarGuid = Guid(XmlElement(manifest, "/FrameworkArchiveManifest/FarHeader/GuidValue"))
if fdb.HasFar(thisFarGuid):
if not flags.reinstall:
print "Error: There is a far with this guid already installed."
flags = Flags()
# Process the command line args.
- optlist, args = getopt.getopt(sys.argv[1:], '?hvf', ['help', 'verbose', 'force', 'reinstall'])
+ optlist, args = getopt.getopt(sys.argv[1:], '?hvfd:', ['directory=', 'help', 'verbose', 'force', 'reinstall'])
# First pass through the options list.
for o, a in optlist:
optlist.remove((o,a))
if o in ["-v", "--verbose"]:
flags.verbose = True
+ if o in ["-d", "--directory"]:
+ flags.dir = a
if o in ["-f", "--force"]:
flags.force = True
if o in ["--reinstall"]:
far = Far()
"""The far object is constructed from the template file the user passed in."""
+def AddToZip(zip, infile):
+
+ """Add a file to a zip file, provided it is not already there."""
+
+ if not infile in zip.namelist():
+ zip.write(inWorkspace(infile), infile)
+
def parseMsa(msaFile, spdDir):
- """ XXX Parse an msa file and return a list of all the files that this msa
+ """Parse an msa file and return a list of all the files that this msa
includes."""
filelist = [msaFile]
xmlPaths = [
"/ModuleSurfaceArea/SourceFiles/Filename",
"/ModuleSurfaceArea/NonProcessedFiles/Filename" ]
-
+
for xmlPath in xmlPaths:
for f in XmlList(msa, xmlPath):
filelist.append(str(os.path.join(msaDir, XmlElementData(f))))
spd = xml.dom.minidom.parse(inWorkspace(spdFile))
+ # We are currently ignoring these hints.
+ readonly = XmlElement(spd, "/PackageSurfaceArea/PackageDefinitions/ReadOnly") != "false"
+ repackage = XmlElement(spd, "/PackageSurfaceArea/PackageDefinitions/RePackage") != "false"
+
xmlPaths = [
"/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass/IncludeHeader",
- "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader/IncludeHeader",
- "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader" ]
+ "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader/IncludeHeader" ]
+
+ # These are covered by the Industry Standard Includes.
+ # "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader"
for xmlPath in xmlPaths:
for f in XmlList(spd, xmlPath):
"""Create a dom tree for the Far Header. It will use information from the
template file passed on the command line, if present."""
-
+
header = XmlAppendChildElement(doc.documentElement, "FarHeader")
XmlAppendChildElement(header, "FarName", far.FarName)
contents = XmlAppendChildElement(top_element, "Contents")
XmlAppendChildElement(top_element, "UserExtensions")
- zip = zipfile.ZipFile(farname, "w")
+ try:
+ zip = zipfile.ZipFile(farname, "w", zipfile.ZIP_DEFLATED)
+ except:
+ zip = zipfile.ZipFile(farname, "w", zipfile.ZIP_STORED)
for infile in set(files):
if not os.path.exists(inWorkspace(infile)):
print "Error: Non-existent file '%s'." % infile
package = XmlAppendChildElement(packList, "FarPackage")
XmlAppendChildElement(package, "FarFilename", lean(infile), {"Md5Sum": Md5(inWorkspace(infile))})
- zip.write(inWorkspace(infile), infile)
+ AddToZip(zip, infile)
XmlAppendChildElement(package, "GuidValue", spdGuid)
XmlAppendChildElement(package, "Version", spdVersion)
XmlAppendChildElement(package, "DefaultPath", spdDir)
for spdfile in filelist:
XmlAppendChildElement(packContents, "FarFilename", lean(spdfile), {"Md5Sum": Md5(inWorkspace(os.path.join(spdDir, spdfile)))})
- zip.write(inWorkspace(os.path.join(spdDir, spdfile)), os.path.join(spdDir,spdfile))
+ AddToZip(zip, os.path.join(spdDir,spdfile))
elif extension == ".fpd":
platform = XmlAppendChildElement(platList, "FarPlatform")
XmlAppendChildElement(platform, "FarFilename", lean(infile), {"Md5Sum": Md5(inWorkspace(infile))})
- zip.write(inWorkspace(infile), infile)
+ AddToZip(zip, infile)
else:
XmlAppendChildElement(contents, "FarFilename", lean(infile), {"Md5Sum": Md5(inWorkspace(infile))})
- zip.write(inWorkspace(infile), infile)
+ AddToZip(zip, infile)
zip.writestr("FrameworkArchiveManifest.xml", man.toxml('UTF-8'))
zip.close()
# Second pass through the options list. These can override the first pass.
for o, a in optlist:
- print o, a
if o in ["-o", "--far", "--output"]:
far.FileName = a