Skip to content

Instantly share code, notes, and snippets.

@inhies
Created March 26, 2013 02:52
Show Gist options
  • Save inhies/5242764 to your computer and use it in GitHub Desktop.
Save inhies/5242764 to your computer and use it in GitHub Desktop.
This patch applies to the 'build' project in the android-4.2.2_r1 branch of AOSP and allows you to build flashable .zips without including the factory recovery.
From bdfb8228f5a8ddd541ddc401d7e5b87a7b43234b Mon Sep 17 00:00:00 2001
From: inhies
Date: Thu, 7 Mar 2013 08:43:24 +0000
Subject: [PATCH] Add option to prevent building of recovery image with OTA .zip
Change-Id: I604ddaaa79442465ff821b74259b947da23ae98a
---
core/Makefile | 7 +++++++
tools/releasetools/ota_from_target_files | 28 +++++++++++++++++++++-------
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/core/Makefile b/core/Makefile
index a25d80f..3672015 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1173,11 +1173,18 @@ INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
+$(INTERNAL_OTA_PACKAGE_TARGET): increcovery := true
+
+ifdef INCLUDE_RECOVERY
+ $(INTERNAL_OTA_PACKAGE_TARGET): increcovery = $(INCLUDE_RECOVERY)
+endif
+
$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
@echo "Package OTA: $@"
$(hide) ./build/tools/releasetools/ota_from_target_files -v \
-p $(HOST_OUT) \
-k $(KEY_CERT_PAIR) \
+ --increcovery=$(increcovery) \
$(BUILT_TARGET_FILES_PACKAGE) $@
.PHONY: otapackage
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 170f5b3..38428bf 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -51,6 +51,10 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package
-a (--aslr_mode) <on|off>
Specify whether to turn on ASLR for the package (on by default).
+
+ --increcovery <boolean>
+ Specify the inclusion of recovery.img or /recovery
+ Default is true
"""
@@ -88,6 +92,7 @@ OPTIONS.omit_prereq = False
OPTIONS.extra_script = None
OPTIONS.aslr_mode = True
OPTIONS.worker_threads = 3
+OPTIONS.inc_recovery = True
def MostPopularKey(d, default):
"""Given a dict, return the key corresponding to the largest
@@ -335,8 +340,10 @@ def MakeRecoveryPatch(input_tmp, output_zip, recovery_img, boot_img):
d = common.Difference(recovery_img, boot_img, diff_program=diff_program)
_, _, patch = d.ComputePatch()
- common.ZipWriteStr(output_zip, "recovery/recovery-from-boot.p", patch)
- Item.Get("system/recovery-from-boot.p", dir=False)
+
+ if OPTIONS.inc_recovery:
+ common.ZipWriteStr(output_zip, "recovery/recovery-from-boot.p", patch)
+ Item.Get("system/recovery-from-boot.p", dir=False)
boot_type, boot_device = common.GetTypeAndDevice("/boot", OPTIONS.info_dict)
recovery_type, recovery_device = common.GetTypeAndDevice("/recovery", OPTIONS.info_dict)
@@ -403,7 +410,10 @@ def WriteFullOTAPackage(input_zip, output_zip):
script.FormatPartition("/system")
script.Mount("/system")
- script.UnpackPackageDir("recovery", "/system")
+
+ if OPTIONS.inc_recovery:
+ script.UnpackPackageDir("recovery", "/system")
+
script.UnpackPackageDir("system", "/system")
symlinks = CopySystemFiles(input_zip, output_zip)
@@ -411,9 +421,10 @@ def WriteFullOTAPackage(input_zip, output_zip):
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)
+ if OPTIONS.inc_recovery:
+ 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)
@@ -759,7 +770,9 @@ def main(argv):
else:
OPTIONS.aslr_mode = False
elif o in ("--worker_threads"):
- OPTIONS.worker_threads = int(a)
+ OPTIONS.worker_threads = int(a)
+ elif o in ("--increcovery"):
+ OPTIONS.inc_recovery = bool(a.lower() == 'true')
else:
return False
return True
@@ -773,6 +786,7 @@ def main(argv):
"no_prereq",
"extra_script=",
"worker_threads=",
+ "increcovery=",
"aslr_mode=",
],
extra_option_handler=option_handler)
--
1.7.2.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment