From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 20C5D1A1E24 for ; Mon, 1 Aug 2016 21:05:03 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 01 Aug 2016 21:05:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,458,1464678000"; d="scan'208";a="742919717" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 01 Aug 2016 21:05:02 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 21:05:02 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 21:05:01 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.181]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.150]) with mapi id 14.03.0248.002; Tue, 2 Aug 2016 12:04:59 +0800 From: "Zhu, Yonghong" To: "Chen, Hesheng" , "edk2-devel@lists.01.org" Thread-Topic: [patch] BaseTool/UPT: Add Test Install Thread-Index: AQHR6W8Npm1qv3NUyUKi9noPxiL6fqA1Ey8Q Date: Tue, 2 Aug 2016 04:04:59 +0000 Message-ID: References: <1469779103-144380-1-git-send-email-hesheng.chen@intel.com> In-Reply-To: <1469779103-144380-1-git-send-email-hesheng.chen@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] BaseTool/UPT: Add Test Install X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 04:05:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please remove the trailing whitespace when commit. Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Chen, Hesheng=20 Sent: Friday, July 29, 2016 3:58 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong Subject: [patch] BaseTool/UPT: Add Test Install Add a new function to test if a DIST file list one by one to see if they ca= n meet the requirement of Dependency. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: hesschen --- .../Source/Python/UPT/Core/DependencyRules.py | 21 ++++- BaseTools/Source/Python/UPT/Logger/StringTable.py | 5 ++ BaseTools/Source/Python/UPT/TestInstall.py | 100 +++++++++++++++++= ++++ BaseTools/Source/Python/UPT/UPT.py | 16 ++++ 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 Base= Tools/Source/Python/UPT/TestInstall.py diff --git a/BaseTools/Source/Python/UPT/Core/DependencyRules.py b/BaseTool= s/Source/Python/UPT/Core/DependencyRules.py index 4608ed6..ee06c53 100644 --- a/BaseTools/Source/Python/UPT/Core/DependencyRules.py +++ b/BaseTools/Source/Python/UPT/Core/DependencyRules.py @@ -1,7 +1,7 @@ ## @file # This file is for installed package information database operations # -#= Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2016, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials are licensed and made availa= ble # under the terms and conditions of the BSD License which accompanies = this @@ -183,6 +183,25 @@ class DependencyRules(object): def CheckInstallDpDepexSatisfied(self, DpObj): self.PkgsToBeDepend =3D [(PkgInfo[1], PkgInfo[2]) for PkgInfo in s= elf.WsPkgList] return self.CheckDpDepexSatisfied(DpObj) + =20 + # # 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 =3D [(PkgInfo[1], PkgInfo[2]) for PkgInfo in s= elf.WsPkgList] + for DpObj in DpObjList: + if self.CheckDpDepexSatisfied(DpObj): + for PkgKey in DpObj.PackageSurfaceArea.keys(): + PkgObj =3D DpObj.PackageSurfaceArea[PkgKey] + self.PkgsToBeDepend.append((PkgObj.Guid, PkgObj.Versio= n)) + else: + return False, DpObj + + return True, DpObj + =20 ## Check whether a DP depex satisfied by current workspace=20 # (excluding the original distribution's packages to be replaced) for= Replace diff --git a/BaseTools/Source/Python/UPT/Logger/StringTable.py b/B= aseTools/Source/Python/UPT/Logger/StringTable.py index 96f0e1c..4c42661 100644 --- a/BaseTools/Source/Python/UPT/Logger/StringTable.py +++ b/BaseTools/Source/Python/UPT/Logger/StringTable.py @@ -858,3 +858,8 @@ HLP_SPECIFY_PACKAGE_NAME_TO_BE_REPLACED =3D _( "Specify the UEFI Distribution Package file name to be replaced") HLP= _USE_GUIDED_PATHS =3D _( "Install packages to the following directory path by default: __") +HLP_TEST_INSTALL =3D _( + "Specify the UEFI Distribution Package filenames to install") + +MSG_TEST_INSTALL_PASS =3D _("All distribution package file are satisfied=20 +for dependence check.") MSG_TEST_INSTALL_FAIL =3D _("NOT all distribution= =20 +package file are satisfied for dependence check.") diff --git a/BaseTools/Source/Python/UPT/TestInstall.py b/BaseTools/Source/= Python/UPT/TestInstall.py new file mode 100644 index 0000000..71fe928 --- /dev/null +++ b/BaseTools/Source/Python/UPT/TestInstall.py @@ -0,0 +1,100 @@ +# # @file +# Test Install distribution package +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
# #=20 +This program and the accompanying materials are licensed and made=20 +available # under the terms and conditions of the BSD License which=20 +accompanies this # distribution. The full text of the license may be=20 +found at # http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=20 +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. +# +""" +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=20 +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 option= s. +# If no error found, return zero value so the caller of this tool can=20 +know # if it's executed successfully or not. +# +# @param Options: command Options +# +def Main(Options=3DNone): + ContentZipFile, DistFile =3D None, None + ReturnCode =3D 0 + + try: + DataBase =3D GlobalData.gDB + WorkspaceDir =3D GlobalData.gWORKSPACE + if not Options.DistFiles: + Logger.Error("TestInstallPkg", TE.OPTION_MISSING,=20 + ExtraData=3DST.ERR_SPECIFY_PACKAGE) + + DistPkgList =3D [] + for DistFile in Options.DistFiles: + DistPkg, ContentZipFile, __, DistFile =3D UnZipDp(WorkspaceDir= , DistFile) + DistPkgList.append(DistPkg) + + # + # check dependency + # + Dep =3D DependencyRules(DataBase) + Result =3D True + DpObj =3D None + try: + Result, DpObj =3D Dep.CheckTestInstallPdDepexSatisfied(DistPkg= List) + except: + Result =3D False + =20 + if Result: + Logger.Quiet(ST.MSG_TEST_INSTALL_PASS) + else: + Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL) + + except TE.FatalError, XExcept: + ReturnCode =3D XExcept.args[0] + if Logger.GetLevel() <=3D Logger.DEBUG_9: + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),=20 + platform) + format_exc()) + + except Exception, x: + ReturnCode =3D TE.CODE_ERROR + Logger.Error( + "\nTestInstallPkg", + TE.CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.DistFiles, + ExtraData=3DST.MSG_SEARCH_FOR_HELP, + RaiseError=3DFalse + ) + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) +=20 + 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 =3D None + Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE) + if ReturnCode =3D=3D 0: + Logger.Quiet(ST.MSG_FINISH) + return ReturnCode + diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/U= PT/UPT.py index 59c4a88..8dd949a 100644 --- a/BaseTools/Source/Python/UPT/UPT.py +++ b/BaseTools/Source/Python/UPT/UPT.py @@ -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=3DST.ERR_I_R_EXCLUS= IVE) elif Opt.PackFileToCreate and Opt.PackFileToRemove: Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_C_R_EXCLUS= IVE) + elif Opt.TestDistFiles and (Opt.PackFileToCreate or Opt.PackFileToInst= all \ + or Opt.PackFileToRemove or Opt.PackFileToR= eplace): + Logger.Error("UPT", OPTION_CONFLICT,=20 + ExtraData=3DST.ERR_C_R_EXCLUSIVE) =20 if Opt.CustomPath and Opt.UseGuidedPkgPath: Logger.Warn("UPT", ST.WARN_CUSTOMPATH_OVERRIDE_USEGUIDEDPATH) @@ -146,6 +150,9 @@ def Main(): =20 Parser.add_option("--use-guided-paths", action=3D"store_true", dest=3D= "Use_Guided_Paths", help=3DST.HLP_USE_GUIDED_PATHS) =20 + Parser.add_option("-j", "--test-install", action=3D"append", type=3D"s= tring", + dest=3D"Test_Install_Distribution_Package_Files",=20 + help=3DST.HLP_TEST_INSTALL) + Opt =3D Parser.parse_args()[0] =20 Var2Var =3D [ @@ -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) ] =20 for Var in Var2Var: @@ -265,6 +273,14 @@ def Main(): Opt.PackFileToReplace =3D AbsPath RunModule =3D ReplacePkg.Main =20 + 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,=20 + ExtraData=3DST.ERR_DIST_EXT_ERROR % Dist) + + setattr(Opt, 'DistFiles', Opt.Test_Install_Distribution_Packag= e_Files) + RunModule =3D TestInstall.Main + else: Parser.print_usage() return OPTION_MISSING -- 2.7.2.windows.1