From 610754e5ad84b2e65358d85dd38a4e0c86dc9342 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 7 Jul 2015 18:31:47 -0700 Subject: Scan all init.*.rc files for flash_recovery service. Clockwork builds may rename init.rc to init.core.rc. Change the OTA script to scan all init.*.rc files to determine the proper location for install-recovery.sh. Bug: 22128990 Change-Id: If96bd0b81090683ad0bbfddb735d390204849d9f --- tools/releasetools/common.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 3c1575b..edacf7f 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -1203,18 +1203,28 @@ fi } # The install script location moved from /system/etc to /system/bin - # in the L release. Parse the init.rc file to find out where the + # in the L release. Parse init.*.rc files to find out where the # target-files expects it to be, and put it there. sh_location = "etc/install-recovery.sh" - try: - with open(os.path.join(input_dir, "BOOT", "RAMDISK", "init.rc")) as f: + found = False + init_rc_dir = os.path.join(input_dir, "BOOT", "RAMDISK") + init_rc_files = os.listdir(init_rc_dir) + for init_rc_file in init_rc_files: + if (not init_rc_file.startswith('init.') or + not init_rc_file.endswith('.rc')): + continue + + with open(os.path.join(init_rc_dir, init_rc_file)) as f: for line in f: - m = re.match("^service flash_recovery /system/(\S+)\s*$", line) + m = re.match(r"^service flash_recovery /system/(\S+)\s*$", line) if m: sh_location = m.group(1) - print "putting script in", sh_location + found = True break - except (OSError, IOError), e: - print "failed to read init.rc: %s" % (e,) + + if found: + break + + print "putting script in", sh_location output_sink(sh_location, sh) -- cgit v1.1 From 7c4c6f589e846d838136de148ae7e7d680c74d91 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 19 Aug 2015 17:07:50 -0700 Subject: sparse_img.py: Divide NONZERO blocks into groups. For squashfs, we currently don't have a system.map. So the whole system image will be treated as a single file. But for some unknown bug, the updater will be killed due to OOM when writing back the patched image to flash (observed on lenok-userdebug MEA49). Prior to getting a real fix, we evenly divide the non-zero blocks into smaller groups (currently 1024 blocks or 4MB per group). Bug: 23227672 Change-Id: Ifeddd8d802f01f8cd2a743a1d1217a284fb6e182 --- tools/releasetools/sparse_img.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py index 07f3c1c..013044f 100644 --- a/tools/releasetools/sparse_img.py +++ b/tools/releasetools/sparse_img.py @@ -210,6 +210,16 @@ class SparseImage(object): nonzero_blocks = [] reference = '\0' * self.blocksize + # Workaround for bug 23227672. For squashfs, we don't have a system.map. So + # the whole system image will be treated as a single file. But for some + # unknown bug, the updater will be killed due to OOM when writing back the + # patched image to flash (observed on lenok-userdebug MEA49). Prior to + # getting a real fix, we evenly divide the non-zero blocks into smaller + # groups (currently 1024 blocks or 4MB per group). + # Bug: 23227672 + MAX_BLOCKS_PER_GROUP = 1024 + nonzero_groups = [] + f = self.simg_f for s, e in remaining: for b in range(s, e): @@ -232,12 +242,22 @@ class SparseImage(object): nonzero_blocks.append(b) nonzero_blocks.append(b+1) - assert zero_blocks or nonzero_blocks or clobbered_blocks + if len(nonzero_blocks) >= MAX_BLOCKS_PER_GROUP: + nonzero_groups.append(nonzero_blocks) + # Clear the list. + nonzero_blocks = [] + + if nonzero_blocks: + nonzero_groups.append(nonzero_blocks) + nonzero_blocks = [] + + assert zero_blocks or nonzero_groups or clobbered_blocks if zero_blocks: out["__ZERO"] = rangelib.RangeSet(data=zero_blocks) - if nonzero_blocks: - out["__NONZERO"] = rangelib.RangeSet(data=nonzero_blocks) + if nonzero_groups: + for i, blocks in enumerate(nonzero_groups): + out["__NONZERO-%d" % i] = rangelib.RangeSet(data=blocks) if clobbered_blocks: out["__COPY"] = clobbered_blocks -- cgit v1.1 From 391562eb1166e2badbb236920cf15782551cec0e Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Wed, 10 Feb 2016 15:54:05 -0800 Subject: releasetools: Don't extract BOOTABLE_IMAGES when signing target files boot and recovery images need to be re-created during the signing process to ensure that the proper keys are embedded in the images. Don't extract the BOOTABLE_IMAGES path if it exists in the source target files to avoid re-using the prebuilt versions. Change-Id: Icdf61367efc2364f89c7ab1c61a81536431aea2e Ticket: CYNGNOS-1994 --- tools/releasetools/sign_target_files_apks.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools') diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py index 632c36f..ed7a4b7 100755 --- a/tools/releasetools/sign_target_files_apks.py +++ b/tools/releasetools/sign_target_files_apks.py @@ -178,6 +178,9 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info, if info.filename.startswith("IMAGES/"): continue + if info.filename.startswith("BOOTABLE_IMAGES/"): + continue + data = input_tf_zip.read(info.filename) out_info = copy.copy(info) -- cgit v1.1 From 620c1e59735a09828f2e326056a2a76474c0ac59 Mon Sep 17 00:00:00 2001 From: Matt Mower Date: Fri, 29 Jan 2016 18:24:16 -0600 Subject: repopick: Don't crash if change not found If change is not located, skip it. Resolves the following: Traceback (most recent call last): File "(omitted)/build/tools/repopick.py", line 258, in review = [x for x in reviews if x['number'] == change][0] IndexError: list index out of range Change-Id: I96423ddc809ac1c7994998db4e1929ca813f20ca --- tools/repopick.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index 64db7bf..1840a56 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -255,7 +255,11 @@ if __name__ == '__main__': continue change = int(change) - review = [x for x in reviews if x['number'] == change][0] + review = next((x for x in reviews if x['number'] == change), None) + if review is None: + print('Change %d not found, skipping' % change) + continue + mergables.append({ 'subject': review['subject'], 'project': review['project'], -- cgit v1.1 From 78479274e4ca2617646755b3d0197d1e232c24a6 Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Tue, 16 Feb 2016 17:47:46 -0800 Subject: releasetools: Store the proper base64 release key in the target files This code was dropped when the original change (I7528a8e7c484ea9209cd665b9263328ae834586a) was cherry-picked into 13.0. Add it back in to the sign_target_files_apks.py file. Change-Id: I0177a7d2a39ae03b21d0b2b4ad48a621ca5afd7b Ticket: CYNGNOS-2067 --- tools/releasetools/sign_target_files_apks.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools') diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py index ed7a4b7..abdb845 100755 --- a/tools/releasetools/sign_target_files_apks.py +++ b/tools/releasetools/sign_target_files_apks.py @@ -398,6 +398,14 @@ def ReplaceOtaKeys(input_tf_zip, output_tf_zip, misc_info): common.ZipWriteStr(output_tf_zip, "RECOVERY/RAMDISK/res/keys", new_recovery_keys) + # Save the base64 key representation in the update for key-change + # validations + p = common.Run(["python", "build/tools/getb64key.py", mapped_keys[0]], + stdout=subprocess.PIPE) + data, _ = p.communicate() + if p.returncode == 0: + common.ZipWriteStr(output_tf_zip, "META/releasekey.txt", data) + # SystemUpdateActivity uses the x509.pem version of the keys, but # put into a zipfile system/etc/security/otacerts.zip. # We DO NOT include the extra_recovery_keys (if any) here. -- cgit v1.1 From e2b09b24fbce958f59815b4eaec50f26f8d67851 Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Mon, 2 Nov 2015 17:26:07 -0800 Subject: ota_from_target_files: Don't validate data signatures with data wipe If data is going to be wiped later in the script, there is no reason to validate signatures. This breaks updates that may be designed to wipe data and change signatures. Change-Id: I0b794b43cec2d22996eaa5571688c66582475d55 Ticket: CYNGNOS-1289 --- tools/releasetools/ota_from_target_files.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index ff0ccb9..bc40873 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -637,13 +637,14 @@ else if get_stage("%(bcb_dev)s") == "3/3" then if HasVendorPartition(input_zip): system_progress -= 0.1 - script.AppendExtra("if is_mounted(\"/data\") then") - script.ValidateSignatures("data") - script.AppendExtra("else") - script.Mount("/data") - script.ValidateSignatures("data") - script.Unmount("/data") - script.AppendExtra("endif;") + if not OPTIONS.wipe_user_data: + script.AppendExtra("if is_mounted(\"/data\") then") + script.ValidateSignatures("data") + script.AppendExtra("else") + script.Mount("/data") + script.ValidateSignatures("data") + script.Unmount("/data") + script.AppendExtra("endif;") if "selinux_fc" in OPTIONS.info_dict: WritePolicyConfig(OPTIONS.info_dict["selinux_fc"], output_zip) -- cgit v1.1 From c34b558c9b6d31e1632e673e4734dc7a80643b61 Mon Sep 17 00:00:00 2001 From: Artefvck 07 Date: Thu, 4 Feb 2016 09:37:15 -0800 Subject: releasetool: add OSIP partitions specifics - Declare OSIP as a new partition type - Standard boot.img update is not possible for OSIP partitions We are simply removing it on AOSP handling, and let the board handle it in its own releasetool.py Change-Id: Ie19fc3f6a0ca42e2eda264904b20fceeddbeaf53 --- tools/releasetools/common.py | 5 +++-- tools/releasetools/edify_generator.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 4f8db79..cd35023 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -1402,7 +1402,8 @@ PARTITION_TYPES = { "squashfs": "EMMC", "ext2": "EMMC", "ext3": "EMMC", - "vfat": "EMMC" + "vfat": "EMMC", + "osip": "OSIP" } def GetTypeAndDevice(mount_point, info): @@ -1503,4 +1504,4 @@ fi except (OSError, IOError) as e: print("failed to read init.rc: %s" % e) - output_sink(sh_location, sh) + output_sink(sh_location, sh) \ No newline at end of file diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index 80b8a44..825a7eb 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -323,6 +323,10 @@ class EdifyGenerator(object): self.script.append( 'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");' % args) + elif partition_type == "OSIP": + self.script.append( + 'write_osip_image(package_extract_file("%(fn)s"), "%(device)s");' + % args) elif partition_type == "EMMC": if mapfn: args["map"] = mapfn -- cgit v1.1