Skip to content

Inf generator2

inf_generator2

Module to generate inf files for capsule update.

Supports targeting multiple ESRT nodes with the same INF

InfHeader

The INF header at the start of the INF file.

Name property writable

Name: str

Returns the Name attribute.

VersionStr property writable

VersionStr: str

Returns the VersionStr attribute.

Date property writable

Date: str

Returns the Date attribute, a datetime object.

Arch property writable

Arch: str

Returns the Architecture.

__init__

__init__(
    Name: str,
    VersionStr: str,
    CreationDate: str,
    Arch: str,
    Provider: str,
    Manufacturer: str,
    InfStrings: InfStrings,
) -> InfHeader

Instantiate an INF header object.

Parameters:

Name Type Description Default
Name str

specifies the name for the INF package

required
VersionStr str

specifies the version as string in dot-tuple format (e.g. "4.15.80.0")

required
CreationDate str

specifies the INF date as a string in MM/DD/YYYY format (e.g "01/01/2021")

required
Arch str

specifies the architecture as a string (e.g. "amd64")

required
Provider str

specifies the provider as a string (e.g. "Firmware Provider")

required
Manufacturer str

Specifies the manufacturer as a string (e.g. "Firmware Manufacturer")

required
InfStrings InfStrings

An InfStrings object representing the "Strings" section of this INF file.

required

__str__

__str__() -> str

Return the string representation of this InfHeader object.

InfFirmware

Individual firmware sections within the INF.

Tag property writable

Tag: str

Returns the Tag value.

EsrtGuid property writable

EsrtGuid: UUID

Returns the EsrtGuid value.

VersionInt property writable

VersionInt: int

Returns the VersionInt value.

__init__

__init__(
    Tag: str,
    Description: str,
    EsrtGuid: str,
    VersionInt: str,
    FirmwareFile: str,
    InfStrings: InfStrings,
    InfSourceFiles: InfSourceFiles,
    Rollback: Optional[bool] = False,
    IntegrityFile: Optional[str] = None,
) -> InfFirmware

Instantiate an INF firmware object.

Parameters:

Name Type Description Default
Tag str

A string that uniquely identifies this firmware (e.g. "Firmware0")

required
Description str

A description of the firmware (e.g. "UEFI Firmware")

required
EsrtGuid str

ESRT GUID for this firmware in string format. (e.g. "34e094e9-4079-44cd-9450-3f2cb7824c97")

required
VersionInt str

Version as an integer in string format (e.g. "1234" or "0x04158000")

required
FirmwareFile str

Filename (basename only) of the firmware payload file (e.g. "Firmware1234.bin")

required
InfStrings InfStrings

An InfStrings object representing the "Strings" section of this INF file.

required
InfSourceFiles InfSourceFiles

An InfSourceFiles object representing the "SourceDisks*" sections of this INF file.

required
Rollback
False
IntegrityFile

firmware (e.g. "integrity123.bin"). Optional - if not specified, no integrity file will be included.

None

__str__

__str__() -> str

Return the string representation of this InfFirmware object.

InfFirmwareSections

A collection of firmware sections and associated common metadata.

Arch property writable

Arch: str

Returns the Architecture.

__init__

__init__(
    Arch: str, InfStrings: InfStrings
) -> InfFirmwareSections

Instantiate an INF firmware sections object.

Parameters:

Name Type Description Default
Arch str

specifies the architecture as a string (e.g. "amd64")

required
InfStrings InfStrings

An InfStrings object representing the "Strings" section of this INF file.

required

AddSection

AddSection(InfFirmware: InfFirmware) -> None

Adds an InfFirmware section object to the set of firmware sections in this InfFirmwareSections object.

Parameters:

Name Type Description Default
InfFirmware InfFirmware

an InfFirmware object representing a firmware section to be added to this collection of sections.

required

__str__

__str__() -> str

Return the string representation of this InfFirmwareSections object.

This includes any InfFirmware objects in it.

InfSourceFiles

The collection of source files that are referenced by other sections of the INF.

__init__

