def AddCache(output_zip, prefix="IMAGES/"): """Create an empty cache image and store it in output_zip.""" prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") if os.path.exists(prebuilt_path): print("cache.img already exists in %s, no need to rebuild..." % prefix) return image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") # The build system has to explicitly request for cache.img. if "fs_type" not in image_props: return print("creating cache.img...") # Use a fixed timestamp (01/01/2009) when packaging the image. # Bug: 24377993 epoch = datetime.datetime.fromtimestamp(0) timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds() image_props["timestamp"] = int(timestamp) # The name of the directory it is making an image out of matters to # mkyaffs2image. So we create a temp dir, and within it we create an # empty dir named "cache", and build the image from that. temp_dir = tempfile.mkdtemp() user_dir = os.path.join(temp_dir, "cache") os.mkdir(user_dir) img = tempfile.NamedTemporaryFile() fstab = OPTIONS.info_dict["fstab"] if fstab: image_props["fs_type"] = fstab["/cache"].fs_type succ = build_image.BuildImage(user_dir, image_props, img.name) assert succ, "build cache.img image failed" common.CheckSize(img.name, "cache.img", OPTIONS.info_dict) common.ZipWrite(output_zip, img.name, prefix + "cache.img") img.close() os.rmdir(user_dir) os.rmdir(temp_dir)
def AddUserdata(output_zip): """Create a userdata image and store it in output_zip. In most case we just create and store an empty userdata.img; But the invoker can also request to create userdata.img with real data from the target files, by setting "userdata_img_with_data=true" in OPTIONS.info_dict. """ img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "userdata.img") if os.path.exists(img.input_name): print("userdata.img already exists; no need to rebuild...") return # Skip userdata.img if no size. image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "data") if not image_props.get("partition_size"): return print("creating userdata.img...") # Use a fixed timestamp (01/01/2009) when packaging the image. # Bug: 24377993 epoch = datetime.datetime.fromtimestamp(0) timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds() image_props["timestamp"] = int(timestamp) if OPTIONS.info_dict.get("userdata_img_with_data") == "true": user_dir = os.path.join(OPTIONS.input_tmp, "DATA") else: user_dir = common.MakeTempDir() fstab = OPTIONS.info_dict["fstab"] if fstab: image_props["fs_type"] = fstab["/data"].fs_type succ = build_image.BuildImage(user_dir, image_props, img.name) assert succ, "build userdata.img image failed" common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict) img.Write()
def FullOTA_InstallEnd(info): print "amlogic extensions:FullOTA_InstallEnd" bootloader_img_exist = 0 try: bootloader_img_info = info.input_zip.getinfo("BOOTLOADER/bootloader") bootloader_img_exist = 1 bootloader_img = common.File( "bootloader.img", info.input_zip.read("BOOTLOADER/bootloader")) except KeyError: print 'WARNING: No BOOTLOADER found' if bootloader_img_exist: common.CheckSize(bootloader_img.data, "bootloader.img", info.info_dict) common.ZipWriteStr(info.output_zip, "bootloader.img", bootloader_img.data) info.script.WriteBootloaderImage("/bootloader", "bootloader.img") SetBootloaderEnv(info.script, "upgrade_step", "1") else: SetBootloaderEnv(info.script, "upgrade_step", "1") SetBootloaderEnv(info.script, "force_auto_update", "false")
def AddCache(output_zip): """Create an empty cache image and store it in output_zip.""" img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "cache.img") if os.path.exists(img.name): logger.info("cache.img already exists; no need to rebuild...") return image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") # The build system has to explicitly request for cache.img. if "fs_type" not in image_props: return logger.info("creating cache.img...") image_props["timestamp"] = FIXED_FILE_TIMESTAMP user_dir = common.MakeTempDir() build_image.BuildImage(user_dir, image_props, img.name) common.CheckSize(img.name, "cache.img", OPTIONS.info_dict) img.Write()
def AddUserdata(output_zip, prefix="IMAGES/"): """Create an empty userdata image and store it in output_zip.""" prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img") if os.path.exists(prebuilt_path): print "userdata.img already exists in %s, no need to rebuild..." % ( prefix, ) return image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "data") # We only allow yaffs to have a 0/missing partition_size. # Extfs, f2fs must have a size. Skip userdata.img if no size. if (not image_props.get("fs_type", "").startswith("yaffs") and not image_props.get("partition_size")): return print "creating userdata.img..." # The name of the directory it is making an image out of matters to # mkyaffs2image. So we create a temp dir, and within it we create an # empty dir named "data", and build the image from that. temp_dir = tempfile.mkdtemp() user_dir = os.path.join(temp_dir, "data") os.mkdir(user_dir) img = tempfile.NamedTemporaryFile() fstab = OPTIONS.info_dict["fstab"] if fstab: image_props["fs_type"] = fstab["/data"].fs_type succ = build_image.BuildImage(user_dir, image_props, img.name) assert succ, "build userdata.img image failed" common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict) output_zip.write(img.name, prefix + "userdata.img") img.close() os.rmdir(user_dir) os.rmdir(temp_dir)
def AddUserdata(output_zip): """Create a userdata image and store it in output_zip. In most case we just create and store an empty userdata.img; But the invoker can also request to create userdata.img with real data from the target files, by setting "userdata_img_with_data=true" in OPTIONS.info_dict. """ img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "userdata.img") if os.path.exists(img.name): logger.info("userdata.img already exists; no need to rebuild...") return # Skip userdata.img if no size. image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "data") if not image_props.get("partition_size"): return logger.info("creating userdata.img...") image_props["timestamp"] = FIXED_FILE_TIMESTAMP if OPTIONS.info_dict.get("userdata_img_with_data") == "true": user_dir = os.path.join(OPTIONS.input_tmp, "DATA") else: user_dir = common.MakeTempDir() fstab = OPTIONS.info_dict["fstab"] if fstab: image_props["fs_type"] = fstab["/data"].fs_type build_image.BuildImage(user_dir, image_props, img.name) common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict) img.Write()
def AddCache(output_zip, prefix="IMAGES/"): """Create an empty cache image and store it in output_zip.""" prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") if os.path.exists(prebuilt_path): print "cache.img already exists in %s, no need to rebuild..." % ( prefix, ) return image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") # The build system has to explicitly request for cache.img. if "fs_type" not in image_props: return print "creating cache.img..." # The name of the directory it is making an image out of matters to # mkyaffs2image. So we create a temp dir, and within it we create an # empty dir named "cache", and build the image from that. temp_dir = tempfile.mkdtemp() user_dir = os.path.join(temp_dir, "cache") os.mkdir(user_dir) img = tempfile.NamedTemporaryFile() fstab = OPTIONS.info_dict["fstab"] if fstab: image_props["fs_type"] = fstab["/cache"].fs_type succ = build_image.BuildImage(user_dir, image_props, img.name) assert succ, "build cache.img image failed" common.CheckSize(img.name, "cache.img", OPTIONS.info_dict) output_zip.write(img.name, prefix + "cache.img") img.close() os.rmdir(user_dir) os.rmdir(temp_dir)
def WriteFullOTAPackage(input_zip, output_file): target_info = common.BuildInfo(OPTIONS.info_dict, OPTIONS.oem_dicts) # We don't know what version it will be installed on top of. We expect the API # just won't change very often. Similarly for fstab, it might have changed in # the target build. target_api_version = target_info["recovery_api_version"] script = edify_generator.EdifyGenerator(target_api_version, target_info) if target_info.oem_props and not OPTIONS.oem_no_mount: target_info.WriteMountOemScript(script) metadata = GetPackageMetadata(target_info) if not OPTIONS.no_signing: staging_file = common.MakeTempFile(suffix='.zip') else: staging_file = output_file output_zip = zipfile.ZipFile( staging_file, "w", compression=zipfile.ZIP_DEFLATED) device_specific = common.DeviceSpecificParams( input_zip=input_zip, input_version=target_api_version, output_zip=output_zip, script=script, input_tmp=OPTIONS.input_tmp, metadata=metadata, info_dict=OPTIONS.info_dict) assert HasRecoveryPatch(input_zip, info_dict=OPTIONS.info_dict) # Assertions (e.g. downgrade check, device properties check). #ts = target_info.GetBuildProp("ro.build.date.utc") #ts_text = target_info.GetBuildProp("ro.build.date") #script.AssertOlderBuild(ts, ts_text) target_info.WriteDeviceAssertions(script, OPTIONS.oem_no_mount) device_specific.FullOTA_Assertions() block_diff_dict = GetBlockDifferences(target_zip=input_zip, source_zip=None, target_info=target_info, source_info=None, device_specific=device_specific) # Two-step package strategy (in chronological order, which is *not* # the order in which the generated script has things): # # if stage is not "2/3" or "3/3": # write recovery image to boot partition # set stage to "2/3" # reboot to boot partition and restart recovery # else if stage is "2/3": # write recovery image to recovery partition # set stage to "3/3" # reboot to recovery partition and restart recovery # else: # (stage must be "3/3") # set stage to "" # do normal full package installation: # wipe and install system, boot image, etc. # set up system to update recovery partition on first boot # complete script normally # (allow recovery to mark itself finished and reboot) #recovery_img = common.GetBootableImage("recovery.img", "recovery.img", # OPTIONS.input_tmp, "RECOVERY") if OPTIONS.two_step: if not target_info.get("multistage_support"): assert False, "two-step packages not supported by this build" fs = target_info["fstab"]["/misc"] assert fs.fs_type.upper() == "EMMC", \ "two-step packages only supported on devices with EMMC /misc partitions" bcb_dev = {"bcb_dev": fs.device} common.ZipWriteStr(output_zip, "recovery.img", recovery_img.data) script.AppendExtra(""" if get_stage("%(bcb_dev)s") == "2/3" then """ % bcb_dev) # Stage 2/3: Write recovery image to /recovery (currently running /boot). script.Comment("Stage 2/3") #script.WriteRawImage("/recovery", "recovery.img") script.AppendExtra(""" set_stage("%(bcb_dev)s", "3/3"); reboot_now("%(bcb_dev)s", "recovery"); else if get_stage("%(bcb_dev)s") == "3/3" then """ % bcb_dev) # Stage 3/3: Make changes. script.Comment("Stage 3/3") # Dump fingerprints script.Print("Target: {}".format(target_info.fingerprint)) androidver = target_info.GetBuildProp("ro.build.version.release") buildid = target_info.GetBuildProp("ro.build.id") builddate = target_info.GetBuildProp("ro.build.date") securep = target_info.GetBuildProp("ro.build.version.security_patch") name = target_info.GetBuildProp("ro.product.name") model = target_info.GetBuildProp("ro.product.model") manufacturer = target_info.GetBuildProp("ro.product.manufacturer") builduser = target_info.GetBuildProp("ro.build.user") buildsdk = target_info.GetBuildProp("ro.build.version.sdk") # Start output script.Print("----------------------------------------------") script.Print(" _____ _ _ _ _ ___ ") script.Print(" _____ _|_ _| | | |_ __ ___ | | | |_ _|") script.Print(" / _ \ \/ / | | | |_| | '_ ` _ \ | | | || |") script.Print("| __/> < | | | _ | | | | | | | |_| || |") script.Print(" \___/_/\_\ |_| |_| |_|_| |_| |_| \___/|___|") script.Print("") script.Print(" extended TouHou modified UI") script.Print(" Based on AOSP") script.Print("----------------------------------------------") script.Print("ROM Information :") script.Print("Build Date : %s"%(builddate)) script.Print("Android Version : %s"%(androidver)) script.Print("exTHmUI Version : %s"%(buildid)) script.Print("SDK Version : %s"%(buildsdk)) script.Print("Security Patch Date: %s"%(securep)) script.Print("----------------------------------------------") script.Print("Device Information :") script.Print("Manufacturer : %s"%(manufacturer)) script.Print("Name : %s"%(name)) script.Print("Model : %s"%(model)) script.Print("----------------------------------------------") script.Print("Installing exTHmUI to your device...") script.Print("") device_specific.FullOTA_InstallBegin() CopyInstallTools(output_zip) script.UnpackPackageDir("install", "/tmp/install") script.SetPermissionsRecursive("/tmp/install", 0, 0, 0o755, 0o644, None, None) script.SetPermissionsRecursive("/tmp/install/bin", 0, 0, 0o755, 0o755, None, None) if target_info.get("system_root_image") == "true": sysmount = "/" else: sysmount = "/system" if OPTIONS.backuptool: script.RunBackup("backup", sysmount, target_info.get('use_dynamic_partitions') == "true") # All other partitions as well as the data wipe use 10% of the progress, and # the update of the system partition takes the remaining progress. system_progress = 0.9 - (len(block_diff_dict) - 1) * 0.1 if OPTIONS.wipe_user_data: system_progress -= 0.1 progress_dict = {partition: 0.1 for partition in block_diff_dict} progress_dict["system"] = system_progress if target_info.get('use_dynamic_partitions') == "true": # Use empty source_info_dict to indicate that all partitions / groups must # be re-added. dynamic_partitions_diff = common.DynamicPartitionsDifference( info_dict=OPTIONS.info_dict, block_diffs=block_diff_dict.values(), progress_dict=progress_dict, build_without_vendor=(not HasPartition(input_zip, "vendor"))) dynamic_partitions_diff.WriteScript(script, output_zip, write_verify_script=OPTIONS.verify) else: for block_diff in block_diff_dict.values(): block_diff.WriteScript(script, output_zip, progress=progress_dict.get(block_diff.partition), write_verify_script=OPTIONS.verify) CheckVintfIfTrebleEnabled(OPTIONS.input_tmp, target_info) boot_img = common.GetBootableImage( "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") common.CheckSize(boot_img.data, "boot.img", target_info) common.ZipWriteStr(output_zip, "boot.img", boot_img.data) device_specific.FullOTA_PostValidate() if OPTIONS.backuptool: script.ShowProgress(0.02, 10) script.RunBackup("restore", sysmount, target_info.get('use_dynamic_partitions') == "true") script.WriteRawImage("/boot", "boot.img") script.ShowProgress(0.1, 10) device_specific.FullOTA_InstallEnd() if OPTIONS.extra_script is not None: script.AppendExtra(OPTIONS.extra_script) script.UnmountAll() if OPTIONS.wipe_user_data: script.ShowProgress(0.1, 10) script.FormatPartition("/data") if OPTIONS.two_step: script.AppendExtra(""" set_stage("%(bcb_dev)s", ""); """ % bcb_dev) script.AppendExtra("else\n") # Stage 1/3: Nothing to verify for full OTA. Write recovery image to /boot. script.Comment("Stage 1/3") _WriteRecoveryImageToBoot(script, output_zip) script.AppendExtra(""" set_stage("%(bcb_dev)s", "2/3"); reboot_now("%(bcb_dev)s", ""); endif; endif; """ % bcb_dev) script.SetProgress(1) script.AddToZip(input_zip, output_zip, input_path=OPTIONS.updater_binary) metadata.required_cache = script.required_cache # We haven't written the metadata entry, which will be done in # FinalizeMetadata. common.ZipClose(output_zip) needed_property_files = ( NonAbOtaPropertyFiles(), ) FinalizeMetadata(metadata, staging_file, output_file, needed_property_files)
def FullUpdateToPartition(self): mount_point = self.partition.mount_point extract = self.IsExtract() if extract: if self.need_extract is not None: mount_point = self.need_extract self.script.Print("extract " + self.target.file_name + " to " + mount_point + " ....") else: self.script.Print("write " + self.target.file_name + " to partition " + mount_point + " ....") self.FormatPartition() if not extract or self.need_extract is None: mount_point_temp = mount_point[1:] common.CheckSize(self.target.bin.data, mount_point_temp, self.options.info_dict) p = self.options.info_dict["fstab"].get(self.mount_point, None) if p is not None: p1 = None pt_dev1 = None else: p = self.options.info_dict["fstab"][self.mount_point2] p1 = self.options.info_dict["fstab"][self.mount_point3] pt_dev1 = p1.device if p is None: raise common.ExternalError("no partion %s in fstab" % (self.mount_point2)) if p1 is None: print("no partion %s in fstab" % (self.mount_point3)) pt_dev = p.device if extract: self.script_ext.UnpackPackageFile( self.target.file_name, os.path.join(mount_point, self.target.file_name)) else: if p.secureboot: extract_path = os.path.join(OPTIONS.cache_path, self.target.file_name) self.script_ext.UnpackPackageFile(self.target.file_name, extract_path) self.script_ext.WritePartitionImage(p, extract_path, pt_dev) self.script.DeleteFiles([extract_path]) else: self.script.WriteRawImage(mount_point, self.target.file_name) if self.nv_merge: nvmerge_exe = os.path.join(OPTIONS.tmp_path, "nvmerge") nvmerge_cfg = os.path.join(OPTIONS.tmp_path, "nvmerge.cfg") new_nv = os.path.join(OPTIONS.cache_path, self.target.file_name) merged_nv = os.path.join(OPTIONS.cache_path, "merged_" + self.target.file_name) self.script_ext.Run_program(nvmerge_exe, nvmerge_cfg, self.GetRealDevicePath(p, pt_dev), new_nv, merged_nv, self.GetFixNvSize()) self.script_ext.WritePartitionImage(p, merged_nv, pt_dev) if p1 is not None: self.script_ext.WritePartitionImage(p1, merged_nv, pt_dev1) self.script.DeleteFiles([new_nv, merged_nv]) if self.spl_merge: new_spl = os.path.join(OPTIONS.cache_path, self.target.file_name) self.script_ext.MergeSpl(p, new_spl, pt_dev) self.script.DeleteFiles([new_spl])
def WriteFullOTAPackage(input_zip, output_file): target_info = common.BuildInfo(OPTIONS.info_dict, OPTIONS.oem_dicts) # We don't know what version it will be installed on top of. We expect the API # just won't change very often. Similarly for fstab, it might have changed in # the target build. target_api_version = target_info["recovery_api_version"] script = edify_generator.EdifyGenerator(target_api_version, target_info) if target_info.oem_props and not OPTIONS.oem_no_mount: target_info.WriteMountOemScript(script) metadata = GetPackageMetadata(target_info) if not OPTIONS.no_signing: staging_file = common.MakeTempFile(suffix='.zip') else: staging_file = output_file output_zip = zipfile.ZipFile(staging_file, "w", compression=zipfile.ZIP_DEFLATED) device_specific = common.DeviceSpecificParams( input_zip=input_zip, input_version=target_api_version, output_zip=output_zip, script=script, input_tmp=OPTIONS.input_tmp, metadata=metadata, info_dict=OPTIONS.info_dict) assert HasRecoveryPatch(input_zip, info_dict=OPTIONS.info_dict) # Assertions (e.g. downgrade check, device properties check). ts = target_info.GetBuildProp("ro.build.date.utc") ts_text = target_info.GetBuildProp("ro.build.date") script.AssertOlderBuild(ts, ts_text) target_info.WriteDeviceAssertions(script, OPTIONS.oem_no_mount) device_specific.FullOTA_Assertions() block_diff_dict = GetBlockDifferences(target_zip=input_zip, source_zip=None, target_info=target_info, source_info=None, device_specific=device_specific) # Two-step package strategy (in chronological order, which is *not* # the order in which the generated script has things): # # if stage is not "2/3" or "3/3": # write recovery image to boot partition # set stage to "2/3" # reboot to boot partition and restart recovery # else if stage is "2/3": # write recovery image to recovery partition # set stage to "3/3" # reboot to recovery partition and restart recovery # else: # (stage must be "3/3") # set stage to "" # do normal full package installation: # wipe and install system, boot image, etc. # set up system to update recovery partition on first boot # complete script normally # (allow recovery to mark itself finished and reboot) #recovery_img = common.GetBootableImage("recovery.img", "recovery.img", # OPTIONS.input_tmp, "RECOVERY") if OPTIONS.two_step: if not target_info.get("multistage_support"): assert False, "two-step packages not supported by this build" fs = target_info["fstab"]["/misc"] assert fs.fs_type.upper() == "EMMC", \ "two-step packages only supported on devices with EMMC /misc partitions" bcb_dev = {"bcb_dev": fs.device} common.ZipWriteStr(output_zip, "recovery.img", recovery_img.data) script.AppendExtra(""" if get_stage("%(bcb_dev)s") == "2/3" then """ % bcb_dev) # Stage 2/3: Write recovery image to /recovery (currently running /boot). script.Comment("Stage 2/3") #script.WriteRawImage("/recovery", "recovery.img") script.AppendExtra(""" set_stage("%(bcb_dev)s", "3/3"); reboot_now("%(bcb_dev)s", "recovery"); else if get_stage("%(bcb_dev)s") == "3/3" then """ % bcb_dev) # Stage 3/3: Make changes. script.Comment("Stage 3/3") # Dump fingerprints script.Print("Target: {}".format(target_info.fingerprint)) script.AppendExtra( "ifelse(is_mounted(\"/system\"), unmount(\"/system\"));") device_specific.FullOTA_InstallBegin() # All other partitions as well as the data wipe use 10% of the progress, and # the update of the system partition takes the remaining progress. system_progress = 0.9 - (len(block_diff_dict) - 1) * 0.1 if OPTIONS.wipe_user_data: system_progress -= 0.1 progress_dict = {partition: 0.1 for partition in block_diff_dict} progress_dict["system"] = system_progress if target_info.get('use_dynamic_partitions') == "true": # Use empty source_info_dict to indicate that all partitions / groups must # be re-added. dynamic_partitions_diff = common.DynamicPartitionsDifference( info_dict=OPTIONS.info_dict, block_diffs=block_diff_dict.values(), progress_dict=progress_dict) dynamic_partitions_diff.WriteScript(script, output_zip, write_verify_script=OPTIONS.verify) else: for block_diff in block_diff_dict.values(): block_diff.WriteScript(script, output_zip, progress=progress_dict.get( block_diff.partition), write_verify_script=OPTIONS.verify) CheckVintfIfTrebleEnabled(OPTIONS.input_tmp, target_info) boot_img = common.GetBootableImage("boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") common.CheckSize(boot_img.data, "boot.img", target_info) common.ZipWriteStr(output_zip, "boot.img", boot_img.data) script.WriteRawImage("/boot", "boot.img") script.ShowProgress(0.1, 10) device_specific.FullOTA_InstallEnd() if OPTIONS.extra_script is not None: script.AppendExtra(OPTIONS.extra_script) script.UnmountAll() if OPTIONS.wipe_user_data: script.ShowProgress(0.1, 10) script.FormatPartition("/data") if OPTIONS.two_step: script.AppendExtra(""" set_stage("%(bcb_dev)s", ""); """ % bcb_dev) script.AppendExtra("else\n") # Stage 1/3: Nothing to verify for full OTA. Write recovery image to /boot. script.Comment("Stage 1/3") _WriteRecoveryImageToBoot(script, output_zip) script.AppendExtra(""" set_stage("%(bcb_dev)s", "2/3"); reboot_now("%(bcb_dev)s", ""); endif; endif; """ % bcb_dev) script.SetProgress(1) script.AddToZip(input_zip, output_zip, input_path=OPTIONS.updater_binary) metadata.required_cache = script.required_cache # We haven't written the metadata entry, which will be done in # FinalizeMetadata. common.ZipClose(output_zip) needed_property_files = (NonAbOtaPropertyFiles(), ) FinalizeMetadata(metadata, staging_file, output_file, needed_property_files)
def WriteFullOTAPackage(input_zip, output_zip): # TODO: how to determine this? We don't know what version it will # be installed on top of. For now, we expect the API just won't # change very often. script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict) if OPTIONS.override_prop: metadata = { "post-timestamp": GetBuildProp("ro.build.date.utc", OPTIONS.info_dict), } else: metadata = { "post-build": GetBuildProp("ro.build.fingerprint", OPTIONS.info_dict), "pre-device": GetBuildProp("ro.product.device", OPTIONS.info_dict), "post-timestamp": GetBuildProp("ro.build.date.utc", OPTIONS.info_dict), } device_specific = common.DeviceSpecificParams( input_zip=input_zip, input_version=OPTIONS.info_dict["recovery_api_version"], output_zip=output_zip, script=script, input_tmp=OPTIONS.input_tmp, metadata=metadata, info_dict=OPTIONS.info_dict) #if not OPTIONS.omit_prereq: # ts = GetBuildProp("ro.build.date.utc", OPTIONS.info_dict) # ts_text = GetBuildProp("ro.build.date", OPTIONS.info_dict) # script.AssertOlderBuild(ts, ts_text) AppendAssertions(script, OPTIONS.info_dict) device_specific.FullOTA_Assertions() device_specific.FullOTA_InstallBegin() if OPTIONS.backuptool: script.Mount("/system") script.RunBackup("backup") script.Unmount("/system") script.ShowProgress(0.5, 0) if OPTIONS.wipe_user_data: script.FormatPartition("/data") if "selinux_fc" in OPTIONS.info_dict: WritePolicyConfig(OPTIONS.info_dict["selinux_fc"], output_zip) script.FormatPartition("/system") script.Mount("/system") #script.UnpackPackageDir("recovery", "/system") script.UnpackPackageDir("system", "/system") symlinks = CopySystemFiles(input_zip, output_zip) script.MakeSymlinks(symlinks) boot_img = common.GetBootableImage("boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") #recovery_img = common.GetBootableImage("recovery.img", "recovery.img", # OPTIONS.input_tmp, "RECOVERY") #MakeRecoveryPatch(OPTIONS.input_tmp, output_zip, recovery_img, boot_img) Item.GetMetadata(input_zip) Item.Get("system").SetPermissions(script) common.CheckSize(boot_img.data, "boot.img", OPTIONS.info_dict) common.ZipWriteStr(output_zip, "boot.img", boot_img.data) script.ShowProgress(0.2, 0) if OPTIONS.backuptool: script.ShowProgress(0.2, 10) script.RunBackup("restore") script.ShowProgress(0.2, 10) script.WriteRawImage("/boot", "boot.img") script.ShowProgress(0.1, 0) device_specific.FullOTA_InstallEnd() if OPTIONS.extra_script is not None: script.AppendExtra(OPTIONS.extra_script) script.UnmountAll() script.AddToZip(input_zip, output_zip) WriteMetadata(metadata, output_zip)