--- /dev/null
+##\r
+# UefiBuild Plugin that supports Window Capsule files based on the\r
+# Windows Firmware Update Platform spec.\r
+# Creates INF, Cat, and then signs it\r
+#\r
+# Copyright (c) Microsoft Corporation. All rights reserved.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+\r
+import sys\r
+import re\r
+import datetime\r
+import os\r
+import logging\r
+from MuEnvironment import PluginManager\r
+from MuPythonLibrary.Uefi.Capsule.CatGenerator import *\r
+from MuPythonLibrary.Uefi.Capsule.InfGenerator import *\r
+from MuPythonLibrary.UtilityFunctions import CatalogSignWithSignTool\r
+from MuPythonLibrary.Windows.VsWhereUtilities import FindToolInWinSdk\r
+\r
+\r
+class WindowsCapsuleSupportHelper(PluginManager.IUefiHelperPlugin):\r
+\r
+ def RegisterHelpers(self, obj):\r
+ fp = os.path.abspath(__file__)\r
+ obj.Register("PackageWindowsCapsuleFiles", WindowsCapsuleSupportHelper.PackageWindowsCapsuleFiles, fp)\r
+\r
+\r
+ @staticmethod\r
+ def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGuid, CapsuleVersion_DotString,\r
+ CapsuleVersion_HexString, ProductFwProvider, ProductFwMfgName, ProductFwDesc, CapsuleFileName, PfxFile=None, PfxPass=None,\r
+ Rollback=False, Arch='amd64', OperatingSystem_String='Win10'):\r
+\r
+ logging.debug("CapsulePackage: Create Windows Capsule Files")\r
+\r
+ #Make INF\r
+ InfFilePath = os.path.join(OutputFolder, ProductName + ".inf")\r
+ InfTool = InfGenerator(ProductName, ProductFwProvider, ProductFmpGuid, Arch, ProductFwDesc, CapsuleVersion_DotString, CapsuleVersion_HexString)\r
+ InfTool.Manufacturer = ProductFwMfgName #optional\r
+ ret = InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback)\r
+ if(ret != 0):\r
+ raise Exception("CreateWindowsInf Failed with errorcode %d" % ret)\r
+\r
+ #Make CAT\r
+ CatFilePath = os.path.realpath(os.path.join(OutputFolder, ProductName + ".cat"))\r
+ CatTool = CatGenerator(Arch, OperatingSystem_String)\r
+ ret = CatTool.MakeCat(CatFilePath)\r
+\r
+ if(ret != 0):\r
+ raise Exception("Creating Cat file Failed with errorcode %d" % ret)\r
+\r
+ if(PfxFile is not None):\r
+ #Find Signtool\r
+ SignToolPath = FindToolInWinSdk("signtool.exe")\r
+ if not os.path.exists(SignToolPath):\r
+ raise Exception("Can't find signtool on this machine.")\r
+ #dev sign the cat file\r
+ ret = CatalogSignWithSignTool(SignToolPath, CatFilePath, PfxFile, PfxPass)\r
+ if(ret != 0):\r
+ raise Exception("Signing Cat file Failed with errorcode %d" % ret)\r
+\r
+ return ret\r