]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/UPT/TestInstall.py
BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
[mirror_edk2.git] / BaseTools / Source / Python / UPT / TestInstall.py
CommitLineData
6cf99034
HC
1# # @file\r
2# Test Install distribution package\r
3#\r
4# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5#\r
6# This program and the accompanying materials are licensed and made available\r
7# under the terms and conditions of the BSD License which accompanies this\r
8# distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14"""\r
15Test Install multiple distribution package\r
16"""\r
17# #\r
18# Import Modules\r
19#\r
20from Library import GlobalData\r
21import Logger.Log as Logger\r
22from Logger import StringTable as ST\r
23import Logger.ToolError as TE\r
24from Core.DependencyRules import DependencyRules\r
25from InstallPkg import UnZipDp\r
26\r
27import shutil\r
28from traceback import format_exc\r
29from platform import python_version\r
30from sys import platform\r
31\r
32# # Tool entrance method\r
33#\r
34# This method mainly dispatch specific methods per the command line options.\r
35# If no error found, return zero value so the caller of this tool can know\r
36# if it's executed successfully or not.\r
37#\r
38# @param Options: command Options\r
39#\r
40def Main(Options=None):\r
41 ContentZipFile, DistFile = None, None\r
42 ReturnCode = 0\r
43\r
44 try:\r
45 DataBase = GlobalData.gDB\r
46 WorkspaceDir = GlobalData.gWORKSPACE\r
47 if not Options.DistFiles:\r
48 Logger.Error("TestInstallPkg", TE.OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
49\r
50 DistPkgList = []\r
51 for DistFile in Options.DistFiles:\r
52 DistPkg, ContentZipFile, __, DistFile = UnZipDp(WorkspaceDir, DistFile)\r
53 DistPkgList.append(DistPkg)\r
54\r
55 #\r
56 # check dependency\r
57 #\r
58 Dep = DependencyRules(DataBase)\r
59 Result = True\r
60 DpObj = None\r
61 try:\r
62 Result, DpObj = Dep.CheckTestInstallPdDepexSatisfied(DistPkgList)\r
63 except:\r
64 Result = False\r
65\r
66 if Result:\r
67 Logger.Quiet(ST.MSG_TEST_INSTALL_PASS)\r
68 else:\r
69 Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL)\r
70\r
71 except TE.FatalError, XExcept:\r
72 ReturnCode = XExcept.args[0]\r
73 if Logger.GetLevel() <= Logger.DEBUG_9:\r
74 Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
75\r
76 except Exception, x:\r
77 ReturnCode = TE.CODE_ERROR\r
78 Logger.Error(\r
79 "\nTestInstallPkg",\r
80 TE.CODE_ERROR,\r
81 ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.DistFiles,\r
82 ExtraData=ST.MSG_SEARCH_FOR_HELP,\r
83 RaiseError=False\r
84 )\r
85 Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
86\r
87 finally:\r
88 Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED)\r
89 if DistFile:\r
90 DistFile.Close()\r
91 if ContentZipFile:\r
92 ContentZipFile.Close()\r
93 if GlobalData.gUNPACK_DIR:\r
94 shutil.rmtree(GlobalData.gUNPACK_DIR)\r
95 GlobalData.gUNPACK_DIR = None\r
96 Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)\r
97 if ReturnCode == 0:\r
98 Logger.Quiet(ST.MSG_FINISH)\r
99 return ReturnCode\r
100\r