def get_relevant_bootloaders(device): if Config.device: return aboot.by_device(Config.device) if Config.oem: return aboot.by_oem(Config.oem) if "" == device.device(): I("Cannot detect device identifier, considering all ABOOTs") return aboot.all() bootloaders = aboot.by_device(device.device()) if len(bootloaders) == 0: I("Cannot find bootloader images for %s, trying to resolve its OEM", device.device()) try: vendor = Config.oems[device.device()] I("Falling back for images of %s", vendor) return aboot.by_oem(vendor) except KeyError: I("Cannot resolve oem of %s, considering all ABOOTs", device.device()) return aboot.all() return bootloaders
def main(): adjustLevels() parser = argparse.ArgumentParser("ABOOTOOL") parser.add_argument( '-e', '--oem', dest='oem', help='Specify OEM to load ABOOT strings of, otherwise try to autodetect' ) parser.add_argument( '-d', '--device', dest='device', help= 'Specify device to load ABOOT strings of, otherwise try to autodetect') parser.add_argument( '-b', '--build', dest='build', help= 'Specify build to load ABOOT strings of, otherwise try to autodetect') parser.add_argument('-r', '--resume', type=int, default=0, dest='index', help='Resume from specified string index') parser.add_argument('-i', '--ignore', dest='ignore_re', help='Ignore pattern (regexp)') parser.add_argument( '-g', '--use-strings-generator', action='store_true', default=False, dest='use_strings_generator', help= 'Use strings generator instead of loading everything a priori (fast but degrades progress)' ) parser.add_argument( '-o', '--output', action='store_true', dest='show_output', help= "Show output of succeeded fastboot commands. Verbose logging overrides this" ) parser.add_argument('-l', '--aboots-list', action='store_true', dest='aboots', help="List available ABOOTs") parser.add_argument( '-a', '--images-add', dest='images_path', help= "Add ABOOT strings from OTA/Factory images. Either a file or a directory." ) parser.add_argument('-B', '--blob', action='store_true', default=False, dest='treat_as_blob', help="Treat specified path as ABOOT blob") parser.add_argument( '-S', '--string-prefix', default="", dest='string_prefix', help= "When inserting new images, only treat strings with specified prefix") parser.add_argument('-s', '--device-serial', dest='serial', help="Specify device fastboot SN") parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', help='Enable verbose logging') parser.add_argument('-vv', '--moreverbose', action='store_true', dest='moreverbose', help='Even more logging') parser.add_argument('-t', '--timeout', type=int, default=5000, dest='timeout', help='USB I/O timeout (ms)') args = parser.parse_args() if args.verbose: log.setVerbose() if args.moreverbose: log.setVerbose(True) I("Welcome to abootool by Aleph Research, HCL technologies") Config.overlay(args.__dict__) T("Config = %s", Config) if args.treat_as_blob: if not args.oem or not args.device or not args.build: E("Missing OEM/Device/Build specifiers") return 1 if args.aboots: I("BY OEM:") I("-------") dump_data(aboot.by_oem()) I("") I("BY DEVICE:") I("----------") dump_data(aboot.by_device()) return 0 if args.images_path: image.add(args.images_path) return 0 dev = device.Device(args.serial) name = dev.device() adjustLevels() if name: I("Device reported name = %s", name) OEMTester(dev).test(args.index) return 0