Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 945e2a56 authored by Matt Garnes's avatar Matt Garnes
Browse files

Merge remote-tracking branch 'caf/LA.BR.1.2.3' into caf/cm-12.1

parents 8b19c9ec 745623e6
Loading
Loading
Loading
Loading
+72 −4
Original line number Diff line number Diff line
@@ -796,6 +796,7 @@ recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
endif
# Named '.dat' so we don't attempt to use imgdiff for patching it.
RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
RECOVERY_PATCH_INSTALL := $(TARGET_OUT)/bin/install-recovery.sh

ifeq ($(recovery_resources_private),)
  $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
@@ -885,15 +886,75 @@ endif
	$(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
	@echo ----- Made recovery image: $@ --------

recovery_patch_path := $(call intermediates-dir-for,PACKAGING,recovery_patch)
ota_temp_root := $(PRODUCT_OUT)/ota_temp
$(RECOVERY_PATCH_INSTALL): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
$(RECOVERY_PATCH_INSTALL): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
$(RECOVERY_PATCH_INSTALL): $(INSTALLED_RECOVERYIMAGE_TARGET) \
	$(RECOVERY_FROM_BOOT_PATCH) \
	$(ALL_PREBUILT) \
	$(ALL_COPIED_HEADERS) \
	$(ALL_GENERATED_SOURCES) \
	$(ALL_DEFAULT_INSTALLED_MODULES) \
	$(PDK_FUSION_SYSIMG_FILES)
	@echo "Installing recovery patch to system partition"
	$(hide) mkdir -p $(ota_temp_root)
	$(hide) mkdir -p $(ota_temp_root)/BOOT
	$(hide) mkdir -p $(ota_temp_root)/RECOVERY
	$(hide) mkdir -p $(ota_temp_root)/BOOTABLE_IMAGES
	$(hide) mkdir -p $(ota_temp_root)/SYSTEM
	$(hide) mkdir -p $(ota_temp_root)/SYSTEM/bin
	$(hide) mkdir -p $(ota_temp_root)/SYSTEM/etc
	$(hide) mkdir -p $(ota_temp_root)/META
	$(hide) $(call package_files-copy-root, \
		$(TARGET_RECOVERY_ROOT_OUT),$(ota_temp_root)/RECOVERY/RAMDISK)
	$(hide) $(call package_files-copy-root, \
		$(TARGET_ROOT_OUT),$(ota_temp_root)/BOOT/RAMDISK)
	$(hide) $(call package_files-copy-root, \
		$(TARGET_OUT)/etc,$(ota_temp_root)/SYSTEM/etc)
	@echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(ota_temp_root)/META/misc_info.txt
	@echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(ota_temp_root)/META/misc_info.txt
ifdef BOARD_FLASH_BLOCK_SIZE
	@echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(ota_temp_root)/META/misc_info.txt
endif
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
	@echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(ota_temp_root)/META/misc_info.txt
endif
ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
	@echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(ota_temp_root)/META/misc_info.txt
endif
ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
	@# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
	@echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(ota_temp_root)/META/misc_info.txt
else
	@echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(ota_temp_root)/META/misc_info.txt
endif
	@echo "tool_extensions=$(tool_extensions)" >> $(ota_temp_root)/META/misc_info.txt
	@echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(ota_temp_root)/META/misc_info.txt
ifdef PRODUCT_EXTRA_RECOVERY_KEYS
	@echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(ota_temp_root)/META/misc_info.txt
endif
	@echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(ota_temp_root)/META/misc_info.txt
	@echo "use_set_metadata=1" >> $(ota_temp_root)/META/misc_info.txt
	@echo "multistage_support=1" >> $(ota_temp_root)/META/misc_info.txt
	@echo "update_rename_support=1" >> $(ota_temp_root)/META/misc_info.txt
ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
	# OTA scripts are only interested in fingerprint related properties
	@echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(ota_temp_root)/META/misc_info.txt
endif
	$(call generate-userimage-prop-dictionary, $(ota_temp_root)/META/misc_info.txt)
	$(hide) cp -r $(PRODUCT_OUT)/boot.img $(ota_temp_root)/BOOTABLE_IMAGES/
	$(hide) cp -r $(PRODUCT_OUT)/recovery.img $(ota_temp_root)/BOOTABLE_IMAGES/
	$(hide) ./build/tools/releasetools/make_recovery_patch $(ota_temp_root) $(ota_temp_root)
	$(hide) cp --remove-destination $(ota_temp_root)/SYSTEM/bin/install-recovery.sh $(TARGET_OUT)/bin/install-recovery.sh
	$(hide) cp --remove-destination $(ota_temp_root)/SYSTEM/recovery-from-boot.p $(TARGET_OUT)/recovery-from-boot.p
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
	$(hide) mkdir -p $(dir $@)
	$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@

else
INSTALLED_RECOVERYIMAGE_TARGET :=
RECOVERY_RESOURCE_ZIP :=
endif

.PHONY: recoveryimage
recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)

