am bcc4d671
: Merge "Support systems that use a full copy of recovery image."
* commit 'bcc4d671745beaa5314a0a1133adc0347b55db77': Support systems that use a full copy of recovery image.
This commit is contained in:
@@ -784,8 +784,15 @@ recovery_fstab := $(TARGET_RECOVERY_FSTAB)
|
|||||||
else
|
else
|
||||||
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
|
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||||
# Named '.dat' so we don't attempt to use imgdiff for patching it.
|
# Named '.dat' so we don't attempt to use imgdiff for patching it.
|
||||||
RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
|
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),)
|
ifeq ($(recovery_resources_private),)
|
||||||
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
|
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
|
||||||
@@ -877,16 +884,18 @@ $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
|
|||||||
$(RECOVERY_INSTALL_OTA_KEYS)
|
$(RECOVERY_INSTALL_OTA_KEYS)
|
||||||
$(call build-recoveryimage-target, $@)
|
$(call build-recoveryimage-target, $@)
|
||||||
|
|
||||||
|
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||||
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
|
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
|
||||||
$(hide) mkdir -p $(dir $@)
|
$(hide) mkdir -p $(dir $@)
|
||||||
$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
|
$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: recoveryimage-nodeps
|
.PHONY: recoveryimage-nodeps
|
||||||
recoveryimage-nodeps:
|
recoveryimage-nodeps:
|
||||||
@echo "make $@: ignoring dependencies"
|
@echo "make $@: ignoring dependencies"
|
||||||
$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
|
$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
|
||||||
|
|
||||||
else
|
else # ! ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
|
||||||
INSTALLED_RECOVERYIMAGE_TARGET :=
|
INSTALLED_RECOVERYIMAGE_TARGET :=
|
||||||
RECOVERY_RESOURCE_ZIP :=
|
RECOVERY_RESOURCE_ZIP :=
|
||||||
endif
|
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
|
# we can see how big it's going to be, and include that in the system
|
||||||
# image size check calculation.
|
# image size check calculation.
|
||||||
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
|
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
|
||||||
|
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||||
intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
|
intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
|
||||||
RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
|
RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
|
||||||
$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
|
$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
|
||||||
@@ -1003,6 +1013,9 @@ $(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
|
|||||||
@echo "Construct recovery from boot"
|
@echo "Construct recovery from boot"
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
|
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
|
endif
|
||||||
|
|
||||||
|
|
||||||
@@ -1495,6 +1508,9 @@ endif
|
|||||||
ifeq ($(SANITIZE_TARGET),address)
|
ifeq ($(SANITIZE_TARGET),address)
|
||||||
# We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
|
# 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
|
$(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
|
endif
|
||||||
$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
|
$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
|
||||||
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
|
$(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:
|
if info_dict is None:
|
||||||
info_dict = OPTIONS.info_dict
|
info_dict = OPTIONS.info_dict
|
||||||
|
|
||||||
diff_program = ["imgdiff"]
|
full_recovery_image = info_dict.get("full_recovery_image", None) == "true"
|
||||||
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)
|
if full_recovery_image:
|
||||||
_, _, patch = d.ComputePatch()
|
output_sink("etc/recovery.img", recovery_img.data)
|
||||||
output_sink("recovery-from-boot.p", patch)
|
|
||||||
|
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:
|
try:
|
||||||
boot_type, boot_device = GetTypeAndDevice("/boot", info_dict)
|
boot_type, boot_device = GetTypeAndDevice("/boot", info_dict)
|
||||||
@@ -1414,7 +1420,19 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
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
|
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"
|
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
|
else
|
||||||
|
@@ -218,7 +218,8 @@ class ItemSet(object):
|
|||||||
if i.is_dir:
|
if i.is_dir:
|
||||||
i.children.sort(key=lambda i: i.name)
|
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)
|
i = self.ITEMS.get("system/recovery-from-boot.p", None)
|
||||||
if i:
|
if i:
|
||||||
i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0o644, None, None
|
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):
|
def HasRecoveryPatch(target_files_zip):
|
||||||
try:
|
namelist = [name for name in target_files_zip.namelist()]
|
||||||
target_files_zip.getinfo("SYSTEM/recovery-from-boot.p")
|
return ("SYSTEM/recovery-from-boot.p" in namelist or
|
||||||
return True
|
"SYSTEM/etc/recovery.img" in namelist)
|
||||||
except KeyError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def HasVendorPartition(target_files_zip):
|
def HasVendorPartition(target_files_zip):
|
||||||
try:
|
try:
|
||||||
@@ -1360,6 +1359,7 @@ else
|
|||||||
common.MakeRecoveryPatch(OPTIONS.target_tmp, output_sink,
|
common.MakeRecoveryPatch(OPTIONS.target_tmp, output_sink,
|
||||||
target_recovery, target_boot)
|
target_recovery, target_boot)
|
||||||
script.DeleteFiles(["/system/recovery-from-boot.p",
|
script.DeleteFiles(["/system/recovery-from-boot.p",
|
||||||
|
"/system/etc/recovery.img",
|
||||||
"/system/etc/install-recovery.sh"])
|
"/system/etc/install-recovery.sh"])
|
||||||
print "recovery image changed; including as patch from boot."
|
print "recovery image changed; including as patch from boot."
|
||||||
else:
|
else:
|
||||||
|
@@ -175,6 +175,7 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
|
|||||||
data = input_tf_zip.read(info.filename)
|
data = input_tf_zip.read(info.filename)
|
||||||
out_info = copy.copy(info)
|
out_info = copy.copy(info)
|
||||||
|
|
||||||
|
# Replace keys if requested.
|
||||||
if (info.filename == "META/misc_info.txt" and
|
if (info.filename == "META/misc_info.txt" and
|
||||||
OPTIONS.replace_verity_private_key):
|
OPTIONS.replace_verity_private_key):
|
||||||
ReplaceVerityPrivateKey(input_tf_zip, output_tf_zip, misc_info,
|
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,
|
new_data = ReplaceVerityPublicKey(output_tf_zip,
|
||||||
OPTIONS.replace_verity_public_key[1])
|
OPTIONS.replace_verity_public_key[1])
|
||||||
write_to_temp(info.filename, info.external_attr, new_data)
|
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
|
elif (info.filename.startswith("BOOT/") or
|
||||||
info.filename.startswith("RECOVERY/") or
|
info.filename.startswith("RECOVERY/") or
|
||||||
info.filename.startswith("META/") or
|
info.filename.startswith("META/") or
|
||||||
info.filename == "SYSTEM/etc/recovery-resource.dat"):
|
info.filename == "SYSTEM/etc/recovery-resource.dat"):
|
||||||
write_to_temp(info.filename, info.external_attr, data)
|
write_to_temp(info.filename, info.external_attr, data)
|
||||||
|
|
||||||
|
# Sign APKs.
|
||||||
if info.filename.endswith(".apk"):
|
if info.filename.endswith(".apk"):
|
||||||
name = os.path.basename(info.filename)
|
name = os.path.basename(info.filename)
|
||||||
key = apk_key_map[name]
|
key = apk_key_map[name]
|
||||||
@@ -214,6 +217,7 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
|
|||||||
new_data = ReplaceCerts(data)
|
new_data = ReplaceCerts(data)
|
||||||
common.ZipWriteStr(output_tf_zip, out_info, new_data)
|
common.ZipWriteStr(output_tf_zip, out_info, new_data)
|
||||||
elif info.filename in ("SYSTEM/recovery-from-boot.p",
|
elif info.filename in ("SYSTEM/recovery-from-boot.p",
|
||||||
|
"SYSTEM/etc/recovery.img",
|
||||||
"SYSTEM/bin/install-recovery.sh"):
|
"SYSTEM/bin/install-recovery.sh"):
|
||||||
rebuild_recovery = True
|
rebuild_recovery = True
|
||||||
elif (OPTIONS.replace_ota_keys and
|
elif (OPTIONS.replace_ota_keys and
|
||||||
|
Reference in New Issue
Block a user