2 # Test Install distribution package
4 # Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
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
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.
15 Test Install multiple distribution package
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
28 from traceback
import format_exc
29 from platform
import python_version
30 from sys
import platform
32 # # Tool entrance method
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.
38 # @param Options: command Options
40 def Main(Options
=None):
41 ContentZipFile
, DistFile
= None, None
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
)
51 for DistFile
in Options
.DistFiles
:
52 DistPkg
, ContentZipFile
, __
, DistFile
= UnZipDp(WorkspaceDir
, DistFile
)
53 DistPkgList
.append(DistPkg
)
58 Dep
= DependencyRules(DataBase
)
62 Result
, DpObj
= Dep
.CheckTestInstallPdDepexSatisfied(DistPkgList
)
67 Logger
.Quiet(ST
.MSG_TEST_INSTALL_PASS
)
69 Logger
.Quiet(ST
.MSG_TEST_INSTALL_FAIL
)
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())
77 ReturnCode
= TE
.CODE_ERROR
81 ST
.ERR_UNKNOWN_FATAL_INSTALL_ERR
% Options
.DistFiles
,
82 ExtraData
=ST
.MSG_SEARCH_FOR_HELP
,
85 Logger
.Quiet(ST
.MSG_PYTHON_ON
% (python_version(), platform
) + format_exc())
88 Logger
.Quiet(ST
.MSG_REMOVE_TEMP_FILE_STARTED
)
92 ContentZipFile
.Close()
93 for TempDir
in GlobalData
.gUNPACK_DIR
:
94 shutil
.rmtree(TempDir
)
95 GlobalData
.gUNPACK_DIR
= []
96 Logger
.Quiet(ST
.MSG_REMOVE_TEMP_FILE_DONE
)
98 Logger
.Quiet(ST
.MSG_FINISH
)