+# # @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