]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py
BaseTools/Capsule: Add WindowsCapsuleSupportHelper
[mirror_edk2.git] / BaseTools / Source / Python / Capsule / WindowsCapsuleSupportHelper.py
CommitLineData
e2aacac5
SB
1##\r
2# UefiBuild Plugin that supports Window Capsule files based on the\r
3# Windows Firmware Update Platform spec.\r
4# Creates INF, Cat, and then signs it\r
5#\r
6# Copyright (c) Microsoft Corporation. All rights reserved.\r
7# SPDX-License-Identifier: BSD-2-Clause-Patent\r
8##\r
9\r
10import sys\r
11import re\r
12import datetime\r
13import os\r
14import logging\r
15from MuEnvironment import PluginManager\r
16from MuPythonLibrary.Uefi.Capsule.CatGenerator import *\r
17from MuPythonLibrary.Uefi.Capsule.InfGenerator import *\r
18from MuPythonLibrary.UtilityFunctions import CatalogSignWithSignTool\r
19from MuPythonLibrary.Windows.VsWhereUtilities import FindToolInWinSdk\r
20\r
21\r
22class WindowsCapsuleSupportHelper(PluginManager.IUefiHelperPlugin):\r
23\r
24 def RegisterHelpers(self, obj):\r
25 fp = os.path.abspath(__file__)\r
26 obj.Register("PackageWindowsCapsuleFiles", WindowsCapsuleSupportHelper.PackageWindowsCapsuleFiles, fp)\r
27\r
28\r
29 @staticmethod\r
30 def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGuid, CapsuleVersion_DotString,\r
31 CapsuleVersion_HexString, ProductFwProvider, ProductFwMfgName, ProductFwDesc, CapsuleFileName, PfxFile=None, PfxPass=None,\r
32 Rollback=False, Arch='amd64', OperatingSystem_String='Win10'):\r
33\r
34 logging.debug("CapsulePackage: Create Windows Capsule Files")\r
35\r
36 #Make INF\r
37 InfFilePath = os.path.join(OutputFolder, ProductName + ".inf")\r
38 InfTool = InfGenerator(ProductName, ProductFwProvider, ProductFmpGuid, Arch, ProductFwDesc, CapsuleVersion_DotString, CapsuleVersion_HexString)\r
39 InfTool.Manufacturer = ProductFwMfgName #optional\r
40 ret = InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback)\r
41 if(ret != 0):\r
42 raise Exception("CreateWindowsInf Failed with errorcode %d" % ret)\r
43\r
44 #Make CAT\r
45 CatFilePath = os.path.realpath(os.path.join(OutputFolder, ProductName + ".cat"))\r
46 CatTool = CatGenerator(Arch, OperatingSystem_String)\r
47 ret = CatTool.MakeCat(CatFilePath)\r
48\r
49 if(ret != 0):\r
50 raise Exception("Creating Cat file Failed with errorcode %d" % ret)\r
51\r
52 if(PfxFile is not None):\r
53 #Find Signtool\r
54 SignToolPath = FindToolInWinSdk("signtool.exe")\r
55 if not os.path.exists(SignToolPath):\r
56 raise Exception("Can't find signtool on this machine.")\r
57 #dev sign the cat file\r
58 ret = CatalogSignWithSignTool(SignToolPath, CatFilePath, PfxFile, PfxPass)\r
59 if(ret != 0):\r
60 raise Exception("Signing Cat file Failed with errorcode %d" % ret)\r
61\r
62 return ret\r