@@ -924,7 +985,8 @@ INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
    $(ALL_GENERATED_SOURCES) \
    $(ALL_DEFAULT_INSTALLED_MODULES) \
    $(PDK_FUSION_SYSIMG_FILES) \
    $(RECOVERY_RESOURCE_ZIP))
    $(RECOVERY_RESOURCE_ZIP) \
    $(RECOVERY_PATCH_INSTALL))

FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
# -----------------------------------------------------------------
@@ -1358,6 +1420,12 @@ $(BUILT_TARGET_FILES_PACKAGE): \
	$(hide) mkdir -p $(zip_root)/RECOVERY
	$(hide) $(call package_files-copy-root, \
		$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
# Just copy the already built boot/recovery images into the target-files dir
# in order to avoid mismatched images between the out dir and what the ota
# build system tries to rebuild.
	$(hide) mkdir -p $(zip_root)/BOOTABLE_IMAGES
	$(hide) $(ACP) $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/BOOTABLE_IMAGES/
	$(hide) $(ACP) $(INSTALLED_RECOVERYIMAGE_TARGET) $(zip_root)/BOOTABLE_IMAGES/
ifdef INSTALLED_KERNEL_TARGET
	$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
endif
@@ -1463,7 +1531,7 @@ endif
	$(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "blockimgdiff_versions=1,2" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "blockimgdiff_versions=1,2,3" >> $(zip_root)/META/misc_info.txt
ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
	# OTA scripts are only interested in fingerprint related properties
	$(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
+1 −1
Original line number Diff line number Diff line
@@ -18,4 +18,4 @@
# (like "CRB01").  It must be a single word, and is
# capitalized by convention.

export BUILD_ID=LMY47D
export BUILD_ID=LMY47O
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

# Provides dependencies necessary for verified boot

PRODUCT_SUPPORTS_VERITY := false
PRODUCT_SUPPORTS_VERITY := true

# The dev key is used to sign boot and recovery images, and the verity
# metadata table. Actual product deliverables will be re-signed by hand.
+4 −14
Original line number Diff line number Diff line
@@ -30,9 +30,6 @@ if sys.hexversion < 0x02070000:

import errno
import os
import re
import shutil
import subprocess
import tempfile
import zipfile

@@ -70,10 +67,8 @@ def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None):
  block_list = common.MakeTempFile(prefix="system-blocklist-", suffix=".map")
  imgname = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict,
                        block_list=block_list)
  with open(imgname, "rb") as f:
    common.ZipWriteStr(output_zip, prefix + "system.img", f.read())
  with open(block_list, "rb") as f:
    common.ZipWriteStr(output_zip, prefix + "system.map", f.read())
  common.ZipWrite(output_zip, imgname, prefix + "system.img")
  common.ZipWrite(output_zip, block_list, prefix + "system.map")


def BuildSystem(input_dir, info_dict, block_list=None):
@@ -94,10 +89,8 @@ def AddVendor(output_zip, prefix="IMAGES/"):
  block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map")
  imgname = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict,
                     block_list=block_list)
  with open(imgname, "rb") as f:
    common.ZipWriteStr(output_zip, prefix + "vendor.img", f.read())
  with open(block_list, "rb") as f:
    common.ZipWriteStr(output_zip, prefix + "vendor.map", f.read())
  common.ZipWrite(output_zip, imgname, prefix + "vendor.img")
  common.ZipWrite(output_zip, block_list, prefix + "vendor.map")


def BuildVendor(input_dir, info_dict, block_list=None):
@@ -296,7 +289,6 @@ def AddImagesToTargetFiles(filename):
  output_zip.close()

def main(argv):

  def option_handler(o, a):
    if o in ("-a", "--add_missing"):
      OPTIONS.add_missing = True
@@ -312,8 +304,6 @@ def main(argv):
                                              "rebuild_recovery",
                                              ],
                             extra_option_handler=option_handler)


  if len(args) != 1:
    common.Usage(__doc__)
    sys.exit(1)
+53 −6
Original line number Diff line number Diff line
@@ -190,14 +190,14 @@ class Transfer(object):
# original image.

class BlockImageDiff(object):
  def __init__(self, tgt, src=None, threads=None, version=2):
  def __init__(self, tgt, src=None, threads=None, version=3):
    if threads is None:
      threads = multiprocessing.cpu_count() // 2
      if threads == 0: threads = 1
    self.threads = threads
    self.version = version

    assert version in (1, 2)
    assert version in (1, 2, 3)

    self.tgt = tgt
    if src is None:
