forked from openkylin/platform_build
Support systems that use a full copy of recovery image.
If BOARD_USES_FULL_RECOVERY_IMAGE == true, a full copy of recovery
image will be carried as /system/etc/recovery.img instead of a patch
at /system/recovery_from_boot.p.
Bug: 22641135
Change-Id: Ie271d3e2d55d7b003f667ac5b44203d69b23c63b
(cherry picked from commit 8beab69bd5
)
This commit is contained in:
parent
7ecb919dba
commit
f2cffbddb9
|
@ -784,8 +784,15 @@ recovery_fstab := $(TARGET_RECOVERY_FSTAB)
|
|||
else
|
||||
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||
# Named '.dat' so we don't attempt to use imgdiff for patching it.
|
||||
RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
|
||||
else
|
||||
# We carry a full copy of the recovery image. recovery-resource.dat is no
|
||||
# longer needed.
|
||||
RECOVERY_RESOURCE_ZIP :=
|
||||
endif
|
||||
|
||||
ifeq ($(recovery_resources_private),)
|
||||
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
|
||||
|
@ -877,16 +884,18 @@ $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
|
|||
$(RECOVERY_INSTALL_OTA_KEYS)
|
||||
$(call build-recoveryimage-target, $@)
|
||||
|
||||
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
|
||||
$(hide) mkdir -p $(dir $@)
|
||||
$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
|
||||
endif
|
||||
|
||||
.PHONY: recoveryimage-nodeps
|
||||
recoveryimage-nodeps:
|
||||
@echo "make $@: ignoring dependencies"
|
||||
$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
|
||||
|
||||
else
|
||||
else # ! ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
|
||||
INSTALLED_RECOVERYIMAGE_TARGET :=
|
||||
RECOVERY_RESOURCE_ZIP :=
|
||||
endif
|
||||
|
@ -994,6 +1003,7 @@ SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
|
|||
# we can see how big it's going to be, and include that in the system
|
||||
# image size check calculation.
|
||||
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
|
||||
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||
intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
|
||||
RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
|
||||
$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
|
||||
|
@ -1003,6 +1013,9 @@ $(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
|
|||
@echo "Construct recovery from boot"
|
||||
mkdir -p $(dir $@)
|
||||
PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
|
||||
else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
|
||||
RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
@ -1495,6 +1508,9 @@ endif
|
|||
ifeq ($(SANITIZE_TARGET),address)
|
||||
# We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
|
||||
$(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt
|
||||
endif
|
||||
ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||
$(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
|
||||
endif
|
||||
$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
|
||||
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
|
||||
|
|
|
@ -1395,18 +1395,24 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
|
|||
if info_dict is None:
|
||||
info_dict = OPTIONS.info_dict
|
||||
|
||||
diff_program = ["imgdiff"]
|
||||
path = os.path.join(input_dir, "SYSTEM", "etc", "recovery-resource.dat")
|
||||
if os.path.exists(path):
|
||||
diff_program.append("-b")
|
||||
diff_program.append(path)
|
||||
bonus_args = "-b /system/etc/recovery-resource.dat"
|
||||
else:
|
||||
bonus_args = ""
|
||||
full_recovery_image = info_dict.get("full_recovery_image", None) == "true"
|
||||
|
||||
d = Difference(recovery_img, boot_img, diff_program=diff_program)
|
||||
_, _, patch = d.ComputePatch()
|
||||
output_sink("recovery-from-boot.p", patch)
|
||||
if full_recovery_image:
|
||||
output_sink("etc/recovery.img", recovery_img.data)
|
||||
|
||||
else:
|
||||
diff_program = ["imgdiff"]
|
||||
path = os.path.join(input_dir, "SYSTEM", "etc", "recovery-resource.dat")
|
||||
if os.path.exists(path):
|
||||
diff_program.append("-b")
|
||||
diff_program.append(path)
|
||||
bonus_args = "-b /system/etc/recovery-resource.dat"
|
||||
else:
|
||||
bonus_args = ""
|
||||
|
||||
d = Difference(recovery_img, boot_img, diff_program=diff_program)
|
||||
_, _, patch = d.ComputePatch()
|
||||
output_sink("recovery-from-boot.p", patch)
|
||||
|
||||
try:
|
||||
boot_type, boot_device = GetTypeAndDevice("/boot", info_dict)
|
||||
|
@ -1414,7 +1420,19 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
|
|||
except KeyError:
|
||||
return
|
||||
|
||||
sh = """#!/system/bin/sh
|
||||
if full_recovery_image:
|
||||
sh = """#!/system/bin/sh
|
||||
if ! applypatch -c %(type)s:%(device)s:%(size)d:%(sha1)s; then
|
||||
applypatch /system/etc/recovery.img %(type)s:%(device)s %(sha1)s %(size)d && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
|
||||
else
|
||||
log -t recovery "Recovery image already installed"
|
||||
fi
|
||||
""" % {'type': recovery_type,
|
||||
'device': recovery_device,
|
||||
'sha1': recovery_img.sha1,
|
||||
'size': recovery_img.size}
|
||||
else:
|
||||
sh = """#!/system/bin/sh
|
||||
if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
|
||||
applypatch %(bonus_args)s %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s %(recovery_type)s:%(recovery_device)s %(recovery_sha1)s %(recovery_size)d %(boot_sha1)s:/system/recovery-from-boot.p && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
|
||||
else
|
||||
|
|
|
@ -218,7 +218,8 @@ class ItemSet(object):
|
|||
if i.is_dir:
|
||||
i.children.sort(key=lambda i: i.name)
|
||||
|
||||
# set metadata for the files generated by this script.
|
||||
# Set metadata for the files generated by this script. For full recovery
|
||||
# image at system/etc/recovery.img, it will be taken care by fs_config.
|
||||
i = self.ITEMS.get("system/recovery-from-boot.p", None)
|
||||
if i:
|
||||
i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0o644, None, None
|
||||
|
@ -422,11 +423,9 @@ def AppendAssertions(script, info_dict, oem_dict=None):
|
|||
|
||||
|
||||
def HasRecoveryPatch(target_files_zip):
|
||||
try:
|
||||
target_files_zip.getinfo("SYSTEM/recovery-from-boot.p")
|
||||
return True
|
||||
except KeyError:
|
||||
return False
|
||||
namelist = [name for name in target_files_zip.namelist()]
|
||||
return ("SYSTEM/recovery-from-boot.p" in namelist or
|
||||
"SYSTEM/etc/recovery.img" in namelist)
|
||||
|
||||
def HasVendorPartition(target_files_zip):
|
||||
try:
|
||||
|
@ -1360,6 +1359,7 @@ else
|
|||
common.MakeRecoveryPatch(OPTIONS.target_tmp, output_sink,
|
||||
target_recovery, target_boot)
|
||||
script.DeleteFiles(["/system/recovery-from-boot.p",
|
||||
"/system/etc/recovery.img",
|
||||
"/system/etc/install-recovery.sh"])
|
||||
print "recovery image changed; including as patch from boot."
|
||||
else:
|
||||
|
|
|
@ -175,6 +175,7 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
|
|||
data = input_tf_zip.read(info.filename)
|
||||
out_info = copy.copy(info)
|
||||
|
||||
# Replace keys if requested.
|
||||
if (info.filename == "META/misc_info.txt" and
|
||||
OPTIONS.replace_verity_private_key):
|
||||
ReplaceVerityPrivateKey(input_tf_zip, output_tf_zip, misc_info,
|
||||
|
@ -184,12 +185,14 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
|
|||
new_data = ReplaceVerityPublicKey(output_tf_zip,
|
||||
OPTIONS.replace_verity_public_key[1])
|
||||
write_to_temp(info.filename, info.external_attr, new_data)
|
||||
# Copy BOOT/, RECOVERY/, META/, ROOT/ to rebuild recovery patch.
|
||||
elif (info.filename.startswith("BOOT/") or
|
||||
info.filename.startswith("RECOVERY/") or
|
||||
info.filename.startswith("META/") or
|
||||
info.filename == "SYSTEM/etc/recovery-resource.dat"):
|
||||
write_to_temp(info.filename, info.external_attr, data)
|
||||
|
||||
# Sign APKs.
|
||||
if info.filename.endswith(".apk"):
|
||||
name = os.path.basename(info.filename)
|
||||
key = apk_key_map[name]
|
||||
|
@ -214,6 +217,7 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
|
|||
new_data = ReplaceCerts(data)
|
||||
common.ZipWriteStr(output_tf_zip, out_info, new_data)
|
||||
elif info.filename in ("SYSTEM/recovery-from-boot.p",
|
||||
"SYSTEM/etc/recovery.img",
|
||||
"SYSTEM/bin/install-recovery.sh"):
|
||||
rebuild_recovery = True
|
||||
elif (OPTIONS.replace_ota_keys and
|
||||
|
|
Loading…
Reference in New Issue