From 85fe6388fec3c57726e84724d565ce793990f4bc Mon Sep 17 00:00:00 2001 From: Abhishek G Date: Mon, 4 Apr 2016 17:03:24 -0700 Subject: Preventing default locale from being overridden because of buildinfo.sh Adding the ability to set default locale from the device tree. Adding the TARGET_SKIP_DEFAULT_LOCALE flag which can be set in the device tree, thus preventing buildinfo.sh from overriding default locale. Change-Id: I66bcedb42216acee56ceaf657a39dc23d7eea6f4 Issue-Id: FEIJ-22 --- tools/buildinfo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh index 559cd88..c621859 100755 --- a/tools/buildinfo.sh +++ b/tools/buildinfo.sh @@ -37,7 +37,7 @@ echo "ro.product.cpu.abilist32=$TARGET_CPU_ABI_LIST_32_BIT" echo "ro.product.cpu.abilist64=$TARGET_CPU_ABI_LIST_64_BIT" echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER" -if [ -n "$PRODUCT_DEFAULT_LOCALE" ] ; then +if [ -n "$PRODUCT_DEFAULT_LOCALE" ] && [ -z "$TARGET_SKIP_DEFAULT_LOCALE" ] ; then echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE" fi echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS" -- cgit v1.1 From c9c78dbd214d3ca9e79788c3406a40cb80638dcb Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Fri, 4 Sep 2015 11:59:13 +0100 Subject: build: Create a oem image when BOARD_OEMIMAGE_FILE_SYSTEM_TYPE is defined This adds the capability of generating a OEM image with the build and adding it to target files when BOARD_OEMIMAGE_FILE_SYSTEM_TYPE is set. Change-Id: I6c596d58d9d5ece1a261d953eeb8c60eac30e642 Ticket: CYNGNOS-936 (cherry picked from commit 1966a9e7c22b95eb4c16be6aee7adf43cb6ce118) --- tools/releasetools/add_img_to_target_files.py | 33 +++++++++++++++++++++++++++ tools/releasetools/img_from_target_files.py | 6 +++++ 2 files changed, 39 insertions(+) (limited to 'tools') diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index b132963..b699135 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -100,6 +100,29 @@ def BuildVendor(input_dir, info_dict, block_list=None): file containing it.""" return CreateImage(input_dir, info_dict, "vendor", block_list=block_list) +def AddOem(output_zip, prefix="IMAGES/"): + """Turn the contents of OEM into a oem image and store in it + output_zip.""" + + prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "oem.img") + if os.path.exists(prebuilt_path): + print("oem.img already exists in %s, no need to rebuild..." % prefix) + return + + block_list = common.MakeTempFile(prefix="oem-blocklist-", suffix=".map") + imgname = BuildOem(OPTIONS.input_tmp, OPTIONS.info_dict, + block_list=block_list) + with open(imgname, "rb") as f: + common.ZipWriteStr(output_zip, prefix + "oem.img", f.read()) + with open(block_list, "rb") as f: + common.ZipWriteStr(output_zip, prefix + "oem.map", f.read()) + + +def BuildOem(input_dir, info_dict, block_list=None): + """Build the (sparse) oem image and return the name of a temp + file containing it.""" + return CreateImage(input_dir, info_dict, "oem", block_list=block_list) + def CreateImage(input_dir, info_dict, what, block_list=None): print("creating " + what + ".img...") @@ -314,6 +337,12 @@ def AddImagesToTargetFiles(filename): except KeyError: has_vendor = False + try: + input_zip.getinfo("OEM/") + has_oem = True + except KeyError: + has_oem = False + OPTIONS.info_dict = common.LoadInfoDict(input_zip) if "selinux_fc" in OPTIONS.info_dict: OPTIONS.info_dict["selinux_fc"] = os.path.join( @@ -365,6 +394,10 @@ def AddImagesToTargetFiles(filename): AddUserdataExtra(output_zip) banner("cache") AddCache(output_zip) + if has_oem: + banner("oem") + AddOem(output_zip) + common.ZipClose(output_zip) diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py index d486a7a..e9f9af6 100755 --- a/tools/releasetools/img_from_target_files.py +++ b/tools/releasetools/img_from_target_files.py @@ -165,6 +165,12 @@ def main(argv): add_img_to_target_files.AddUserdataExtra(output_zip, prefix="") banner("AddCache") add_img_to_target_files.AddCache(output_zip, prefix="") + try: + input_zip.getinfo("OEM/") + banner("AddOem") + add_img_to_target_files.AddOem(output_zip, prefix="") + except KeyError: + pass # no oem partition for this device finally: print("cleaning up...") -- cgit v1.1 From 06a72275fb859eaffd879c22f86b87a0e3f36e87 Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Fri, 15 Apr 2016 23:03:14 -0700 Subject: build: skip 'ro.product.device' using new macro "TARGET_SKIP_PRODUCT_DEVICE" Change-Id: Id17ef7de8b0146dd6e4b2cc3cc5b88453da38f6c Ticket: FEIJ-62 --- tools/buildinfo.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh index c621859..fa717b7 100755 --- a/tools/buildinfo.sh +++ b/tools/buildinfo.sh @@ -46,7 +46,9 @@ echo "ro.board.platform=$TARGET_BOARD_PLATFORM" if [ "$TARGET_UNIFIED_DEVICE" == "" ] ; then echo "# ro.build.product is obsolete; use ro.product.device" echo "ro.build.product=$TARGET_DEVICE" - echo "ro.product.model=$PRODUCT_MODEL" + if [ -z "$TARGET_SKIP_PRODUCT_DEVICE" ] ; then + echo "ro.product.model=$PRODUCT_MODEL" + fi echo "ro.product.device=$TARGET_DEVICE" echo "# Do not try to parse description, fingerprint, or thumbprint" echo "ro.build.description=$PRIVATE_BUILD_DESC" -- cgit v1.1 From 5f59260b19817e8fc54f00c3829ba432d887da92 Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Sun, 22 Feb 2015 23:23:13 -0800 Subject: releasetools: Add bootable image signing Set PRODUCT_PRIVATE_KEY to the path of the boot image signing certificate to sign an image for secure boot. Ticket: RM-233 Change-Id: I2c767c6f9c3740bed3d7094d2d0b50a075e08abc --- tools/releasetools/common.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 26cc674..efdab16 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -338,6 +338,7 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): ramdisk_img = tempfile.NamedTemporaryFile() img = tempfile.NamedTemporaryFile() + bootimg_key = os.getenv("PRODUCT_PRIVATE_KEY", None) if os.access(fs_config_file, os.F_OK): cmd = ["mkbootfs", "-f", fs_config_file, os.path.join(sourcedir, "RAMDISK")] @@ -404,8 +405,9 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): fn = os.path.join(sourcedir, "pagesize") if os.access(fn, os.F_OK): + kernel_pagesize=open(fn).read().rstrip("\n") cmd.append("--pagesize") - cmd.append(open(fn).read().rstrip("\n")) + cmd.append(kernel_pagesize) args = info_dict.get("mkbootimg_args", None) if args and args.strip(): @@ -425,6 +427,42 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): assert p.returncode == 0, "mkbootimg of %s image failed" % ( os.path.basename(sourcedir),) + if bootimg_key and os.path.exists(bootimg_key) and kernel_pagesize > 0: + print "Signing bootable image..." + bootimg_key_passwords = {} + bootimg_key_passwords.update(PasswordManager().GetPasswords(bootimg_key.split())) + bootimg_key_password = bootimg_key_passwords[bootimg_key] + if bootimg_key_password is not None: + bootimg_key_password += "\n" + img_sha256 = tempfile.NamedTemporaryFile() + img_sig = tempfile.NamedTemporaryFile() + img_sig_padded = tempfile.NamedTemporaryFile() + img_secure = tempfile.NamedTemporaryFile() + p = Run(["openssl", "dgst", "-sha256", "-binary", "-out", img_sha256.name, img.name], + stdout=subprocess.PIPE) + p.communicate() + assert p.returncode == 0, "signing of bootable image failed" + p = Run(["openssl", "rsautl", "-sign", "-in", img_sha256.name, "-inkey", bootimg_key, "-out", + img_sig.name, "-passin", "stdin"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) + p.communicate(bootimg_key_password) + assert p.returncode == 0, "signing of bootable image failed" + p = Run(["dd", "if=/dev/zero", "of=%s" % img_sig_padded.name, "bs=%s" % kernel_pagesize, + "count=1"], stdout=subprocess.PIPE) + p.communicate() + assert p.returncode == 0, "signing of bootable image failed" + p = Run(["dd", "if=%s" % img_sig.name, "of=%s" % img_sig_padded.name, "conv=notrunc"], + stdout=subprocess.PIPE) + p.communicate() + assert p.returncode == 0, "signing of bootable image failed" + p = Run(["cat", img.name, img_sig_padded.name], stdout=img_secure.file.fileno()) + p.communicate() + assert p.returncode == 0, "signing of bootable image failed" + shutil.copyfile(img_secure.name, img.name) + img_sha256.close() + img_sig.close() + img_sig_padded.close() + img_secure.close() + if (info_dict.get("boot_signer", None) == "true" and info_dict.get("verity_key", None)): path = "/" + os.path.basename(sourcedir).lower() -- cgit v1.1 From e1caad2880015a111566c59690f33c039b937147 Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Sun, 22 Feb 2015 23:23:13 -0800 Subject: releasetools: Fix print in boot image signing Python 3 compatibility fail Change-Id: I0acb7059b554ad16833ccdd09643f52f2c44a3f2 Ticket: RM-233 --- tools/releasetools/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index efdab16..ac4cdf7 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -428,7 +428,7 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): os.path.basename(sourcedir),) if bootimg_key and os.path.exists(bootimg_key) and kernel_pagesize > 0: - print "Signing bootable image..." + print("Signing bootable image...") bootimg_key_passwords = {} bootimg_key_passwords.update(PasswordManager().GetPasswords(bootimg_key.split())) bootimg_key_password = bootimg_key_passwords[bootimg_key] -- cgit v1.1 From b0fa40c8a8dfac5077e80a0a7b18098dcd15b4cf Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Tue, 8 Sep 2015 17:11:37 -0700 Subject: img_from_target_files: Skip oem.img in fastboot image creation We don't need this package to be included in fastboot images, so skip it when we are creating fastboot images. Change-Id: I1e0676f5cbf7468088e6997f83ae845578864668 Ticket: CYNGNOS-936 --- tools/releasetools/img_from_target_files.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py index e9f9af6..33375ca 100755 --- a/tools/releasetools/img_from_target_files.py +++ b/tools/releasetools/img_from_target_files.py @@ -111,6 +111,7 @@ def main(argv): if os.path.exists(images_path): # If this is a new target-files, it already contains the images, # and all we have to do is copy them to the output zip. + # Skip oem.img files since they are not needed in fastboot images. images = os.listdir(images_path) if images: for image in images: @@ -118,6 +119,8 @@ def main(argv): continue if not image.endswith(".img"): continue + if image == "oem.img": + continue common.ZipWrite( output_zip, os.path.join(images_path, image), image) done = True @@ -165,12 +168,6 @@ def main(argv): add_img_to_target_files.AddUserdataExtra(output_zip, prefix="") banner("AddCache") add_img_to_target_files.AddCache(output_zip, prefix="") - try: - input_zip.getinfo("OEM/") - banner("AddOem") - add_img_to_target_files.AddOem(output_zip, prefix="") - except KeyError: - pass # no oem partition for this device finally: print("cleaning up...") -- cgit v1.1 From 624ba2e5b510f024c2a2243f2c780085da6c7502 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Thu, 18 Sep 2014 19:29:00 -0500 Subject: repopick: support specifying a range of commits to pick * for example: repopick 12345-12350 Change-Id: I3b8f2c331a6ac5488032432e133bd4b44d0bf007 --- tools/repopick.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index 1840a56..a53c043 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -235,8 +235,14 @@ if __name__ == '__main__': reviews = fetch_query(args.gerrit, args.query) change_numbers = sorted([str(r['number']) for r in reviews]) if args.change_number: - reviews = fetch_query(args.gerrit, ' OR '.join('change:{0}'.format(x.split('/')[0]) for x in args.change_number)) - change_numbers = args.change_number + for c in args.change_number: + if '-' in c: + templist = c.split('-') + for i in range(int(templist[0]), int(templist[1]) + 1): + change_numbers.append(str(i)) + else: + change_numbers.append(c) + reviews = fetch_query(args.gerrit, ' OR '.join('change:{0}'.format(x.split('/')[0]) for x in change_numbers)) # make list of things to actually merge mergables = [] -- cgit v1.1 From fbd7c1cdb0b361cf35f7b3323019806e149c6c00 Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Mon, 16 May 2016 18:53:19 -0700 Subject: ereleasetools: Allow for custom boot image signing tools Some boot images will need to be signed using specific tools. Allow passing the path to this tool through an environment variable. Change-Id: I958726fdae8d63fe99d639dfa361046b528a087c Ticket: CYNGNOS-2868 --- tools/releasetools/common.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index ac4cdf7..6e49629 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -339,6 +339,7 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): ramdisk_img = tempfile.NamedTemporaryFile() img = tempfile.NamedTemporaryFile() bootimg_key = os.getenv("PRODUCT_PRIVATE_KEY", None) + custom_boot_signer = os.getenv("PRODUCT_BOOT_SIGNER", None) if os.access(fs_config_file, os.F_OK): cmd = ["mkbootfs", "-f", fs_config_file, os.path.join(sourcedir, "RAMDISK")] @@ -427,7 +428,15 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): assert p.returncode == 0, "mkbootimg of %s image failed" % ( os.path.basename(sourcedir),) - if bootimg_key and os.path.exists(bootimg_key) and kernel_pagesize > 0: + if custom_boot_signer and bootimg_key and os.path.exists(bootimg_key): + print("Signing bootable image with custom boot signer...") + img_secure = tempfile.NamedTemporaryFile() + p = Run([custom_boot_signer, img.name, img_secure.name], stdout=subprocess.PIPE) + p.communicate() + assert p.returncode == 0, "signing of bootable image failed" + shutil.copyfile(img_secure.name, img.name) + img_secure.close() + elif bootimg_key and os.path.exists(bootimg_key) and kernel_pagesize > 0: print("Signing bootable image...") bootimg_key_passwords = {} bootimg_key_passwords.update(PasswordManager().GetPasswords(bootimg_key.split())) -- cgit v1.1 From a68d79c1ef9ae6cb9dae6acfe7115ad47597376f Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Mon, 4 Jul 2016 16:34:19 +0100 Subject: build: Let the verity signer and metadata builders ask for a password Don't grab stdin/out for these tools. We want to know when a password is being requested (and be able to actually provide one) if the corresponding key needs it Change-Id: I8dd439322b7d8942adc9ce7ce0912fb20c69654f Ref: CYNGNOS-3156 --- tools/releasetools/build_image.py | 10 +++++++--- tools/releasetools/common.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index efaf7eb..81ab64f 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -111,10 +111,14 @@ def BuildVerityMetadata(image_size, verity_metadata_path, root_hash, salt, cmd = cmd_template % (image_size, verity_metadata_path, root_hash, salt, block_device, signer_path, key) print(cmd) - status, output = getstatusoutput(cmd) - if status: - print("Could not build verity metadata! Error: %s" % output) + runcmd = ["system/extras/verity/build_verity_metadata.py", image_size, verity_metadata_path, root_hash, salt, block_device, signer_path, key]; + sp = subprocess.Popen(runcmd) + sp.wait() + + if sp.returncode != 0: + print("Could not build verity metadata!") return False + return True def Append2Simg(sparse_image_path, unsparse_image_path, error_message): diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 6e49629..df06b15 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -480,7 +480,7 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): cmd.extend([path, img.name, info_dict["verity_key"] + ".pk8", info_dict["verity_key"] + ".x509.pem", img.name]) - p = Run(cmd, stdout=subprocess.PIPE) + p = Run(cmd) p.communicate() assert p.returncode == 0, "boot_signer of %s image failed" % path -- cgit v1.1 From d6a079f7e317358e4527fc27948d5b2f6621a22b Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Mon, 11 Jul 2016 11:17:56 +0100 Subject: build: Use the password manager for the verity key if possible If we're operating with a password dict, try to use it for verity Change-Id: Ie0e8e33c873fc9f1ae9bd6da559f9cbbced183e9 Ref: CYNGNOS-3156 --- tools/releasetools/build_image.py | 15 ++++++++++++++- tools/releasetools/common.py | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index 81ab64f..d712083 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -106,13 +106,26 @@ def BuildVerityTree(sparse_image_path, verity_image_path, prop_dict): def BuildVerityMetadata(image_size, verity_metadata_path, root_hash, salt, block_device, signer_path, key): + verity_key = os.getenv("PRODUCT_VERITY_KEY", None) + verity_key_password = None + + if verity_key and os.path.exists(verity_key+".pk8"): + verity_key_passwords = {} + verity_key_passwords.update(common.PasswordManager().GetPasswords(verity_key.split())) + verity_key_password = verity_key_passwords[verity_key] + cmd_template = ( "system/extras/verity/build_verity_metadata.py %s %s %s %s %s %s %s") cmd = cmd_template % (image_size, verity_metadata_path, root_hash, salt, block_device, signer_path, key) print(cmd) runcmd = ["system/extras/verity/build_verity_metadata.py", image_size, verity_metadata_path, root_hash, salt, block_device, signer_path, key]; - sp = subprocess.Popen(runcmd) + if verity_key_password is not None: + sp = subprocess.Popen(runcmd, stdin=subprocess.PIPE) + sp.communicate(verity_key_password) + else: + sp = subprocess.Popen(runcmd) + sp.wait() if sp.returncode != 0: diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index df06b15..32bbc68 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -339,6 +339,7 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): ramdisk_img = tempfile.NamedTemporaryFile() img = tempfile.NamedTemporaryFile() bootimg_key = os.getenv("PRODUCT_PRIVATE_KEY", None) + verity_key = os.getenv("PRODUCT_VERITY_KEY", None) custom_boot_signer = os.getenv("PRODUCT_BOOT_SIGNER", None) if os.access(fs_config_file, os.F_OK): @@ -480,8 +481,21 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): cmd.extend([path, img.name, info_dict["verity_key"] + ".pk8", info_dict["verity_key"] + ".x509.pem", img.name]) - p = Run(cmd) - p.communicate() + verity_key_password = None + + if verity_key and os.path.exists(verity_key+".pk8") and kernel_pagesize > 0: + verity_key_passwords = {} + verity_key_passwords.update(PasswordManager().GetPasswords(verity_key.split())) + verity_key_password = verity_key_passwords[verity_key] + + if verity_key_password is not None: + verity_key_password += "\n" + p = Run(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + p.communicate(verity_key_password) + else: + p = Run(cmd) + p.communicate() + assert p.returncode == 0, "boot_signer of %s image failed" % path # Sign the image if vboot is non-empty. -- cgit v1.1 From 5a8b10690354027b83b382b3ba6e856bbd9fc011 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Wed, 9 Nov 2016 17:55:31 +0000 Subject: releasetools: Rebuild recovery when signing target images When signing a build, the recovery can be built twice, once when signing and again when adding the image to target files. This is usally not a problem for deterministic signatures but a custom signing method might include a time-based component which affects checksums of the generated images. This means that the recovery patches (i.e. install-recovery) will fail to checksum. This patch makes adding images to target files, when invoked from sign_target_files_apks, always rebuild the recovery patch with the newly generated images so that the checksums are consistent irrespective of potential time components. Change-Id: I575c69dc96a6d4d69b3ea9d037f5f13c97afa87e --- tools/releasetools/add_img_to_target_files.py | 14 ++++++++------ tools/releasetools/sign_target_files_apks.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index b699135..51d64b8 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -47,7 +47,8 @@ OPTIONS.replace_verity_public_key = False OPTIONS.replace_verity_private_key = False OPTIONS.verity_signer_path = None -def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): +def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None, + rebuild_recovery=OPTIONS.rebuild_recovery): """Turn the contents of SYSTEM into a system image and store it in output_zip.""" @@ -61,7 +62,7 @@ def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): ofile.write(data) ofile.close() - if OPTIONS.rebuild_recovery: + if rebuild_recovery: print("Building new recovery patch") common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, boot_img, info_dict=OPTIONS.info_dict) @@ -322,7 +323,7 @@ def AddCache(output_zip, prefix="IMAGES/"): os.rmdir(temp_dir) -def AddImagesToTargetFiles(filename): +def AddImagesToTargetFiles(filename, rebuild_recovery=OPTIONS.rebuild_recovery): OPTIONS.input_tmp, input_zip = common.UnzipTemp(filename) if not OPTIONS.add_missing: @@ -360,7 +361,7 @@ def AddImagesToTargetFiles(filename): boot_image = None if os.path.exists(prebuilt_path): print("boot.img already exists in IMAGES/, no need to rebuild...") - if OPTIONS.rebuild_recovery: + if rebuild_recovery: boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") else: @@ -374,7 +375,7 @@ def AddImagesToTargetFiles(filename): prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img") if os.path.exists(prebuilt_path): print("recovery.img already exists in IMAGES/, no need to rebuild...") - if OPTIONS.rebuild_recovery: + if rebuild_recovery: recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") else: @@ -384,7 +385,8 @@ def AddImagesToTargetFiles(filename): recovery_image.AddToZip(output_zip) banner("system") - AddSystem(output_zip, recovery_img=recovery_image, boot_img=boot_image) + AddSystem(output_zip, recovery_img=recovery_image, boot_img=boot_image, + rebuild_recovery = rebuild_recovery) if has_vendor: banner("vendor") AddVendor(output_zip) diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py index abdb845..54460e6 100755 --- a/tools/releasetools/sign_target_files_apks.py +++ b/tools/releasetools/sign_target_files_apks.py @@ -518,7 +518,7 @@ def main(argv): common.ZipClose(input_zip) common.ZipClose(output_zip) - add_img_to_target_files.AddImagesToTargetFiles(args[1]) + add_img_to_target_files.AddImagesToTargetFiles(args[1], rebuild_recovery=True) print("done.") -- cgit v1.1 From 9aa34c95a61c57512cc7973740c34ab3e61983c5 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Thu, 25 Aug 2016 09:39:27 -0500 Subject: repopick: try to use remote's default revision * If the project doesn't have a revision specified, try to see if it's remote has one specified before falling back to the global default. RM-290 Change-Id: I05129413b154e5d08d0fa9ef0ce853631b7e1562 --- tools/repopick.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index a53c043..2b0aab4 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -209,6 +209,7 @@ if __name__ == '__main__': manifest = subprocess.check_output(['repo', 'manifest']) xml_root = ElementTree.fromstring(manifest) projects = xml_root.findall('project') + remotes = xml_root.findall('remote') default_revision = xml_root.findall('default')[0].get('revision').split('/')[-1] #dump project data into the a list of dicts with the following data: @@ -219,7 +220,11 @@ if __name__ == '__main__': path = project.get('path') revision = project.get('revision') if revision is None: - revision = default_revision + for remote in remotes: + if remote.get('name') == project.get('remote'): + revision = remote.get('revision') + if revision is None: + revision = default_revision if not name in project_name_to_data: project_name_to_data[name] = {} -- cgit v1.1 From e5be2a0b233ff0482ba36894de5da57b663dc683 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Sat, 27 Aug 2016 01:49:14 +1000 Subject: repopick: don't re-pick duplicate changes check the last 10 commits to HEAD for a dupe change id. RM-290 Change-Id: Icfbf8b4eae165cf84ef4a82f54f792e9c9acd67b --- tools/repopick.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index 2b0aab4..6e40f38 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -275,6 +275,7 @@ if __name__ == '__main__': 'subject': review['subject'], 'project': review['project'], 'branch': review['branch'], + 'change_id': review['change_id'], 'change_number': review['number'], 'status': review['status'], 'fetch': None @@ -317,6 +318,19 @@ if __name__ == '__main__': if args.start_branch: subprocess.check_output(['repo', 'start', args.start_branch[0], project_path]) + # Check if change is already picked to HEAD...HEAD~10 + found_change = False + for i in range(0, 10): + output = subprocess.check_output(['git', 'show', '-q', 'HEAD~{0}'.format(i)], cwd=project_path).split() + if 'Change-Id:' in output: + head_change_id = output[output.index('Change-Id:')+1] + if head_change_id.strip() == item['change_id']: + print('Skipping {0} - already picked in {1} as HEAD~{2}'.format(item['id'], project_path, i)) + found_change = True + break + if found_change: + continue + # Print out some useful info if not args.quiet: print('--> Subject: "{0}"'.format(item['subject'])) -- cgit v1.1 From b7831759763be0c30d1762f63db0010225957bca Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Wed, 31 Aug 2016 16:30:19 +0200 Subject: repopick: handle revisions with slashes RM-290 Change-Id: I6f7891a52fb1538e88f5a68dd28ef1c603ee7067 --- tools/repopick.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index 6e40f38..2b436ef 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -210,7 +210,7 @@ if __name__ == '__main__': xml_root = ElementTree.fromstring(manifest) projects = xml_root.findall('project') remotes = xml_root.findall('remote') - default_revision = xml_root.findall('default')[0].get('revision').split('/')[-1] + default_revision = xml_root.findall('default')[0].get('revision') #dump project data into the a list of dicts with the following data: #{project: {path, revision}} @@ -228,6 +228,7 @@ if __name__ == '__main__': if not name in project_name_to_data: project_name_to_data[name] = {} + revision = revision.split('refs/heads/')[-1] project_name_to_data[name][revision] = path # get data on requested changes -- cgit v1.1 From 0730edceb5b5454b84260856e064a701276b2c8b Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Thu, 8 Sep 2016 17:11:11 +0200 Subject: build: repopick: Support projects with less than 10 commits * Verify that the project has at least 10 commits to verify, if not check only the amount of existing commits RM-290 Change-Id: Ic95212510d8f5b980c9a94af8d5ac1e0dfd94b3e --- tools/repopick.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index 2b436ef..8031a6a 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -319,9 +319,15 @@ if __name__ == '__main__': if args.start_branch: subprocess.check_output(['repo', 'start', args.start_branch[0], project_path]) - # Check if change is already picked to HEAD...HEAD~10 + # Determine the maximum commits to check already picked changes + check_picked_count = 10 + branch_commits_count = int(subprocess.check_output(['git', 'rev-list', '--count', 'HEAD'], cwd=project_path)) + if branch_commits_count <= check_picked_count: + check_picked_count = branch_commits_count - 1 + + # Check if change is already picked to HEAD...HEAD~check_picked_count found_change = False - for i in range(0, 10): + for i in range(0, check_picked_count): output = subprocess.check_output(['git', 'show', '-q', 'HEAD~{0}'.format(i)], cwd=project_path).split() if 'Change-Id:' in output: head_change_id = output[output.index('Change-Id:')+1] -- cgit v1.1 From 86152e68a701195a2269892561e67133961e51ac Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Thu, 8 Sep 2016 18:25:02 +0200 Subject: build: repopick: Support squashed commits for Change-Id detection * Commits are identified by their last Change-Id, but the parser only considers the first one found * Reverse the list to find the last Change-Id and avoid multiple repopick attempts on the same commit RM-290 Change-Id: Ie0204245a47799f8ead21148e0b4e9356cf271eb --- 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 8031a6a..9bf26bd 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -330,7 +330,11 @@ if __name__ == '__main__': for i in range(0, check_picked_count): output = subprocess.check_output(['git', 'show', '-q', 'HEAD~{0}'.format(i)], cwd=project_path).split() if 'Change-Id:' in output: - head_change_id = output[output.index('Change-Id:')+1] + head_change_id = '' + for j,t in enumerate(reversed(output)): + if t == 'Change-Id:': + head_change_id = output[len(output) - j] + break if head_change_id.strip() == item['change_id']: print('Skipping {0} - already picked in {1} as HEAD~{2}'.format(item['id'], project_path, i)) found_change = True -- cgit v1.1 From ea2aaaeee4322b13eb1fd48342fc8f4a8109a83f Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Sun, 4 Dec 2016 12:30:26 +0100 Subject: build: repopick: Avoid failing on commits lookup * Some projects with multiple merges and discountinuous histories could trigger an error here when the HEAD~{?} does not exist, hence avoid this by ignoring the commit and continue the search Change-Id: Ice28c87d1bf8897da52236b637bbb0c5d349f848 --- tools/repopick.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools') diff --git a/tools/repopick.py b/tools/repopick.py index 9bf26bd..cfbb8a8 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -328,6 +328,8 @@ if __name__ == '__main__': # Check if change is already picked to HEAD...HEAD~check_picked_count found_change = False for i in range(0, check_picked_count): + if subprocess.call(['git', 'cat-file', '-e', 'HEAD~{0}'.format(i)], cwd=project_path, stderr=open(os.devnull, 'wb')): + continue output = subprocess.check_output(['git', 'show', '-q', 'HEAD~{0}'.format(i)], cwd=project_path).split() if 'Change-Id:' in output: head_change_id = '' -- cgit v1.1