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
This commit is contained in:
@ -57,18 +57,22 @@ class Database:
|
|||||||
self.lock.close()
|
self.lock.close()
|
||||||
os.unlink(self.lockfile)
|
os.unlink(self.lockfile)
|
||||||
|
|
||||||
def HasPackage(self, spdString):
|
def HasPackage(self, (guid, version)):
|
||||||
"""Return true iff this package is already installed."""
|
"""Return true iff this package is already installed."""
|
||||||
spdHeader = XmlParseStringSection(spdString, "SpdHeader")
|
if version == "":
|
||||||
guid = XmlElement(spdHeader, "/SpdHeader/GuidValue")
|
# Look for the guid.
|
||||||
version = XmlElement(spdHeader, "/SpdHeader/Version")
|
for (g, v) in self.installedPackages.keys():
|
||||||
|
if g == guid:
|
||||||
|
return True
|
||||||
return self.installedPackages.has_key((guid, version))
|
return self.installedPackages.has_key((guid, version))
|
||||||
|
|
||||||
def HasPlatform(self, fpdString):
|
def HasPlatform(self, (guid, version)):
|
||||||
"""Return true iff this platform is already installed."""
|
"""Return true iff this platform is already installed."""
|
||||||
fpdHeader = XmlParseStringSection(fpdString, "PlatformHeader")
|
if version == "":
|
||||||
guid = XmlElement(fpdHeader, "/PlatformHeader/GuidValue")
|
# Look for the guid.
|
||||||
version = XmlElement(fpdHeader, "/PlatformHeader/Version")
|
for (g, v) in self.installedPlatforms.keys():
|
||||||
|
if g == guid:
|
||||||
|
return True
|
||||||
return self.installedPlatforms.has_key((guid, version))
|
return self.installedPlatforms.has_key((guid, version))
|
||||||
|
|
||||||
def HasFar(self, farguid):
|
def HasFar(self, farguid):
|
||||||
@ -113,6 +117,20 @@ def ExtractFile(zip, file, workspaceLocation=""):
|
|||||||
f.write(zip.read(file))
|
f.write(zip.read(file))
|
||||||
f.close()
|
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=""):
|
def InstallFar(farfile, workspaceLocation=""):
|
||||||
|
|
||||||
far = zipfile.ZipFile(farfile, "r")
|
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.
|
# 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
|
# Check the packages
|
||||||
for farPackage in XmlList(manifest, "/FrameworkArchiveManifest/FarPackageList/FarPackage/FarFilename"):
|
for farPackage in XmlList(manifest, "/FrameworkArchiveManifest/FarPackageList/FarPackage/FarFilename"):
|
||||||
spdfile = str(XmlElementData(farPackage))
|
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
|
print "Error: This package is already installed: ", spdfile
|
||||||
installError = True
|
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
|
# Check the platforms
|
||||||
for farPlatform in XmlList(manifest, "/FrameworkArchiveManifest/FarPlatformList/FarPlatform/FarFilename"):
|
for farPlatform in XmlList(manifest, "/FrameworkArchiveManifest/FarPlatformList/FarPlatform/FarFilename"):
|
||||||
fpdfile = str(XmlElementData(farPlatform))
|
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
|
print "Error: This platform is already installed: ", fpdfile
|
||||||
installError = True
|
installError = True
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ def makeFar(files, farname):
|
|||||||
|
|
||||||
for spdfile in filelist:
|
for spdfile in filelist:
|
||||||
content = farFileNode(man, inWorkspace(os.path.join(spdDir, spdfile)))
|
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)))
|
content.appendChild(man.createTextNode(lean(spdfile)))
|
||||||
packContents.appendChild(content)
|
packContents.appendChild(content)
|
||||||
|
|
||||||
|
@ -73,6 +73,13 @@ def XmlParseFile (FileName):
|
|||||||
except:
|
except:
|
||||||
return xml.dom.minidom.parseString('<empty/>')
|
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):
|
def XmlParseFileSection (FileName, Tag):
|
||||||
"""Parse a section of an XML file into a DOM(Document Object Model) and return the DOM."""
|
"""Parse a section of an XML file into a DOM(Document Object Model) and return the DOM."""
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user