firmware-packager: Make it clearer to use

1) Remove the confusing --firmware-id and build this field dynamically based on GUID and Developer name
2) Make developer name mandatory
3) Rename device-unique-id to device-guid to more closely reflect how fwupdmgr shows it
4) Allow running on Windows
This commit is contained in:
Mario Limonciello 2018-10-22 16:52:56 -05:00 committed by Mario Limonciello
parent e4ad25044a
commit 355f5c12d6
2 changed files with 20 additions and 13 deletions

View File

@ -26,21 +26,19 @@ bin file inside the archive, I would pass `--exe dell-thunderbolt-firmware.exe -
## Documentation ## Documentation
`--firmware-id` ID for the firmware package, can be a customized [fwupd.org](http://fwupd.org/vendors.html) recommends using "a reverse-DNS prefix similar to java" and to "always use a .firmware suffix" (e.g. net.queuecumber.DellTBT.firmware) **REQUIRED**
`--firmware-name` Short name of the firmware package can be customized (e.g. DellTBT) **REQUIRED** `--firmware-name` Short name of the firmware package can be customized (e.g. DellTBT) **REQUIRED**
`--firmware-summary` One line description of the firmware package (e.g. Dell thunderbolt firmware) `--firmware-summary` One line description of the firmware package (e.g. Dell thunderbolt firmware)
`--firmware-description` Longer description of the firmware package. Theoretically this can include HTML but I haven't tried it `--firmware-description` Longer description of the firmware package. Theoretically this can include HTML but I haven't tried it
`--device-unique-id` Unique ID of the device this firmware will run on, this *must* match the output from `fwupdmgr get-devices` (e.g. 72533768-6a6c-5c06-994a-367374336810) **REQUIRED** `--device-guid` GUID ID of the device this firmware will run on, this *must* match the output from `fwupdmgr get-devices` (e.g. 72533768-6a6c-5c06-994a-367374336810) **REQUIRED**
`--firmware-homepage` Website for the firmware provider (e.g. http://www.dell.com) `--firmware-homepage` Website for the firmware provider (e.g. http://www.dell.com)
`-contact-info` Email address of the firmware developer (e.g. someone@something.net) `-contact-info` Email address of the firmware developer (e.g. someone@something.net)
`--developer-name` Name of the firmware developer (e.g. John Smith) `--developer-name` Name of the firmware developer (e.g. Dell) **REQUIRED**
`--release-version` Version number of the firmware package (e.g. 4.21.01.002) **REQUIRED** `--release-version` Version number of the firmware package (e.g. 4.21.01.002) **REQUIRED**
`--release-description` Description of the firmware release, again this can theoretically include HTML but I didnt try it. `--release-description` Description of the firmware release, again this can theoretically include HTML but I didnt try it.

View File

@ -24,14 +24,14 @@ def cd(path):
firmware_metainfo_template = """ firmware_metainfo_template = """
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<component type="firmware"> <component type="firmware">
<id>{firmware_id}</id> <id>org.{developer_name}.guid{firmware_id}</id>
<name>{firmware_name}</name> <name>{firmware_name}</name>
<summary>{firmware_summary}</summary> <summary>{firmware_summary}</summary>
<description> <description>
{firmware_description} {firmware_description}
</description> </description>
<provides> <provides>
<firmware type="flashed">{device_unique_id}</firmware> <firmware type="flashed">{device_guid}</firmware>
</provides> </provides>
<url type="homepage">{firmware_homepage}</url> <url type="homepage">{firmware_homepage}</url>
<metadata_license>CC0-1.0</metadata_license> <metadata_license>CC0-1.0</metadata_license>
@ -50,7 +50,9 @@ firmware_metainfo_template = """
def make_firmware_metainfo(firmware_info, dst): def make_firmware_metainfo(firmware_info, dst):
firmware_metainfo = firmware_metainfo_template.format(**vars(firmware_info), timestamp=time.time()) local_info = vars(firmware_info)
local_info["firmware_id"] = local_info["device_guid"][0:8]
firmware_metainfo = firmware_metainfo_template.format(**local_info, timestamp=time.time())
with open(os.path.join(dst, 'firmware.metainfo.xml'), 'w') as f: with open(os.path.join(dst, 'firmware.metainfo.xml'), 'w') as f:
f.write(firmware_metainfo) f.write(firmware_metainfo)
@ -68,6 +70,14 @@ def get_firmware_bin(root, bin_path, dst):
def create_firmware_cab(exe, folder): def create_firmware_cab(exe, folder):
with cd(folder): with cd(folder):
if os.name is "nt":
directive = os.path.join (folder, "directive")
with open (directive, 'w') as wfd:
wfd.write('"firmware.cab"\r\n')
wfd.write('"firmware.bin"\r\n')
wfd.write('"firmware.metainfo.xml"\r\n')
command = ['makecab.exe', '/f', directive]
else:
command = ['gcab', '--create', 'firmware.cab', 'firmware.bin', 'firmware.metainfo.xml'] command = ['gcab', '--create', 'firmware.cab', 'firmware.bin', 'firmware.metainfo.xml']
subprocess.check_call(command) subprocess.check_call(command)
@ -93,18 +103,17 @@ def main(args):
shutil.copy(os.path.join(dir, 'firmware.cab'), args.out) shutil.copy(os.path.join(dir, 'firmware.cab'), args.out)
parser = argparse.ArgumentParser(description='Create fwupd packaged from windows executables') parser = argparse.ArgumentParser(description='Create fwupd packaged from windows executables')
parser.add_argument('--firmware-id', help='ID for the firmware package, can be a customized (e.g. net.queuecumber.DellTBT.firmware)', required=True)
parser.add_argument('--firmware-name', help='Name of the firmware package can be customized (e.g. DellTBT)', required=True) parser.add_argument('--firmware-name', help='Name of the firmware package can be customized (e.g. DellTBT)', required=True)
parser.add_argument('--firmware-summary', help='One line description of the firmware package') parser.add_argument('--firmware-summary', help='One line description of the firmware package')
parser.add_argument('--firmware-description', help='Longer description of the firmware package') parser.add_argument('--firmware-description', help='Longer description of the firmware package')
parser.add_argument('--device-unique-id', help='Unique ID of the device this firmware will run on, this *must* match the output from `fwupdmgr get-devices`', required=True) parser.add_argument('--device-guid', help='GUID of the device this firmware will run on, this *must* match the output of one of the GUIDs in `fwupdmgr get-devices`', required=True)
parser.add_argument('--firmware-homepage', help='Website for the firmware provider') parser.add_argument('--firmware-homepage', help='Website for the firmware provider')
parser.add_argument('--contact-info', help='Email address of the firmware developer') parser.add_argument('--contact-info', help='Email address of the firmware developer')
parser.add_argument('--developer-name', help='Name of the firmware developer') parser.add_argument('--developer-name', help='Name of the firmware developer', required=True)
parser.add_argument('--release-version', help='Version number of the firmware package', required=True) parser.add_argument('--release-version', help='Version number of the firmware package', required=True)
parser.add_argument('--release-description', help='Description of the firmware release') parser.add_argument('--release-description', help='Description of the firmware release')
parser.add_argument('--exe', help='Executable file to extract firmware from') parser.add_argument('--exe', help='(optional) Executable file to extract firmware from')
parser.add_argument('--bin', help='Path to the .bin file inside the executable to use as the firmware image', required=True) parser.add_argument('--bin', help='Path to the .bin file (Relative if inside the executable; Absolute if outside) to use as the firmware image', required=True)
parser.add_argument('--out', help='Output cab file path', required=True) parser.add_argument('--out', help='Output cab file path', required=True)
args = parser.parse_args() args = parser.parse_args()