2 # Test Install distribution package
4 # Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
9 Test Install multiple distribution package
14 from Library
import GlobalData
15 import Logger
.Log
as Logger
16 from Logger
import StringTable
as ST
17 import Logger
.ToolError
as TE
18 from Core
.DependencyRules
import DependencyRules
19 from InstallPkg
import UnZipDp
22 from traceback
import format_exc
23 from platform
import python_version
24 from sys
import platform
26 # # Tool entrance method
28 # This method mainly dispatch specific methods per the command line options.
29 # If no error found, return zero value so the caller of this tool can know
30 # if it's executed successfully or not.
32 # @param Options: command Options
34 def Main(Options
=None):
35 ContentZipFile
, DistFile
= None, None
39 DataBase
= GlobalData
.gDB
40 WorkspaceDir
= GlobalData
.gWORKSPACE
41 if not Options
.DistFiles
:
42 Logger
.Error("TestInstallPkg", TE
.OPTION_MISSING
, ExtraData
=ST
.ERR_SPECIFY_PACKAGE
)
45 for DistFile
in Options
.DistFiles
:
46 DistPkg
, ContentZipFile
, __
, DistFile
= UnZipDp(WorkspaceDir
, DistFile
)
47 DistPkgList
.append(DistPkg
)
52 Dep
= DependencyRules(DataBase
)
56 Result
, DpObj
= Dep
.CheckTestInstallPdDepexSatisfied(DistPkgList
)
61 Logger
.Quiet(ST
.MSG_TEST_INSTALL_PASS
)
63 Logger
.Quiet(ST
.MSG_TEST_INSTALL_FAIL
)
65 except TE
.FatalError
as XExcept
:
66 ReturnCode
= XExcept
.args
[0]
67 if Logger
.GetLevel() <= Logger
.DEBUG_9
:
68 Logger
.Quiet(ST
.MSG_PYTHON_ON
% (python_version(), platform
) + format_exc())
70 except Exception as x
:
71 ReturnCode
= TE
.CODE_ERROR
75 ST
.ERR_UNKNOWN_FATAL_INSTALL_ERR
% Options
.DistFiles
,
76 ExtraData
=ST
.MSG_SEARCH_FOR_HELP
% ST
.MSG_EDKII_MAIL_ADDR
,
79 Logger
.Quiet(ST
.MSG_PYTHON_ON
% (python_version(), platform
) + format_exc())
82 Logger
.Quiet(ST
.MSG_REMOVE_TEMP_FILE_STARTED
)
86 ContentZipFile
.Close()
87 for TempDir
in GlobalData
.gUNPACK_DIR
:
88 shutil
.rmtree(TempDir
)
89 GlobalData
.gUNPACK_DIR
= []
90 Logger
.Quiet(ST
.MSG_REMOVE_TEMP_FILE_DONE
)
92 Logger
.Quiet(ST
.MSG_FINISH
)