]>
Commit | Line | Data |
---|---|---|
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 | |
10 | import sys\r | |
11 | import re\r | |
12 | import datetime\r | |
13 | import os\r | |
14 | import logging\r | |
15 | from MuEnvironment import PluginManager\r | |
16 | from MuPythonLibrary.Uefi.Capsule.CatGenerator import *\r | |
17 | from MuPythonLibrary.Uefi.Capsule.InfGenerator import *\r | |
18 | from MuPythonLibrary.UtilityFunctions import CatalogSignWithSignTool\r | |
19 | from MuPythonLibrary.Windows.VsWhereUtilities import FindToolInWinSdk\r | |
20 | \r | |
21 | \r | |
22 | class 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 |