summaryrefslogtreecommitdiffstats
path: root/Tools/Python
diff options
context:
space:
mode:
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-22 19:41:08 +0000
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-22 19:41:08 +0000
commit24a86f9acc0773579aaa8560dc196e443c0e5cfc (patch)
tree09fba7075749a9148c6c355759964a7defc93287 /Tools/Python
parent2897231803d9d506f7cb7c68eeb59dcc4805084d (diff)
downloadedk2-24a86f9acc0773579aaa8560dc196e443c0e5cfc.tar.gz
edk2-24a86f9acc0773579aaa8560dc196e443c0e5cfc.tar.bz2
edk2-24a86f9acc0773579aaa8560dc196e443c0e5cfc.zip
Add dependency checking to the Far install.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2279 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Python')
-rwxr-xr-xTools/Python/InstallFar.py69
-rwxr-xr-xTools/Python/MkFar.py2
-rwxr-xr-xTools/Python/XmlRoutines.py7
3 files changed, 67 insertions, 11 deletions
diff --git a/Tools/Python/InstallFar.py b/Tools/Python/InstallFar.py
index c1dc4c10c0..346b09e5a3 100755
--- a/Tools/Python/InstallFar.py
+++ b/Tools/Python/InstallFar.py
@@ -57,18 +57,22 @@ class Database:
self.lock.close()
os.unlink(self.lockfile)
- def HasPackage(self, spdString):
+ def HasPackage(self, (guid, version)):
"""Return true iff this package is already installed."""
- spdHeader = XmlParseStringSection(spdString, "SpdHeader")
- guid = XmlElement(spdHeader, "/SpdHeader/GuidValue")
- version = XmlElement(spdHeader, "/SpdHeader/Version")
+ if version == "":
+ # Look for the guid.
+ for (g, v) in self.installedPackages.keys():
+ if g == guid:
+ return True
return self.installedPackages.has_key((guid, version))
- def HasPlatform(self, fpdString):
+ def HasPlatform(self, (guid, version)):
"""Return true iff this platform is already installed."""
- fpdHeader = XmlParseStringSection(fpdString, "PlatformHeader")
- guid = XmlElement(fpdHeader, "/PlatformHeader/GuidValue")
- version = XmlElement(fpdHeader, "/PlatformHeader/Version")
+ if version == "":
+ # Look for the guid.
+ for (g, v) in self.installedPlatforms.keys():
+ if g == guid:
+ return True
return self.installedPlatforms.has_key((guid, version))
def HasFar(self, farguid):
@@ -113,6 +117,20 @@ def ExtractFile(zip, file, workspaceLocation=""):
f.write(zip.read(file))
f.close()
+def GetFpdGuidVersion(Dom):
+
+ """Get the Guid and version of the fpd from a dom object."""
+
+ return XmlElement(Dom, "/PlatformSurfaceArea/PlatformHeader/GuidValue"), \
+ XmlElement(Dom, "/PlatformSurfaceArea/PlatformHeader/Version")
+
+def GetSpdGuidVersion(Dom):
+
+ """Get the Guid and version of the spd from a dom object."""
+
+ return XmlElement(Dom, "/PackageSurfaceArea/SpdHeader/GuidValue"), \
+ XmlElement(Dom, "/PackageSurfaceArea/SpdHeader/Version")
+
def InstallFar(farfile, workspaceLocation=""):
far = zipfile.ZipFile(farfile, "r")
@@ -126,17 +144,48 @@ def InstallFar(farfile, workspaceLocation=""):
# First we need to make sure that the far will install cleanly.
+ installError = False # Let's hope for the best.
+ spdDoms = []
+ farSpds = []
+
# Check the packages
for farPackage in XmlList(manifest, "/FrameworkArchiveManifest/FarPackageList/FarPackage/FarFilename"):
spdfile = str(XmlElementData(farPackage))
- if fdb.HasPackage(far.read(spdfile)):
+ spd = XmlParseString(far.read(spdfile))
+ packageGV = GetSpdGuidVersion(spd)
+ if fdb.HasPackage(packageGV):
print "Error: This package is already installed: ", spdfile
installError = True
+ # Build up a list of the package guid versions that this far is bringing in.
+ # This is needed to satisfy dependencies of msas that are in the other packages of
+ # this far.
+
+ farSpds.append(packageGV)
+
+ spdDoms.append(spd)
+
+ for spd in spdDoms:
+ # Now we need to get a list of every msa in this spd and check the package dependencies.
+ for msafile in XmlList(spd, "/PackageSurfaceArea/MsaFiles/Filename"):
+ msafilePath = str(os.path.join(os.path.dirname(spdfile), XmlElementData(msafile)))
+
+ msa = XmlParseString(far.read(msafilePath))
+
+ for package in XmlList(msa, "/ModuleSurfaceArea/PackageDependencies/Package"):
+ guid = package.getAttribute("PackageGuid")
+ version = package.getAttribute("PackageVersion")
+
+ if not fdb.HasPackage((guid, version)) and not (guid, version) in farSpds:
+ print "The module %s depends on the package guid % version %s, which is not installed in the workspace." \
+ % (msafilePath, guid, version)
+ installError = True
+
# Check the platforms
for farPlatform in XmlList(manifest, "/FrameworkArchiveManifest/FarPlatformList/FarPlatform/FarFilename"):
fpdfile = str(XmlElementData(farPlatform))
- if fdb.HasPlatform(far.read(fpdfile)):
+ fpd = XmlParseString(far.read(fpdfile))
+ if fdb.HasPlatform(GetFpdGuidVersion(fpd)):
print "Error: This platform is already installed: ", fpdfile
installError = True
diff --git a/Tools/Python/MkFar.py b/Tools/Python/MkFar.py
index bdecd2137c..e20bf4dd68 100755
--- a/Tools/Python/MkFar.py
+++ b/Tools/Python/MkFar.py
@@ -190,7 +190,7 @@ def makeFar(files, farname):
for spdfile in filelist:
content = farFileNode(man, inWorkspace(os.path.join(spdDir, spdfile)))
- zip.write(inWorkspace(os.path.join(spdDir, spdfile)), spdfile)
+ zip.write(inWorkspace(os.path.join(spdDir, spdfile)), os.path.join(spdDir,spdfile))
content.appendChild(man.createTextNode(lean(spdfile)))
packContents.appendChild(content)
diff --git a/Tools/Python/XmlRoutines.py b/Tools/Python/XmlRoutines.py
index 0345f4acc6..1757ea019c 100755
--- a/Tools/Python/XmlRoutines.py
+++ b/Tools/Python/XmlRoutines.py
@@ -73,6 +73,13 @@ def XmlParseFile (FileName):
except:
return xml.dom.minidom.parseString('<empty/>')
+def XmlParseString (Str):
+ """Parse an XML string into a DOM and return the DOM."""
+ try:
+ return xml.dom.minidom.parseString(Str)
+ except:
+ return xml.dom.minidom.parseString('<empty/>')
+
def XmlParseFileSection (FileName, Tag):
"""Parse a section of an XML file into a DOM(Document Object Model) and return the DOM."""
try: