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