]>
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 | |
48d8d4d8 JE |
6 | # To install run pip install --upgrade edk2-pytool-library\r |
7 | # edk2-pytool-library-0.9.1 is required.\r | |
8 | #\r | |
e2aacac5 | 9 | # Copyright (c) Microsoft Corporation. All rights reserved.\r |
48d8d4d8 | 10 | # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r |
e2aacac5 SB |
11 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
12 | ##\r | |
13 | \r | |
14 | import sys\r | |
15 | import re\r | |
16 | import datetime\r | |
17 | import os\r | |
18 | import logging\r | |
48d8d4d8 JE |
19 | from edk2toollib.windows.capsule.cat_generator import CatGenerator\r |
20 | from edk2toollib.windows.capsule.inf_generator import InfGenerator\r | |
21 | from edk2toollib.utility_functions import CatalogSignWithSignTool\r | |
22 | from edk2toollib.windows.locate_tools import FindToolInWinSdk\r | |
e2aacac5 | 23 | \r |
48d8d4d8 | 24 | class WindowsCapsuleSupportHelper(object):\r |
e2aacac5 SB |
25 | \r |
26 | def RegisterHelpers(self, obj):\r | |
27 | fp = os.path.abspath(__file__)\r | |
28 | obj.Register("PackageWindowsCapsuleFiles", WindowsCapsuleSupportHelper.PackageWindowsCapsuleFiles, fp)\r | |
29 | \r | |
30 | \r | |
31 | @staticmethod\r | |
32 | def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGuid, CapsuleVersion_DotString,\r | |
33 | CapsuleVersion_HexString, ProductFwProvider, ProductFwMfgName, ProductFwDesc, CapsuleFileName, PfxFile=None, PfxPass=None,\r | |
34 | Rollback=False, Arch='amd64', OperatingSystem_String='Win10'):\r | |
35 | \r | |
36 | logging.debug("CapsulePackage: Create Windows Capsule Files")\r | |
37 | \r | |
38 | #Make INF\r | |
39 | InfFilePath = os.path.join(OutputFolder, ProductName + ".inf")\r | |
40 | InfTool = InfGenerator(ProductName, ProductFwProvider, ProductFmpGuid, Arch, ProductFwDesc, CapsuleVersion_DotString, CapsuleVersion_HexString)\r | |
41 | InfTool.Manufacturer = ProductFwMfgName #optional\r | |
42 | ret = InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback)\r | |
43 | if(ret != 0):\r | |
44 | raise Exception("CreateWindowsInf Failed with errorcode %d" % ret)\r | |
45 | \r | |
46 | #Make CAT\r | |
47 | CatFilePath = os.path.realpath(os.path.join(OutputFolder, ProductName + ".cat"))\r | |
48 | CatTool = CatGenerator(Arch, OperatingSystem_String)\r | |
49 | ret = CatTool.MakeCat(CatFilePath)\r | |
50 | \r | |
51 | if(ret != 0):\r | |
52 | raise Exception("Creating Cat file Failed with errorcode %d" % ret)\r | |
53 | \r | |
54 | if(PfxFile is not None):\r | |
55 | #Find Signtool\r | |
56 | SignToolPath = FindToolInWinSdk("signtool.exe")\r | |
57 | if not os.path.exists(SignToolPath):\r | |
58 | raise Exception("Can't find signtool on this machine.")\r | |
59 | #dev sign the cat file\r | |
60 | ret = CatalogSignWithSignTool(SignToolPath, CatFilePath, PfxFile, PfxPass)\r | |
61 | if(ret != 0):\r | |
62 | raise Exception("Signing Cat file Failed with errorcode %d" % ret)\r | |
63 | \r | |
64 | return ret\r |