## @file\r
# This file is for installed package information database operations\r
#\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2016, 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
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
+ #\r
+ # @param DpObjList: A distribution object list\r
+ # @return: True if distribution depex satisfied\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
+ PkgObj = DpObj.PackageSurfaceArea[PkgKey]\r
+ self.PkgsToBeDepend.append((PkgObj.Guid, PkgObj.Version))\r
+ else:\r
+ return False, DpObj\r
+\r
+ return True, DpObj\r
+\r
+\r
## Check whether a DP depex satisfied by current workspace \r
# (excluding the original distribution's packages to be replaced) for Replace\r
#\r
"Specify the UEFI Distribution Package file name to be replaced")\r
HLP_USE_GUIDED_PATHS = _(\r
"Install packages to the following directory path by default: <PackageName>_<PACKAGE_GUID>_<PACKAGE_VERSION>")\r
+HLP_TEST_INSTALL = _(\r
+ "Specify the UEFI Distribution Package filenames to install")\r
+\r
+MSG_TEST_INSTALL_PASS = _("All distribution package file are satisfied for dependence check.")\r
+MSG_TEST_INSTALL_FAIL = _("NOT all distribution package file are satisfied for dependence check.")\r
--- /dev/null
+# # @file\r
+# Test Install distribution package\r
+#\r
+# Copyright (c) 2016, 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
+# distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+"""\r
+Test Install multiple distribution package\r
+"""\r
+# #\r
+# Import Modules\r
+#\r
+from Library import GlobalData\r
+import Logger.Log as Logger\r
+from Logger import StringTable as ST\r
+import Logger.ToolError as TE\r
+from Core.DependencyRules import DependencyRules\r
+from InstallPkg import UnZipDp\r
+\r
+import shutil\r
+from traceback import format_exc\r
+from platform import python_version\r
+from sys import platform\r
+\r
+# # Tool entrance method\r
+#\r
+# This method mainly dispatch specific methods per the command line options.\r
+# If no error found, return zero value so the caller of this tool can know\r
+# if it's executed successfully or not.\r
+#\r
+# @param Options: command Options\r
+#\r
+def Main(Options=None):\r
+ ContentZipFile, DistFile = None, None\r
+ ReturnCode = 0\r
+\r
+ try:\r
+ DataBase = GlobalData.gDB\r
+ WorkspaceDir = GlobalData.gWORKSPACE\r
+ if not Options.DistFiles:\r
+ Logger.Error("TestInstallPkg", TE.OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
+\r
+ DistPkgList = []\r
+ for DistFile in Options.DistFiles:\r
+ DistPkg, ContentZipFile, __, DistFile = UnZipDp(WorkspaceDir, DistFile)\r
+ DistPkgList.append(DistPkg)\r
+\r
+ #\r
+ # check dependency\r
+ #\r
+ Dep = DependencyRules(DataBase)\r
+ Result = True\r
+ DpObj = None\r
+ try:\r
+ Result, DpObj = Dep.CheckTestInstallPdDepexSatisfied(DistPkgList)\r
+ except:\r
+ Result = False\r
+\r
+ if Result:\r
+ Logger.Quiet(ST.MSG_TEST_INSTALL_PASS)\r
+ else:\r
+ Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL)\r
+\r
+ except TE.FatalError, XExcept:\r
+ ReturnCode = XExcept.args[0]\r
+ if Logger.GetLevel() <= Logger.DEBUG_9:\r
+ Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
+\r
+ except Exception, x:\r
+ ReturnCode = TE.CODE_ERROR\r
+ Logger.Error(\r
+ "\nTestInstallPkg",\r
+ TE.CODE_ERROR,\r
+ ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.DistFiles,\r
+ ExtraData=ST.MSG_SEARCH_FOR_HELP,\r
+ RaiseError=False\r
+ )\r
+ Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
+\r
+ finally:\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
+ shutil.rmtree(GlobalData.gUNPACK_DIR)\r
+ GlobalData.gUNPACK_DIR = None\r
+ Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)\r
+ if ReturnCode == 0:\r
+ Logger.Quiet(ST.MSG_FINISH)\r
+ return ReturnCode\r
+\r
import RmPkg\r
import InventoryWs\r
import ReplacePkg\r
+import TestInstall\r
from Library.Misc import GetWorkspace\r
from Library import GlobalData\r
from Core.IpiDb import IpiDatabase\r
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_I_R_EXCLUSIVE)\r
elif Opt.PackFileToCreate and Opt.PackFileToRemove:\r
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_C_R_EXCLUSIVE)\r
+ elif Opt.TestDistFiles and (Opt.PackFileToCreate or Opt.PackFileToInstall \\r
+ or Opt.PackFileToRemove or Opt.PackFileToReplace):\r
+ Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_C_R_EXCLUSIVE)\r
\r
if Opt.CustomPath and Opt.UseGuidedPkgPath:\r
Logger.Warn("UPT", ST.WARN_CUSTOMPATH_OVERRIDE_USEGUIDEDPATH)\r
\r
Parser.add_option("--use-guided-paths", action="store_true", dest="Use_Guided_Paths", help=ST.HLP_USE_GUIDED_PATHS)\r
\r
+ Parser.add_option("-j", "--test-install", action="append", type="string",\r
+ dest="Test_Install_Distribution_Package_Files", help=ST.HLP_TEST_INSTALL)\r
+\r
Opt = Parser.parse_args()[0]\r
\r
Var2Var = [\r
("PackFileToReplace", Opt.Replace_Distribution_Package_File),\r
("PackFileToBeReplaced", Opt.Original_Distribution_Package_File),\r
("UseGuidedPkgPath", Opt.Use_Guided_Paths),\r
+ ("TestDistFiles", Opt.Test_Install_Distribution_Package_Files)\r
]\r
\r
for Var in Var2Var:\r
Opt.PackFileToReplace = AbsPath\r
RunModule = ReplacePkg.Main\r
\r
+ elif Opt.Test_Install_Distribution_Package_Files:\r
+ for Dist in Opt.Test_Install_Distribution_Package_Files:\r
+ if not Dist.endswith('.dist'):\r
+ Logger.Error("TestInstall", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Dist)\r
+\r
+ setattr(Opt, 'DistFiles', Opt.Test_Install_Distribution_Package_Files)\r
+ RunModule = TestInstall.Main\r
+\r
else:\r
Parser.print_usage()\r
return OPTION_MISSING\r