def SignOutput(input_zip_name, output_zip_name): key_passwords = common.GetKeyPasswords([OPTIONS.package_key]) pw = key_passwords[OPTIONS.package_key] common.SignFile(input_zip_name, output_zip_name, OPTIONS.package_key, pw, whole_file=True)
def main(argv): def option_handler(o, a): if o in ("-I", "--ifwi-directory"): OPTIONS.ifwi_directory = a elif o in ("-A", "--avb-key"): OPTIONS.avb_key = a OPTIONS.all_keys.add(a) elif o in ("-K", "--oem-key"): OPTIONS.oem_key = a OPTIONS.all_keys.add(a) elif o in ("-V", "--variant"): OPTIONS.variant = a else: return False return True args = common.ParseOptions(argv, __doc__, extra_opts="I:A:K:V:", extra_long_opts=[ "ifwi-directory=", "avb-key=", "oem-key=", "variant=" ], extra_option_handler=option_handler) if len(args) != 2: common.Usage(__doc__) sys.exit(1) output_fastboot_fn = args[1] print("Extracting the provdata.zip") prov_file = "provdata_" + OPTIONS.variant + ".zip" unpack_dir = common.UnzipTemp(args[0]) input_zip = zipfile.ZipFile(args[0], "r") input_provzip = zipfile.ZipFile( os.path.join(unpack_dir, "RADIO", prov_file), "r") print("Parsing build.prop for target_product") d = {} try: with open(os.path.join(unpack_dir, "SYSTEM", "build.prop")) as f: d = common.LoadDictionaryFromLines(f.read().split("\n")) except IOError as e: if e.errno == errno.ENOENT: raise KeyError(f) OPTIONS.target_product = d["ro.product.system.name"] print("Processing private keys") OPTIONS.info_dict = common.LoadInfoDict(input_zip) passwords = common.GetKeyPasswords(OPTIONS.all_keys) #process the provdata.zip to generate resigned one process_provzip(input_provzip, output_fastboot_fn) common.ZipClose(input_zip) print("Extract done.")
def main(argv): key_mapping_options = [] def option_handler(o, a): if o in ("-e", "--extra_apks"): names, key = a.split("=") names = names.split(",") for n in names: OPTIONS.extra_apks[n] = key elif o in ("-d", "--default_key_mappings"): key_mapping_options.append((None, a)) elif o in ("-k", "--key_mapping"): key_mapping_options.append(a.split("=", 1)) elif o in ("-o", "--replace_ota_keys"): OPTIONS.replace_ota_keys = True elif o in ("-t", "--tag_changes"): new = [] for i in a.split(","): i = i.strip() if not i or i[0] not in "-+": raise ValueError("Bad tag change '%s'" % (i,)) new.append(i[0] + i[1:].strip()) OPTIONS.tag_changes = tuple(new) elif o == "--replace_verity_public_key": OPTIONS.replace_verity_public_key = (True, a) elif o == "--replace_verity_private_key": OPTIONS.replace_verity_private_key = (True, a) elif o == "--replace_verity_keyid": OPTIONS.replace_verity_keyid = (True, a) else: return False return True args = common.ParseOptions(argv, __doc__, extra_opts="e:d:k:ot:", extra_long_opts=["extra_apks=", "default_key_mappings=", "key_mapping=", "replace_ota_keys", "tag_changes=", "replace_verity_public_key=", "replace_verity_private_key=", "replace_verity_keyid="], extra_option_handler=option_handler) if len(args) != 2: common.Usage(__doc__) sys.exit(1) input_zip = zipfile.ZipFile(args[0], "r") output_zip = zipfile.ZipFile(args[1], "w") misc_info = common.LoadInfoDict(input_zip) BuildKeyMap(misc_info, key_mapping_options) apk_key_map = GetApkCerts(input_zip) CheckAllApksSigned(input_zip, apk_key_map) key_passwords = common.GetKeyPasswords(set(apk_key_map.values())) platform_api_level, platform_codename = GetApiLevelAndCodename(input_zip) codename_to_api_level_map = GetCodenameToApiLevelMap(input_zip) # Android N will be API Level 24, but isn't yet. # TODO: Remove this workaround once Android N is officially API Level 24. if platform_api_level == 23 and platform_codename == "N": platform_api_level = 24 ProcessTargetFiles(input_zip, output_zip, misc_info, apk_key_map, key_passwords, platform_api_level, codename_to_api_level_map) common.ZipClose(input_zip) common.ZipClose(output_zip) add_img_to_target_files.AddImagesToTargetFiles(args[1]) print "done."
def main(argv): key_mapping_options = [] def option_handler(o, a): if o in ("-e", "--extra_apks"): names, key = a.split("=") names = names.split(",") for n in names: OPTIONS.extra_apks[n] = key elif o in ("-d", "--default_key_mappings"): key_mapping_options.append((None, a)) elif o in ("-k", "--key_mapping"): key_mapping_options.append(a.split("=", 1)) elif o in ("-o", "--replace_ota_keys"): OPTIONS.replace_ota_keys = True elif o in ("-t", "--tag_changes"): new = [] for i in a.split(","): i = i.strip() if not i or i[0] not in "-+": raise ValueError("Bad tag change '%s'" % (i,)) new.append(i[0] + i[1:].strip()) OPTIONS.tag_changes = tuple(new) elif o == "--replace_verity_public_key": OPTIONS.replace_verity_public_key = (True, a) elif o == "--replace_verity_private_key": OPTIONS.replace_verity_private_key = (True, a) elif o == "--replace_verity_keyid": OPTIONS.replace_verity_keyid = (True, a) elif o == "--avb_vbmeta_key": OPTIONS.avb_keys['vbmeta'] = a elif o == "--avb_vbmeta_algorithm": OPTIONS.avb_algorithms['vbmeta'] = a elif o == "--avb_vbmeta_extra_args": OPTIONS.avb_extra_args['vbmeta'] = a elif o == "--avb_boot_key": OPTIONS.avb_keys['boot'] = a elif o == "--avb_boot_algorithm": OPTIONS.avb_algorithms['boot'] = a elif o == "--avb_boot_extra_args": OPTIONS.avb_extra_args['boot'] = a elif o == "--avb_dtbo_key": OPTIONS.avb_keys['dtbo'] = a elif o == "--avb_dtbo_algorithm": OPTIONS.avb_algorithms['dtbo'] = a elif o == "--avb_dtbo_extra_args": OPTIONS.avb_extra_args['dtbo'] = a elif o == "--avb_system_key": OPTIONS.avb_keys['system'] = a elif o == "--avb_system_algorithm": OPTIONS.avb_algorithms['system'] = a elif o == "--avb_system_extra_args": OPTIONS.avb_extra_args['system'] = a elif o == "--avb_vendor_key": OPTIONS.avb_keys['vendor'] = a elif o == "--avb_vendor_algorithm": OPTIONS.avb_algorithms['vendor'] = a elif o == "--avb_vendor_extra_args": OPTIONS.avb_extra_args['vendor'] = a else: return False return True args = common.ParseOptions( argv, __doc__, extra_opts="e:d:k:ot:", extra_long_opts=[ "extra_apks=", "default_key_mappings=", "key_mapping=", "replace_ota_keys", "tag_changes=", "replace_verity_public_key=", "replace_verity_private_key=", "replace_verity_keyid=", "avb_vbmeta_algorithm=", "avb_vbmeta_key=", "avb_vbmeta_extra_args=", "avb_boot_algorithm=", "avb_boot_key=", "avb_boot_extra_args=", "avb_dtbo_algorithm=", "avb_dtbo_key=", "avb_dtbo_extra_args=", "avb_system_algorithm=", "avb_system_key=", "avb_system_extra_args=", "avb_vendor_algorithm=", "avb_vendor_key=", "avb_vendor_extra_args=", ], extra_option_handler=option_handler) if len(args) != 2: common.Usage(__doc__) sys.exit(1) input_zip = zipfile.ZipFile(args[0], "r") output_zip = zipfile.ZipFile(args[1], "w") misc_info = common.LoadInfoDict(input_zip) BuildKeyMap(misc_info, key_mapping_options) apk_key_map = GetApkCerts(input_zip) CheckAllApksSigned(input_zip, apk_key_map) key_passwords = common.GetKeyPasswords(set(apk_key_map.values())) platform_api_level, _ = GetApiLevelAndCodename(input_zip) codename_to_api_level_map = GetCodenameToApiLevelMap(input_zip) ProcessTargetFiles(input_zip, output_zip, misc_info, apk_key_map, key_passwords, platform_api_level, codename_to_api_level_map) common.ZipClose(input_zip) common.ZipClose(output_zip) # Skip building userdata.img and cache.img when signing the target files. new_args = ["--is_signing"] # add_img_to_target_files builds the system image from scratch, so the # recovery patch is guaranteed to be regenerated there. if OPTIONS.rebuild_recovery: new_args.append("--rebuild_recovery") new_args.append(args[1]) add_img_to_target_files.main(new_args) print "done."
def main(argv): key_mapping_options = [] def option_handler(o, a): if o in ("-e", "--extra_apks"): names, key = a.split("=") names = names.split(",") for n in names: OPTIONS.extra_apks[n] = key elif o == "--extra_apex_payload_key": apex_name, key = a.split("=") OPTIONS.extra_apex_payload_keys[apex_name] = key elif o == "--skip_apks_with_path_prefix": # Sanity check the prefix, which must be in all upper case. prefix = a.split('/')[0] if not prefix or prefix != prefix.upper(): raise ValueError("Invalid path prefix '%s'" % (a,)) OPTIONS.skip_apks_with_path_prefix.add(a) elif o in ("-d", "--default_key_mappings"): key_mapping_options.append((None, a)) elif o in ("-k", "--key_mapping"): key_mapping_options.append(a.split("=", 1)) elif o in ("-o", "--replace_ota_keys"): OPTIONS.replace_ota_keys = True elif o in ("-t", "--tag_changes"): new = [] for i in a.split(","): i = i.strip() if not i or i[0] not in "-+": raise ValueError("Bad tag change '%s'" % (i,)) new.append(i[0] + i[1:].strip()) OPTIONS.tag_changes = tuple(new) elif o == "--replace_verity_public_key": OPTIONS.replace_verity_public_key = (True, a) elif o == "--replace_verity_private_key": OPTIONS.replace_verity_private_key = (True, a) elif o == "--replace_verity_keyid": OPTIONS.replace_verity_keyid = (True, a) elif o == "--avb_vbmeta_key": OPTIONS.avb_keys['vbmeta'] = a elif o == "--avb_vbmeta_algorithm": OPTIONS.avb_algorithms['vbmeta'] = a elif o == "--avb_vbmeta_extra_args": OPTIONS.avb_extra_args['vbmeta'] = a elif o == "--avb_boot_key": OPTIONS.avb_keys['boot'] = a elif o == "--avb_boot_algorithm": OPTIONS.avb_algorithms['boot'] = a elif o == "--avb_boot_extra_args": OPTIONS.avb_extra_args['boot'] = a elif o == "--avb_dtbo_key": OPTIONS.avb_keys['dtbo'] = a elif o == "--avb_dtbo_algorithm": OPTIONS.avb_algorithms['dtbo'] = a elif o == "--avb_dtbo_extra_args": OPTIONS.avb_extra_args['dtbo'] = a elif o == "--avb_system_key": OPTIONS.avb_keys['system'] = a elif o == "--avb_system_algorithm": OPTIONS.avb_algorithms['system'] = a elif o == "--avb_system_extra_args": OPTIONS.avb_extra_args['system'] = a elif o == "--avb_system_other_key": OPTIONS.avb_keys['system_other'] = a elif o == "--avb_system_other_algorithm": OPTIONS.avb_algorithms['system_other'] = a elif o == "--avb_system_other_extra_args": OPTIONS.avb_extra_args['system_other'] = a elif o == "--avb_vendor_key": OPTIONS.avb_keys['vendor'] = a elif o == "--avb_vendor_algorithm": OPTIONS.avb_algorithms['vendor'] = a elif o == "--avb_vendor_extra_args": OPTIONS.avb_extra_args['vendor'] = a elif o == "--avb_vbmeta_system_key": OPTIONS.avb_keys['vbmeta_system'] = a elif o == "--avb_vbmeta_system_algorithm": OPTIONS.avb_algorithms['vbmeta_system'] = a elif o == "--avb_vbmeta_system_extra_args": OPTIONS.avb_extra_args['vbmeta_system'] = a elif o == "--avb_vbmeta_vendor_key": OPTIONS.avb_keys['vbmeta_vendor'] = a elif o == "--avb_vbmeta_vendor_algorithm": OPTIONS.avb_algorithms['vbmeta_vendor'] = a elif o == "--avb_vbmeta_vendor_extra_args": OPTIONS.avb_extra_args['vbmeta_vendor'] = a elif o == "--avb_apex_extra_args": OPTIONS.avb_extra_args['apex'] = a else: return False return True args = common.ParseOptions( argv, __doc__, extra_opts="e:d:k:ot:", extra_long_opts=[ "extra_apks=", "extra_apex_payload_key=", "skip_apks_with_path_prefix=", "default_key_mappings=", "key_mapping=", "replace_ota_keys", "tag_changes=", "replace_verity_public_key=", "replace_verity_private_key=", "replace_verity_keyid=", "avb_apex_extra_args=", "avb_vbmeta_algorithm=", "avb_vbmeta_key=", "avb_vbmeta_extra_args=", "avb_boot_algorithm=", "avb_boot_key=", "avb_boot_extra_args=", "avb_dtbo_algorithm=", "avb_dtbo_key=", "avb_dtbo_extra_args=", "avb_system_algorithm=", "avb_system_key=", "avb_system_extra_args=", "avb_system_other_algorithm=", "avb_system_other_key=", "avb_system_other_extra_args=", "avb_vendor_algorithm=", "avb_vendor_key=", "avb_vendor_extra_args=", "avb_vbmeta_system_algorithm=", "avb_vbmeta_system_key=", "avb_vbmeta_system_extra_args=", "avb_vbmeta_vendor_algorithm=", "avb_vbmeta_vendor_key=", "avb_vbmeta_vendor_extra_args=", ], extra_option_handler=option_handler) if len(args) != 2: common.Usage(__doc__) sys.exit(1) common.InitLogging() input_zip = zipfile.ZipFile(args[0], "r") output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED, allowZip64=True) misc_info = common.LoadInfoDict(input_zip) BuildKeyMap(misc_info, key_mapping_options) apk_keys_info, compressed_extension = common.ReadApkCerts(input_zip) apk_keys = GetApkCerts(apk_keys_info) apex_keys_info = ReadApexKeysInfo(input_zip) apex_keys = GetApexKeys(apex_keys_info, apk_keys) CheckApkAndApexKeysAvailable( input_zip, set(apk_keys.keys()) | set(apex_keys.keys()), compressed_extension, apex_keys) key_passwords = common.GetKeyPasswords( set(apk_keys.values()) | set(itertools.chain(*apex_keys.values()))) platform_api_level, _ = GetApiLevelAndCodename(input_zip) codename_to_api_level_map = GetCodenameToApiLevelMap(input_zip) ProcessTargetFiles(input_zip, output_zip, misc_info, apk_keys, apex_keys, key_passwords, platform_api_level, codename_to_api_level_map, compressed_extension) common.ZipClose(input_zip) common.ZipClose(output_zip) # Skip building userdata.img and cache.img when signing the target files. new_args = ["--is_signing"] # add_img_to_target_files builds the system image from scratch, so the # recovery patch is guaranteed to be regenerated there. if OPTIONS.rebuild_recovery: new_args.append("--rebuild_recovery") new_args.append(args[1]) add_img_to_target_files.main(new_args) print("done.")
def main(argv): key_mapping_options = [] def option_handler(o, a): if o in ("-e", "--extra_apks"): names, key = a.split("=") names = names.split(",") for n in names: OPTIONS.extra_apks[n] = key elif o in ("-d", "--default_key_mappings"): key_mapping_options.append((None, a)) elif o in ("-k", "--key_mapping"): key_mapping_options.append(a.split("=", 1)) elif o in ("-o", "--replace_ota_keys"): OPTIONS.replace_ota_keys = True elif o in ("-t", "--tag_changes"): new = [] for i in a.split(","): i = i.strip() if not i or i[0] not in "-+": raise ValueError("Bad tag change '%s'" % (i, )) new.append(i[0] + i[1:].strip()) OPTIONS.tag_changes = tuple(new) elif o == "--replace_verity_public_key": OPTIONS.replace_verity_public_key = (True, a) elif o == "--replace_verity_private_key": OPTIONS.replace_verity_private_key = (True, a) else: return False return True args = common.ParseOptions(argv, __doc__, extra_opts="e:d:k:ot:", extra_long_opts=[ "extra_apks=", "default_key_mappings=", "key_mapping=", "replace_ota_keys", "tag_changes=", "replace_verity_public_key=", "replace_verity_private_key=" ], extra_option_handler=option_handler) if len(args) != 2: common.Usage(__doc__) sys.exit(1) input_zip = zipfile.ZipFile(args[0], "r") output_zip = zipfile.ZipFile(args[1], "w") misc_info = common.LoadInfoDict(input_zip) BuildKeyMap(misc_info, key_mapping_options) apk_key_map = GetApkCerts(input_zip) CheckAllApksSigned(input_zip, apk_key_map) key_passwords = common.GetKeyPasswords(set(apk_key_map.values())) ProcessTargetFiles(input_zip, output_zip, misc_info, apk_key_map, key_passwords) common.ZipClose(input_zip) common.ZipClose(output_zip) add_img_to_target_files.AddImagesToTargetFiles(args[1], rebuild_recovery=True) print("done.")
def main(argv): def option_handler(o, a): if o in ("-k", "--package_key"): OPTIONS.package_key = a elif o in ("-i", "--incremental_from"): OPTIONS.incremental_source = a elif o == "--full_radio": OPTIONS.full_radio = True elif o == "--full_bootloader": OPTIONS.full_bootloader = True elif o == "--wipe_user_data": OPTIONS.wipe_user_data = True elif o == "--downgrade": OPTIONS.downgrade = True OPTIONS.wipe_user_data = True elif o == "--override_timestamp": OPTIONS.downgrade = True elif o in ("-o", "--oem_settings"): OPTIONS.oem_source = a.split(',') elif o == "--oem_no_mount": OPTIONS.oem_no_mount = True elif o in ("-e", "--extra_script"): OPTIONS.extra_script = a elif o in ("-t", "--worker_threads"): if a.isdigit(): OPTIONS.worker_threads = int(a) else: raise ValueError("Cannot parse value %r for option %r - only " "integers are allowed." % (a, o)) elif o in ("-2", "--two_step"): OPTIONS.two_step = True elif o == "--include_secondary": OPTIONS.include_secondary = True elif o == "--no_signing": OPTIONS.no_signing = True elif o == "--verify": OPTIONS.verify = True elif o == "--block": OPTIONS.block_based = True elif o in ("-b", "--binary"): OPTIONS.updater_binary = a elif o == "--stash_threshold": try: OPTIONS.stash_threshold = float(a) except ValueError: raise ValueError( "Cannot parse value %r for option %r - expecting " "a float" % (a, o)) elif o == "--log_diff": OPTIONS.log_diff = a elif o == "--payload_signer": OPTIONS.payload_signer = a elif o == "--payload_signer_args": OPTIONS.payload_signer_args = shlex.split(a) elif o == "--payload_signer_maximum_signature_size": OPTIONS.payload_signer_maximum_signature_size = a elif o == "--payload_signer_key_size": # TODO(Xunchang) remove this option after cleaning up the callers. logger.warning( "The option '--payload_signer_key_size' is deprecated." " Use '--payload_signer_maximum_signature_size' instead.") OPTIONS.payload_signer_maximum_signature_size = a elif o == "--extracted_input_target_files": OPTIONS.extracted_input = a elif o == "--skip_postinstall": OPTIONS.skip_postinstall = True elif o == "--retrofit_dynamic_partitions": OPTIONS.retrofit_dynamic_partitions = True elif o == "--skip_compatibility_check": OPTIONS.skip_compatibility_check = True elif o == "--output_metadata_path": OPTIONS.output_metadata_path = a elif o == "--disable_fec_computation": OPTIONS.disable_fec_computation = True elif o == "--force_non_ab": OPTIONS.force_non_ab = True elif o == "--boot_variable_file": OPTIONS.boot_variable_file = a else: return False return True args = common.ParseOptions(argv, __doc__, extra_opts="b:k:i:d:e:t:2o:", extra_long_opts=[ "package_key=", "incremental_from=", "full_radio", "full_bootloader", "wipe_user_data", "downgrade", "override_timestamp", "extra_script=", "worker_threads=", "two_step", "include_secondary", "no_signing", "block", "binary=", "oem_settings=", "oem_no_mount", "verify", "stash_threshold=", "log_diff=", "payload_signer=", "payload_signer_args=", "payload_signer_maximum_signature_size=", "payload_signer_key_size=", "extracted_input_target_files=", "skip_postinstall", "retrofit_dynamic_partitions", "skip_compatibility_check", "output_metadata_path=", "disable_fec_computation", "force_non_ab", "boot_variable_file=", ], extra_option_handler=option_handler) if len(args) != 2: common.Usage(__doc__) sys.exit(1) common.InitLogging() if OPTIONS.downgrade: # We should only allow downgrading incrementals (as opposed to full). # Otherwise the device may go back from arbitrary build with this full # OTA package. if OPTIONS.incremental_source is None: raise ValueError("Cannot generate downgradable full OTAs") # Load the build info dicts from the zip directly or the extracted input # directory. We don't need to unzip the entire target-files zips, because they # won't be needed for A/B OTAs (brillo_update_payload does that on its own). # When loading the info dicts, we don't need to provide the second parameter # to common.LoadInfoDict(). Specifying the second parameter allows replacing # some properties with their actual paths, such as 'selinux_fc', # 'ramdisk_dir', which won't be used during OTA generation. if OPTIONS.extracted_input is not None: OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.extracted_input) else: with zipfile.ZipFile(args[0], 'r') as input_zip: OPTIONS.info_dict = common.LoadInfoDict(input_zip) logger.info("--- target info ---") common.DumpInfoDict(OPTIONS.info_dict) # Load the source build dict if applicable. if OPTIONS.incremental_source is not None: OPTIONS.target_info_dict = OPTIONS.info_dict with zipfile.ZipFile(OPTIONS.incremental_source, 'r') as source_zip: OPTIONS.source_info_dict = common.LoadInfoDict(source_zip) logger.info("--- source info ---") common.DumpInfoDict(OPTIONS.source_info_dict) # Load OEM dicts if provided. OPTIONS.oem_dicts = _LoadOemDicts(OPTIONS.oem_source) # Assume retrofitting dynamic partitions when base build does not set # use_dynamic_partitions but target build does. if (OPTIONS.source_info_dict and OPTIONS.source_info_dict.get("use_dynamic_partitions") != "true" and OPTIONS.target_info_dict.get("use_dynamic_partitions") == "true"): if OPTIONS.target_info_dict.get( "dynamic_partition_retrofit") != "true": raise common.ExternalError( "Expect to generate incremental OTA for retrofitting dynamic " "partitions, but dynamic_partition_retrofit is not set in target " "build.") logger.info("Implicitly generating retrofit incremental OTA.") OPTIONS.retrofit_dynamic_partitions = True # Skip postinstall for retrofitting dynamic partitions. if OPTIONS.retrofit_dynamic_partitions: OPTIONS.skip_postinstall = True ab_update = OPTIONS.info_dict.get("ab_update") == "true" allow_non_ab = OPTIONS.info_dict.get("allow_non_ab") == "true" if OPTIONS.force_non_ab: assert allow_non_ab, "--force_non_ab only allowed on devices that supports non-A/B" assert ab_update, "--force_non_ab only allowed on A/B devices" generate_ab = not OPTIONS.force_non_ab and ab_update # Use the default key to sign the package if not specified with package_key. # package_keys are needed on ab_updates, so always define them if an # A/B update is getting created. if not OPTIONS.no_signing or generate_ab: if OPTIONS.package_key is None: OPTIONS.package_key = OPTIONS.info_dict.get( "default_system_dev_certificate", "build/make/target/product/security/testkey") # Get signing keys OPTIONS.key_passwords = common.GetKeyPasswords([OPTIONS.package_key]) if generate_ab: GenerateAbOtaPackage(target_file=args[0], output_file=args[1], source_file=OPTIONS.incremental_source) else: GenerateNonAbOtaPackage(target_file=args[0], output_file=args[1], source_file=OPTIONS.incremental_source) # Post OTA generation works. if OPTIONS.incremental_source is not None and OPTIONS.log_diff: logger.info("Generating diff logs...") logger.info("Unzipping target-files for diffing...") target_dir = common.UnzipTemp(args[0], TARGET_DIFFING_UNZIP_PATTERN) source_dir = common.UnzipTemp(OPTIONS.incremental_source, TARGET_DIFFING_UNZIP_PATTERN) with open(OPTIONS.log_diff, 'w') as out_file: target_files_diff.recursiveDiff('', source_dir, target_dir, out_file) logger.info("done.")
if len(args) != 2: common.Usage(__doc__) sys.exit(1) input_zip = zipfile.ZipFile(args[0], "r") output_zip = zipfile.ZipFile(args[1], "w") misc_info = common.LoadInfoDict(input_zip) BuildKeyMap(misc_info, key_mapping_options) apk_key_map = GetApkCerts(input_zip) CheckAllApksSigned(input_zip, apk_key_map) key_passwords = common.GetKeyPasswords(set(apk_key_map.values())) platform_api_level, platform_codename = GetApiLevelAndCodename(input_zip) codename_to_api_level_map = GetCodenameToApiLevelMap(input_zip) # Android N will be API Level 24, but isn't yet. # TODO: Remove this workaround once Android N is officially API Level 24. if platform_api_level == 23 and platform_codename == "N": platform_api_level = 24 ProcessTargetFiles(input_zip, output_zip, misc_info, apk_key_map, key_passwords, platform_api_level, codename_to_api_level_map) common.ZipClose(input_zip) common.ZipClose(output_zip)
input_provzip = zipfile.ZipFile(os.path.join(unpack_dir, "RADIO", prov_file), "r") print "Parsing build.prop for target_product" d = {} try: with open(os.path.join(unpack_dir, "SYSTEM", "build.prop")) as f: d = common.LoadDictionaryFromLines(f.read().split("\n")) except IOError, e: if e.errno == errno.ENOENT: raise KeyError(f) OPTIONS.target_product = d["ro.product.system.name"] print "Processing private keys" OPTIONS.info_dict = common.LoadInfoDict(input_zip) passwords = common.GetKeyPasswords(OPTIONS.all_keys) #process the provdata.zip to generate resigned one process_provzip(input_provzip, output_fastboot_fn) common.ZipClose(input_zip) print "Extract done." if __name__ == '__main__': try: main(sys.argv[1:]) except common.ExternalError, e: print print " ERROR: %s" % (e,) print sys.exit(1)