@@ -244,6 +244,15 @@ class BlockImageDiff(object):
    self.ComputePatches(prefix)
    self.WriteTransfers(prefix)

  def HashBlocks(self, source, ranges):
    data = source.ReadRangeSet(ranges)
    ctx = sha1()

    for p in data:
      ctx.update(p)

    return ctx.hexdigest()

  def WriteTransfers(self, prefix):
    out = []

@@ -272,14 +281,22 @@ class BlockImageDiff(object):
          next_stash_id += 1
        stashes[s] = sid
        stashed_blocks += sr.size()
        if self.version == 2:
          out.append("stash %d %s\n" % (sid, sr.to_string_raw()))
        else:
          sh = self.HashBlocks(self.src, sr)
          if sh in stashes:
            stashes[sh] += 1
          else:
            stashes[sh] = 1
            out.append("stash %s %s\n" % (sh, sr.to_string_raw()))

      if stashed_blocks > max_stashed_blocks:
        max_stashed_blocks = stashed_blocks

      if self.version == 1:
        src_string = xf.src_ranges.to_string_raw()
      elif self.version == 2:
      elif self.version >= 2:

        #   <# blocks> <src ranges>
        #     OR
@@ -289,6 +306,7 @@ class BlockImageDiff(object):

        size = xf.src_ranges.size()
        src_string = [str(size)]
        free_string = []

        unstashed_src_ranges = xf.src_ranges
        mapped_stashes = []
@@ -296,9 +314,18 @@ class BlockImageDiff(object):
          sid = stashes.pop(s)
          stashed_blocks -= sr.size()
          unstashed_src_ranges = unstashed_src_ranges.subtract(sr)
          sh = self.HashBlocks(self.src, sr)
          sr = xf.src_ranges.map_within(sr)
          mapped_stashes.append(sr)
          if self.version == 2:
            src_string.append("%d:%s" % (sid, sr.to_string_raw()))
          else:
            assert sh in stashes
            src_string.append("%s:%s" % (sh, sr.to_string_raw()))
            stashes[sh] -= 1
            if stashes[sh] == 0:
              free_string.append("free %s\n" % (sh))
              stashes.pop(sh)
          heapq.heappush(free_stash_ids, sid)

        if unstashed_src_ranges:
@@ -314,7 +341,7 @@ class BlockImageDiff(object):

        src_string = " ".join(src_string)

      # both versions:
      # all versions:
      #   zero <rangeset>
      #   new <rangeset>
      #   erase <rangeset>
@@ -328,6 +355,11 @@ class BlockImageDiff(object):
      #   bsdiff patchstart patchlen <tgt rangeset> <src_string>
      #   imgdiff patchstart patchlen <tgt rangeset> <src_string>
      #   move <tgt rangeset> <src_string>
      #
      # version 3:
      #   bsdiff patchstart patchlen srchash tgthash <tgt rangeset> <src_string>
      #   imgdiff patchstart patchlen srchash tgthash <tgt rangeset> <src_string>
      #   move hash <tgt rangeset> <src_string>

      tgt_size = xf.tgt_ranges.size()

@@ -348,6 +380,11 @@ class BlockImageDiff(object):
            out.append("%s %s %s\n" % (
                xf.style,
                xf.tgt_ranges.to_string_raw(), src_string))
          elif self.version >= 3:
            out.append("%s %s %s %s\n" % (
                xf.style,
                self.HashBlocks(self.tgt, xf.tgt_ranges),
                xf.tgt_ranges.to_string_raw(), src_string))
          total += tgt_size
      elif xf.style in ("bsdiff", "imgdiff"):
        performs_read = True
@@ -361,6 +398,13 @@ class BlockImageDiff(object):
          out.append("%s %d %d %s %s\n" % (
              xf.style, xf.patch_start, xf.patch_len,
              xf.tgt_ranges.to_string_raw(), src_string))
        elif self.version >= 3:
          out.append("%s %d %d %s %s %s %s\n" % (
              xf.style,
              xf.patch_start, xf.patch_len,
              self.HashBlocks(self.src, xf.src_ranges),
              self.HashBlocks(self.tgt, xf.tgt_ranges),
              xf.tgt_ranges.to_string_raw(), src_string))
        total += tgt_size
      elif xf.style == "zero":
        assert xf.tgt_ranges
@@ -371,6 +415,9 @@ class BlockImageDiff(object):
      else:
        raise ValueError, "unknown transfer style '%s'\n" % (xf.style,)

      if free_string:
        out.append("".join(free_string))


      # sanity check: abort if we're going to need more than 512 MB if
      # stash space
Loading