From 1dbd18af2b98f635921c63de8e14ce1a8b17ba7f Mon Sep 17 00:00:00 2001 From: flawedworld Date: Tue, 5 Apr 2022 16:27:06 +0100 Subject: [PATCH] Add OTA firmware extraction command --- src/commands/ota-firmware.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/commands/ota-firmware.ts diff --git a/src/commands/ota-firmware.ts b/src/commands/ota-firmware.ts new file mode 100644 index 0000000..8855ae2 --- /dev/null +++ b/src/commands/ota-firmware.ts @@ -0,0 +1,30 @@ +import { Command, flags } from '@oclif/command' +import { run } from '../util/process' +import { readFile } from '../util/fs' + +import YAML from 'yaml' + +export default class ExtractFirmware extends Command { + static description = 'extract firmware partitions' + + static flags = { + help: flags.help({char: 'h'}), + factoryOtaPath: flags.string({char: 'f', description: 'path to stock factory OTA images zip (for extracting firmware)', required: true}), + } + + static args = [ + {name: 'configPath', description: 'path to device-specific YAML config', required: true}, + ] + + async run() { + let {args: {configPath}, flags: {factoryOtaPath}} = this.parse(ExtractFirmware) + + // parse config file + let config = YAML.parse(await readFile(configPath)) + let vendor = "google_devices" + let device = config.device.name + + let outDir = `vendor/${vendor}/${device}/firmware` + await run(__dirname + `/../../external/extract_android_ota_payload/extract_android_ota_payload.py ${factoryOtaPath} ${outDir}`) + } +}