summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py62
1 files changed, 62 insertions, 0 deletions
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