# @param object: Inherited from object class\r
#\r
class DependencyRules(object):\r
- def __init__(self, Datab):\r
+ def __init__(self, Datab, ToBeInstalledPkgList=None):\r
self.IpiDb = Datab\r
self.WsPkgList = GetWorkspacePackage()\r
self.WsModuleList = GetWorkspaceModule()\r
- self.PkgsToBeDepend = []\r
+\r
+ self.PkgsToBeDepend = [(PkgInfo[1], PkgInfo[2]) for PkgInfo in self.WsPkgList]\r
+\r
+ # Add package info from the DIST to be installed.\r
+ self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstalledPkgList))\r
\r
+ def GenToBeInstalledPkgList(self, ToBeInstalledPkgList):\r
+ RtnList = []\r
+ for Dist in ToBeInstalledPkgList:\r
+ for Package in Dist.PackageSurfaceArea:\r
+ RtnList.append((Package[0], Package[1]))\r
+\r
+ return RtnList\r
+\r
## Check whether a module exists by checking the Guid+Version+Name+Path combination\r
#\r
# @param Guid: Guid of a module\r
# False else\r
#\r
def CheckInstallDpDepexSatisfied(self, DpObj):\r
- self.PkgsToBeDepend = [(PkgInfo[1], PkgInfo[2]) for PkgInfo in self.WsPkgList]\r
return self.CheckDpDepexSatisfied(DpObj)\r
\r
# # Check whether multiple DP depex satisfied by current workspace for Install\r
# False else\r
#\r
def CheckTestInstallPdDepexSatisfied(self, DpObjList):\r
- self.PkgsToBeDepend = [(PkgInfo[1], PkgInfo[2]) for PkgInfo in self.WsPkgList]\r
for DpObj in DpObjList:\r
if self.CheckDpDepexSatisfied(DpObj):\r
for PkgKey in DpObj.PackageSurfaceArea.keys():\r
# Using TokenSpaceGuidValue and Token to obtain PcdName from DEC file\r
#\r
def ObtainPcdName(Packages, TokenSpaceGuidValue, Token):\r
+ TokenSpaceGuidName = ''\r
+ PcdCName = ''\r
+ TokenSpaceGuidNameFound = False\r
+\r
for PackageDependency in Packages:\r
#\r
# Generate generic comment\r
Guid = PackageDependency.GetGuid()\r
Version = PackageDependency.GetVersion()\r
\r
+ Path = None\r
#\r
# find package path/name\r
# \r
Path = PkgInfo[3]\r
break\r
\r
- DecFile = None\r
- if Path not in GlobalData.gPackageDict:\r
- DecFile = Dec(Path)\r
- GlobalData.gPackageDict[Path] = DecFile\r
- else:\r
- DecFile = GlobalData.gPackageDict[Path]\r
-\r
- DecGuidsDict = DecFile.GetGuidSectionObject().ValueDict\r
- DecPcdsDict = DecFile.GetPcdSectionObject().ValueDict\r
-\r
- TokenSpaceGuidName = ''\r
- PcdCName = ''\r
- TokenSpaceGuidNameFound = False\r
-\r
- #\r
- # Get TokenSpaceGuidCName from Guids section \r
- #\r
- for GuidKey in DecGuidsDict:\r
- GuidList = DecGuidsDict[GuidKey]\r
- for GuidItem in GuidList:\r
- if TokenSpaceGuidValue.upper() == GuidItem.GuidString.upper():\r
- TokenSpaceGuidName = GuidItem.GuidCName\r
- TokenSpaceGuidNameFound = True\r
+ # The dependency package in workspace\r
+ if Path:\r
+ DecFile = None\r
+ if Path not in GlobalData.gPackageDict:\r
+ DecFile = Dec(Path)\r
+ GlobalData.gPackageDict[Path] = DecFile\r
+ else:\r
+ DecFile = GlobalData.gPackageDict[Path]\r
+\r
+ DecGuidsDict = DecFile.GetGuidSectionObject().ValueDict\r
+ DecPcdsDict = DecFile.GetPcdSectionObject().ValueDict\r
+\r
+ TokenSpaceGuidName = ''\r
+ PcdCName = ''\r
+ TokenSpaceGuidNameFound = False\r
+\r
+ #\r
+ # Get TokenSpaceGuidCName from Guids section\r
+ #\r
+ for GuidKey in DecGuidsDict:\r
+ GuidList = DecGuidsDict[GuidKey]\r
+ for GuidItem in GuidList:\r
+ if TokenSpaceGuidValue.upper() == GuidItem.GuidString.upper():\r
+ TokenSpaceGuidName = GuidItem.GuidCName\r
+ TokenSpaceGuidNameFound = True\r
+ break\r
+ if TokenSpaceGuidNameFound:\r
break\r
- if TokenSpaceGuidNameFound:\r
- break\r
- #\r
- # Retrieve PcdCName from Pcds Section\r
- #\r
- for PcdKey in DecPcdsDict:\r
- PcdList = DecPcdsDict[PcdKey]\r
- for PcdItem in PcdList:\r
- if TokenSpaceGuidName == PcdItem.TokenSpaceGuidCName and Token == PcdItem.TokenValue:\r
- PcdCName = PcdItem.TokenCName\r
- return TokenSpaceGuidName, PcdCName\r
+ #\r
+ # Retrieve PcdCName from Pcds Section\r
+ #\r
+ for PcdKey in DecPcdsDict:\r
+ PcdList = DecPcdsDict[PcdKey]\r
+ for PcdItem in PcdList:\r
+ if TokenSpaceGuidName == PcdItem.TokenSpaceGuidCName and Token == PcdItem.TokenValue:\r
+ PcdCName = PcdItem.TokenCName\r
+ return TokenSpaceGuidName, PcdCName\r
+\r
+ # The dependency package in ToBeInstalledDist\r
+ else:\r
+ for Dist in GlobalData.gTO_BE_INSTALLED_DIST_LIST:\r
+ for Package in Dist.PackageSurfaceArea.values():\r
+ if Guid == Package.Guid:\r
+ for GuidItem in Package.GuidList:\r
+ if TokenSpaceGuidValue.upper() == GuidItem.Guid.upper():\r
+ TokenSpaceGuidName = GuidItem.CName\r
+ TokenSpaceGuidNameFound = True\r
+ break\r
+ for PcdItem in Package.PcdList:\r
+ if TokenSpaceGuidName == PcdItem.TokenSpaceGuidCName and Token == PcdItem.Token:\r
+ PcdCName = PcdItem.CName\r
+ return TokenSpaceGuidName, PcdCName\r
\r
return TokenSpaceGuidName, PcdCName\r
\r
## @file\r
# Install distribution package.\r
#\r
-# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available \r
# under the terms and conditions of the BSD License which accompanies this \r
#\r
# UnZipDp\r
#\r
-def UnZipDp(WorkspaceDir, DpPkgFileName):\r
+def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):\r
ContentZipFile = None\r
Logger.Quiet(ST.MSG_UZIP_PARSE_XML)\r
DistFile = PackageFile(DpPkgFileName)\r
\r
DpDescFileName, ContentFileName = GetDPFile(DistFile.GetZipFile())\r
\r
- GlobalData.gUNPACK_DIR = os.path.normpath(os.path.join(WorkspaceDir, ".tmp"))\r
- DistPkgFile = DistFile.UnpackFile(DpDescFileName,\r
- os.path.normpath(os.path.join(GlobalData.gUNPACK_DIR, DpDescFileName)))\r
+ TempDir = os.path.normpath(os.path.join(WorkspaceDir, "Conf/.tmp%s" % str(Index)))\r
+ GlobalData.gUNPACK_DIR.append(TempDir)\r
+ DistPkgFile = DistFile.UnpackFile(DpDescFileName, os.path.normpath(os.path.join(TempDir, DpDescFileName)))\r
if not DistPkgFile:\r
Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_FILE_BROKEN %DpDescFileName)\r
\r
#\r
# unzip contents.zip file\r
#\r
- ContentFile = DistFile.UnpackFile(ContentFileName,\r
- os.path.normpath(os.path.join(GlobalData.gUNPACK_DIR, ContentFileName)))\r
+ ContentFile = DistFile.UnpackFile(ContentFileName, os.path.normpath(os.path.join(TempDir, ContentFileName)))\r
if not ContentFile:\r
Logger.Error("InstallPkg", FILE_NOT_FOUND,\r
ST.ERR_FILE_BROKEN % ContentFileName)\r
\r
- FilePointer = __FileHookOpen__(ContentFile, "rb")\r
- #\r
- # Assume no archive comment.\r
- #\r
- FilePointer.seek(0, SEEK_SET)\r
- FilePointer.seek(0, SEEK_END)\r
#\r
# Get file size\r
# \r
- FileSize = FilePointer.tell()\r
- FilePointer.close()\r
+ FileSize = os.path.getsize(ContentFile)\r
\r
if FileSize != 0: \r
ContentZipFile = PackageFile(ContentFile)\r
PackagePath = Path\r
Package = DistPkg.PackageSurfaceArea[Guid, Version, Path]\r
Logger.Info(ST.MSG_INSTALL_PACKAGE % Package.GetName())\r
- if Dep.CheckPackageExists(Guid, Version):\r
- Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version))\r
+# if Dep.CheckPackageExists(Guid, Version):\r
+# Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version))\r
if Options.UseGuidedPkgPath:\r
GuidedPkgPath = "%s_%s_%s" % (Package.GetName(), Guid, Version)\r
NewPackagePath = InstallNewPackage(WorkspaceDir, GuidedPkgPath, Options.CustomPath)\r
# @param Options: command Options\r
#\r
def Main(Options = None):\r
- ContentZipFile, DistFile = None, None\r
-\r
try:\r
DataBase = GlobalData.gDB\r
WorkspaceDir = GlobalData.gWORKSPACE\r
if not Options.PackageFile:\r
Logger.Error("InstallPkg", OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
\r
- #\r
- # unzip dist.pkg file\r
- #\r
- DistPkg, ContentZipFile, DpPkgFileName, DistFile = UnZipDp(WorkspaceDir, Options.PackageFile)\r
+ # Get all Dist Info\r
+ DistInfoList = []\r
+ DistPkgList = []\r
+ Index = 1\r
+ for ToBeInstalledDist in Options.PackageFile:\r
+ #\r
+ # unzip dist.pkg file\r
+ #\r
+ DistInfoList.append(UnZipDp(WorkspaceDir, ToBeInstalledDist, Index))\r
+ DistPkgList.append(DistInfoList[-1][0])\r
+ Index += 1\r
\r
- #\r
- # check dependency\r
- #\r
- Dep = DependencyRules(DataBase)\r
- CheckInstallDpx(Dep, DistPkg)\r
+ #\r
+ # Add dist\r
+ #\r
+ GlobalData.gTO_BE_INSTALLED_DIST_LIST.append(DistInfoList[-1][0])\r
\r
- #\r
- # Install distribution\r
- #\r
- InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir, DataBase)\r
+ # Check for dependency\r
+ Dep = DependencyRules(DataBase, DistPkgList)\r
+\r
+ for ToBeInstalledDist in DistInfoList:\r
+ CheckInstallDpx(Dep, ToBeInstalledDist[0], ToBeInstalledDist[2])\r
+\r
+ #\r
+ # Install distribution\r
+ #\r
+ InstallDp(ToBeInstalledDist[0], ToBeInstalledDist[2], ToBeInstalledDist[1],\r
+ Options, Dep, WorkspaceDir, DataBase)\r
ReturnCode = 0\r
\r
except FatalError, XExcept:\r
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),\r
platform) + format_exc())\r
finally:\r
- if ReturnCode != UPT_ALREADY_INSTALLED_ERROR:\r
- Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED)\r
- if DistFile:\r
- DistFile.Close()\r
- if ContentZipFile:\r
- ContentZipFile.Close()\r
- if GlobalData.gUNPACK_DIR:\r
- rmtree(GlobalData.gUNPACK_DIR)\r
- GlobalData.gUNPACK_DIR = None\r
- Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)\r
+ Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED)\r
+ for ToBeInstalledDist in DistInfoList:\r
+ if ToBeInstalledDist[3]:\r
+ ToBeInstalledDist[3].Close()\r
+ if ToBeInstalledDist[1]:\r
+ ToBeInstalledDist[1].Close()\r
+ for TempDir in GlobalData.gUNPACK_DIR:\r
+ rmtree(TempDir)\r
+ GlobalData.gUNPACK_DIR = []\r
+ Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)\r
if ReturnCode == 0:\r
Logger.Quiet(ST.MSG_FINISH)\r
return ReturnCode\r
# @param Dep: the DependencyRules instance that used to check dependency\r
# @param DistPkg: the distribution object\r
#\r
-def CheckInstallDpx(Dep, DistPkg):\r
+def CheckInstallDpx(Dep, DistPkg, DistPkgFileName):\r
#\r
# Check distribution package installed or not\r
#\r
if Dep.CheckDpExists(DistPkg.Header.GetGuid(),\r
DistPkg.Header.GetVersion()):\r
- Logger.Error("InstallPkg", UPT_ALREADY_INSTALLED_ERROR,\r
- ST.WRN_DIST_PKG_INSTALLED)\r
+ Logger.Error("InstallPkg",\r
+ UPT_ALREADY_INSTALLED_ERROR,\r
+ ST.WRN_DIST_PKG_INSTALLED % os.path.basename(DistPkgFileName))\r
#\r
# Check distribution dependency (all module dependency should be\r
# satisfied)\r
## @file\r
# This file is used to define common static strings and global data used by UPT\r
#\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available \r
# under the terms and conditions of the BSD License which accompanies this \r
#\r
# Used to specify the temp directory to hold the unpacked distribution files\r
#\r
-gUNPACK_DIR = None\r
+gUNPACK_DIR = []\r
\r
#\r
# Flag used to mark whether the INF file is Binary INF or not.\r
# {FilePath: FileObj}\r
#\r
gLIBINSTANCEDICT = {}\r
+\r
+#\r
+# Store the list of DIST\r
+#\r
+gTO_BE_INSTALLED_DIST_LIST = []\r
## @file\r
# This file is used to define strings used in the UPT tool\r
#\r
-# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available \r
# under the terms and conditions of the BSD License which accompanies this \r
WRN_FILE_EXISTED = _("This file already exists: %s")\r
WRN_FILE_NOT_OVERWRITTEN = \\r
_("This file already exist and cannot be overwritten: %s")\r
-WRN_DIST_PKG_INSTALLED = _("This distribution package has previously been installed.")\r
+WRN_DIST_PKG_INSTALLED = _("This distribution package %s has previously been installed.")\r
WRN_DIST_NOT_FOUND = _(\r
"Distribution is not found at location %s")\r
WRN_MULTI_PCD_RANGES = _(\r
## @file\r
# Replace distribution package.\r
#\r
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available \r
# under the terms and conditions of the BSD License which accompanies this \r
DistFile.Close()\r
if ContentZipFile:\r
ContentZipFile.Close()\r
- if GlobalData.gUNPACK_DIR:\r
- rmtree(GlobalData.gUNPACK_DIR)\r
- GlobalData.gUNPACK_DIR = None\r
+ for TempDir in GlobalData.gUNPACK_DIR:\r
+ rmtree(TempDir)\r
+ GlobalData.gUNPACK_DIR = []\r
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE) \r
\r
if ReturnCode == 0:\r
# # @file\r
# Test Install distribution package\r
#\r
-# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available\r
# under the terms and conditions of the BSD License which accompanies this\r
DistFile.Close()\r
if ContentZipFile:\r
ContentZipFile.Close()\r
- if GlobalData.gUNPACK_DIR:\r
- shutil.rmtree(GlobalData.gUNPACK_DIR)\r
- GlobalData.gUNPACK_DIR = None\r
+ for TempDir in GlobalData.gUNPACK_DIR:\r
+ shutil.rmtree(TempDir)\r
+ GlobalData.gUNPACK_DIR = []\r
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)\r
if ReturnCode == 0:\r
Logger.Quiet(ST.MSG_FINISH)\r
\r
Parser.add_option("-q", "--quiet", action="store_true", dest="opt_quiet", help=ST.HLP_RETURN_AND_DISPLAY)\r
\r
- Parser.add_option("-i", "--install", action="store", type="string", dest="Install_Distribution_Package_File",\r
+ Parser.add_option("-i", "--install", action="append", type="string", dest="Install_Distribution_Package_File",\r
help=ST.HLP_SPECIFY_PACKAGE_NAME_INSTALL)\r
\r
Parser.add_option("-c", "--create", action="store", type="string", dest="Create_Distribution_Package_File",\r
RunModule = MkPkg.Main\r
\r
elif Opt.PackFileToInstall:\r
- if not Opt.PackFileToInstall.endswith('.dist'):\r
- Logger.Error("InstallPkg", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Opt.PackFileToInstall)\r
-\r
- AbsPath = GetFullPathDist(Opt.PackFileToInstall, WorkspaceDir)\r
- if not AbsPath:\r
- Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_INSTALL_DIST_NOT_FOUND % Opt.PackFileToInstall)\r
+ AbsPath = []\r
+ for Item in Opt.PackFileToInstall:\r
+ if not Item.endswith('.dist'):\r
+ Logger.Error("InstallPkg", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Item)\r
+\r
+ AbsPath.append(GetFullPathDist(Item, WorkspaceDir))\r
+ if not AbsPath:\r
+ Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_INSTALL_DIST_NOT_FOUND % Item)\r
\r
Opt.PackFileToInstall = AbsPath\r
setattr(Opt, 'PackageFile', Opt.PackFileToInstall)\r