From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: eric.jin@intel.com) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Mon, 12 Aug 2019 00:44:45 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Aug 2019 00:44:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,376,1559545200"; d="scan'208";a="175809697" Received: from unknown (HELO jjin9-MOBL.ccr.corp.intel.com) ([10.239.192.132]) by fmsmga008.fm.intel.com with ESMTP; 12 Aug 2019 00:44:42 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Michael D Kinney , Liming Gao , Bob Feng Subject: [PATCH V2 1/2] BaseTools/Capsule: Add WindowsCapsuleSupportHelper Date: Mon, 12 Aug 2019 15:43:59 +0800 Message-Id: <20190812074359.47028-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sean Brogan Add initial version WindowsCapsuleSupportHelper.py original source comes from https://github.com/microsoft/mu_basecore/blob/dev/201905/BaseTools/Plugin/WindowsCapsuleSupportHelper/WindowsCapsuleSupportHelper.py commit ebd9aad90dee3a3094b575928670cf81b8c685b5 Convert EOL to CRLF Cc: Sean Brogan Cc: Bret Barkelew Cc: Michael D Kinney Cc: Liming Gao Cc: Bob Feng Signed-off-by: Eric Jin --- .../Capsule/WindowsCapsuleSupportHelper.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py diff --git a/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py new file mode 100644 index 0000000000..166af58d81 --- /dev/null +++ b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py @@ -0,0 +1,62 @@ +## +# UefiBuild Plugin that supports Window Capsule files based on the +# Windows Firmware Update Platform spec. +# Creates INF, Cat, and then signs it +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +import sys +import re +import datetime +import os +import logging +from MuEnvironment import PluginManager +from MuPythonLibrary.Uefi.Capsule.CatGenerator import * +from MuPythonLibrary.Uefi.Capsule.InfGenerator import * +from MuPythonLibrary.UtilityFunctions import CatalogSignWithSignTool +from MuPythonLibrary.Windows.VsWhereUtilities import FindToolInWinSdk + + +class WindowsCapsuleSupportHelper(PluginManager.IUefiHelperPlugin): + + def RegisterHelpers(self, obj): + fp = os.path.abspath(__file__) + obj.Register("PackageWindowsCapsuleFiles", WindowsCapsuleSupportHelper.PackageWindowsCapsuleFiles, fp) + + + @staticmethod + def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGuid, CapsuleVersion_DotString, + CapsuleVersion_HexString, ProductFwProvider, ProductFwMfgName, ProductFwDesc, CapsuleFileName, PfxFile=None, PfxPass=None, + Rollback=False, Arch='amd64', OperatingSystem_String='Win10'): + + logging.debug("CapsulePackage: Create Windows Capsule Files") + + #Make INF + InfFilePath = os.path.join(OutputFolder, ProductName + ".inf") + InfTool = InfGenerator(ProductName, ProductFwProvider, ProductFmpGuid, Arch, ProductFwDesc, CapsuleVersion_DotString, CapsuleVersion_HexString) + InfTool.Manufacturer = ProductFwMfgName #optional + ret = InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback) + if(ret != 0): + raise Exception("CreateWindowsInf Failed with errorcode %d" % ret) + + #Make CAT + CatFilePath = os.path.realpath(os.path.join(OutputFolder, ProductName + ".cat")) + CatTool = CatGenerator(Arch, OperatingSystem_String) + ret = CatTool.MakeCat(CatFilePath) + + if(ret != 0): + raise Exception("Creating Cat file Failed with errorcode %d" % ret) + + if(PfxFile is not None): + #Find Signtool + SignToolPath = FindToolInWinSdk("signtool.exe") + if not os.path.exists(SignToolPath): + raise Exception("Can't find signtool on this machine.") + #dev sign the cat file + ret = CatalogSignWithSignTool(SignToolPath, CatFilePath, PfxFile, PfxPass) + if(ret != 0): + raise Exception("Signing Cat file Failed with errorcode %d" % ret) + + return ret -- 2.20.1.windows.1