__init__(
    DiskName: str, InfStrings: InfStrings
) -> InfSourceFiles

Instantiate an INF source files object.

Parameters:

Name Type Description Default
DiskName str

Specifies the DiskName as a string (e.g. "FirmwareUpdate")

required
InfStrings InfStrings

An InfStrings object representing the "Strings" section of this INF file.

required

AddFile

AddFile(Filename: str) -> None

Adds a new file to this InfSourceFiles object.

Parameters:

Name Type Description Default
Filename str

Filename (basename only) of the file to be added. (e.g. "Firmware1234.bin")

required

__str__

__str__() -> str

Return the string representation of this InfSourceFIles object.

InfStrings

Represents the collection of strings that are referenced by other sections of the INF.

strings can be localizable or non-localizable

__init__

__init__() -> InfStrings

Instantiate an INF strings object.

AddLocalizableString

AddLocalizableString(Key: str, Value: str) -> None

Add a Localizable string to the collection of strings for this INF.

Parameters:

Name Type Description Default
Key str

the name of this string as it is used in the INF (e.g. "MfgName"). Note: the INF will typically reference this string using % as delimiters (e.g. "%MfgName%"). Do not include the % characters when calling this routine.

required
Value str

the value of the localizable string as a string (e.g. "Firmware Manufacturer")

required

AddNonLocalizableString

AddNonLocalizableString(Key: str, Value: str) -> None

Add a Non-Localizable string to the collection of strings for this INF.

Parameters:

Name Type Description Default
Key str

the name of this string as it is used in the INF (e.g. "REG_DWORD"). Note: the INF will typically reference this string using % as delimiters (e.g. "%REG_DWORD%"). Do not include the % characters when calling this routine.

required
Value str

the value of the non-localizable string as a string (e.g. "0x00010001")

required

__str__

__str__() -> str

Return the string representation of this InfStrings object.

InfFile

An object representing an INF file.

__init__

__init__(
    Name: str,
    VersionStr: str,
    CreationDate: str,
    Provider: str,
    ManufacturerName: str,
    Arch: Optional[str] = "amd64",
    DiskName: Optional[str] = "Firmware Update",
) -> InfFile

Instantiate an INF file object.

This object represents the entire INF file.

Users of this implementation are primarily expected to interact with instances of this class.

Parameters:

Name Type Description Default
Name str

specifies the name for the INF package

required
VersionStr str

specifies the version as string in dot-tuple format (e.g. "4.15.80.0")

required
CreationDate str

specifies the INF date as a string in MM/DD/YYYY format (e.g "01/01/2021")

required
Provider str

specifies the provider as a string (e.g. "Firmware Provider")

required
ManufacturerName str

)Specifies the manufacturer as a string (e.g. "Firmware Manufacturer")

required
Arch
'amd64'
DiskName

Update".

'Firmware Update'

AddFirmware

AddFirmware(
    Tag: str,
    Description: str,
    EsrtGuid: str,
    VersionInt: str,
    FirmwareFile: str,
    Rollback: Optional[bool] = False,
    IntegrityFile: Optional[str] = None,
) -> None

Adds a firmware target to the INF.

Parameters:

Name Type Description Default
Tag str

A string that uniquely identifies this firmware (e.g. "Firmware0")

required
Description str

A description of the firmware (e.g. "UEFI Firmware")

required
EsrtGuid str

ESRT GUID for this firmware in string format. (e.g. "34e094e9-4079-44cd-9450-3f2cb7824c97")

required
VersionInt str

Version as an integer in string format (e.g. "1234" or "0x04158000")

required
FirmwareFile str

Filename (basename only) of the firmware payload file (e.g. "Firmware1234.bin")

required
Rollback

(optional, default: False)

False
IntegrityFile

firmware (e.g. "integrity123.bin"). Optional - if not specified, no integrity file will be included.

None

__str__

__str__() -> str

String represention of this InfFile object.

Returns the string representation of this InfFile object. The resulting string is suitable for writing to an INF file for inclusion in a capsule package.