mirror of https://github.com/acidanthera/audk.git
BaseTool/UPT: Add Test Install
Add a new function to test if a DIST file list one by one to see if they can meet the requirement of Dependency. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
parent
17f3e942bc
commit
6cf9903481
|
@ -1,7 +1,7 @@
|
|||
## @file
|
||||
# This file is for installed package information database operations
|
||||
#
|
||||
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
|
@ -184,6 +184,25 @@ class DependencyRules(object):
|
|||
self.PkgsToBeDepend = [(PkgInfo[1], PkgInfo[2]) for PkgInfo in self.WsPkgList]
|
||||
return self.CheckDpDepexSatisfied(DpObj)
|
||||
|
||||
# # Check whether multiple DP depex satisfied by current workspace for Install
|
||||
#
|
||||
# @param DpObjList: A distribution object list
|
||||
# @return: True if distribution depex satisfied
|
||||
# False else
|
||||
#
|
||||
def CheckTestInstallPdDepexSatisfied(self, DpObjList):
|
||||
self.PkgsToBeDepend = [(PkgInfo[1], PkgInfo[2]) for PkgInfo in self.WsPkgList]
|
||||
for DpObj in DpObjList:
|
||||
if self.CheckDpDepexSatisfied(DpObj):
|
||||
for PkgKey in DpObj.PackageSurfaceArea.keys():
|
||||
PkgObj = DpObj.PackageSurfaceArea[PkgKey]
|
||||
self.PkgsToBeDepend.append((PkgObj.Guid, PkgObj.Version))
|
||||
else:
|
||||
return False, DpObj
|
||||
|
||||
return True, DpObj
|
||||
|
||||
|
||||
## Check whether a DP depex satisfied by current workspace
|
||||
# (excluding the original distribution's packages to be replaced) for Replace
|
||||
#
|
||||
|
|
|
@ -858,3 +858,8 @@ HLP_SPECIFY_PACKAGE_NAME_TO_BE_REPLACED = _(
|
|||
"Specify the UEFI Distribution Package file name to be replaced")
|
||||
HLP_USE_GUIDED_PATHS = _(
|
||||
"Install packages to the following directory path by default: <PackageName>_<PACKAGE_GUID>_<PACKAGE_VERSION>")
|
||||
HLP_TEST_INSTALL = _(
|
||||
"Specify the UEFI Distribution Package filenames to install")
|
||||
|
||||
MSG_TEST_INSTALL_PASS = _("All distribution package file are satisfied for dependence check.")
|
||||
MSG_TEST_INSTALL_FAIL = _("NOT all distribution package file are satisfied for dependence check.")
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
# # @file
|
||||
# Test Install distribution package
|
||||
#
|
||||
# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
"""
|
||||
Test Install multiple distribution package
|
||||
"""
|
||||
# #
|
||||
# Import Modules
|
||||
#
|
||||
from Library import GlobalData
|
||||
import Logger.Log as Logger
|
||||
from Logger import StringTable as ST
|
||||
import Logger.ToolError as TE
|
||||
from Core.DependencyRules import DependencyRules
|
||||
from InstallPkg import UnZipDp
|
||||
|
||||
import shutil
|
||||
from traceback import format_exc
|
||||
from platform import python_version
|
||||
from sys import platform
|
||||
|
||||
# # Tool entrance method
|
||||
#
|
||||
# This method mainly dispatch specific methods per the command line options.
|
||||
# If no error found, return zero value so the caller of this tool can know
|
||||
# if it's executed successfully or not.
|
||||
#
|
||||
# @param Options: command Options
|
||||
#
|
||||
def Main(Options=None):
|
||||
ContentZipFile, DistFile = None, None
|
||||
ReturnCode = 0
|
||||
|
||||
try:
|
||||
DataBase = GlobalData.gDB
|
||||
WorkspaceDir = GlobalData.gWORKSPACE
|
||||
if not Options.DistFiles:
|
||||
Logger.Error("TestInstallPkg", TE.OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)
|
||||
|
||||
DistPkgList = []
|
||||
for DistFile in Options.DistFiles:
|
||||
DistPkg, ContentZipFile, __, DistFile = UnZipDp(WorkspaceDir, DistFile)
|
||||
DistPkgList.append(DistPkg)
|
||||
|
||||
#
|
||||
# check dependency
|
||||
#
|
||||
Dep = DependencyRules(DataBase)
|
||||
Result = True
|
||||
DpObj = None
|
||||
try:
|
||||
Result, DpObj = Dep.CheckTestInstallPdDepexSatisfied(DistPkgList)
|
||||
except:
|
||||
Result = False
|
||||
|
||||
if Result:
|
||||
Logger.Quiet(ST.MSG_TEST_INSTALL_PASS)
|
||||
else:
|
||||
Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL)
|
||||
|
||||
except TE.FatalError, XExcept:
|
||||
ReturnCode = XExcept.args[0]
|
||||
if Logger.GetLevel() <= Logger.DEBUG_9:
|
||||
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
|
||||
|
||||
except Exception, x:
|
||||
ReturnCode = TE.CODE_ERROR
|
||||
Logger.Error(
|
||||
"\nTestInstallPkg",
|
||||
TE.CODE_ERROR,
|
||||
ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.DistFiles,
|
||||
ExtraData=ST.MSG_SEARCH_FOR_HELP,
|
||||
RaiseError=False
|
||||
)
|
||||
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
|
||||
|
||||
finally:
|
||||
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED)
|
||||
if DistFile:
|
||||
DistFile.Close()
|
||||
if ContentZipFile:
|
||||
ContentZipFile.Close()
|
||||
if GlobalData.gUNPACK_DIR:
|
||||
shutil.rmtree(GlobalData.gUNPACK_DIR)
|
||||
GlobalData.gUNPACK_DIR = None
|
||||
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)
|
||||
if ReturnCode == 0:
|
||||
Logger.Quiet(ST.MSG_FINISH)
|
||||
return ReturnCode
|
||||
|
|
@ -46,6 +46,7 @@ import InstallPkg
|
|||
import RmPkg
|
||||
import InventoryWs
|
||||
import ReplacePkg
|
||||
import TestInstall
|
||||
from Library.Misc import GetWorkspace
|
||||
from Library import GlobalData
|
||||
from Core.IpiDb import IpiDatabase
|
||||
|
@ -69,6 +70,9 @@ def CheckConflictOption(Opt):
|
|||
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_I_R_EXCLUSIVE)
|
||||
elif Opt.PackFileToCreate and Opt.PackFileToRemove:
|
||||
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_C_R_EXCLUSIVE)
|
||||
elif Opt.TestDistFiles and (Opt.PackFileToCreate or Opt.PackFileToInstall \
|
||||
or Opt.PackFileToRemove or Opt.PackFileToReplace):
|
||||
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_C_R_EXCLUSIVE)
|
||||
|
||||
if Opt.CustomPath and Opt.UseGuidedPkgPath:
|
||||
Logger.Warn("UPT", ST.WARN_CUSTOMPATH_OVERRIDE_USEGUIDEDPATH)
|
||||
|
@ -146,6 +150,9 @@ def Main():
|
|||
|
||||
Parser.add_option("--use-guided-paths", action="store_true", dest="Use_Guided_Paths", help=ST.HLP_USE_GUIDED_PATHS)
|
||||
|
||||
Parser.add_option("-j", "--test-install", action="append", type="string",
|
||||
dest="Test_Install_Distribution_Package_Files", help=ST.HLP_TEST_INSTALL)
|
||||
|
||||
Opt = Parser.parse_args()[0]
|
||||
|
||||
Var2Var = [
|
||||
|
@ -159,6 +166,7 @@ def Main():
|
|||
("PackFileToReplace", Opt.Replace_Distribution_Package_File),
|
||||
("PackFileToBeReplaced", Opt.Original_Distribution_Package_File),
|
||||
("UseGuidedPkgPath", Opt.Use_Guided_Paths),
|
||||
("TestDistFiles", Opt.Test_Install_Distribution_Package_Files)
|
||||
]
|
||||
|
||||
for Var in Var2Var:
|
||||
|
@ -265,6 +273,14 @@ def Main():
|
|||
Opt.PackFileToReplace = AbsPath
|
||||
RunModule = ReplacePkg.Main
|
||||
|
||||
elif Opt.Test_Install_Distribution_Package_Files:
|
||||
for Dist in Opt.Test_Install_Distribution_Package_Files:
|
||||
if not Dist.endswith('.dist'):
|
||||
Logger.Error("TestInstall", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Dist)
|
||||
|
||||
setattr(Opt, 'DistFiles', Opt.Test_Install_Distribution_Package_Files)
|
||||
RunModule = TestInstall.Main
|
||||
|
||||
else:
|
||||
Parser.print_usage()
|
||||
return OPTION_MISSING
|
||||
|
|
Loading…
Reference in New Issue