Merge changes from topic "productmanifest"

* changes:
  ota_from_target_files: include metadata when odm / product is changed.
  Add product manifest.
This commit is contained in:
Yifan Hong 2019-04-25 22:51:27 +00:00 committed by Gerrit Code Review
commit 001ebfcb30
4 changed files with 109 additions and 58 deletions

View File

@ -2069,29 +2069,6 @@ endif
FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT) FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
# -----------------------------------------------------------------
# Final System VINTF manifest including fragments. This is not assembled
# on the device because it depends on everything in a given device
# image which defines a vintf_fragment.
ifdef BUILDING_SYSTEM_IMAGE
BUILT_ASSEMBLED_SYSTEM_MANIFEST := $(PRODUCT_OUT)/verified_assembled_system_manifest.xml
$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(HOST_OUT_EXECUTABLES)/assemble_vintf
$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(BUILT_VENDOR_MATRIX)
$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(BUILT_SYSTEM_MANIFEST)
$(BUILT_ASSEMBLED_SYSTEM_MANIFEST): $(FULL_SYSTEMIMAGE_DEPS)
@echo "Verifying system VINTF manifest."
PRODUCT_ENFORCE_VINTF_MANIFEST=$(PRODUCT_ENFORCE_VINTF_MANIFEST) \
$(HOST_OUT_EXECUTABLES)/assemble_vintf \
-c $(BUILT_VENDOR_MATRIX) \
-i $(BUILT_SYSTEM_MANIFEST) \
$$([ -d $(TARGET_OUT)/etc/vintf/manifest ] && \
find $(TARGET_OUT)/etc/vintf/manifest -type f -name "*.xml" | \
sed "s/^/-i /" | tr '\n' ' ') -o $@
endif # BUILDING_SYSTEM_IMAGE
# ----------------------------------------------------------------- # -----------------------------------------------------------------
ifdef BUILDING_SYSTEM_IMAGE ifdef BUILDING_SYSTEM_IMAGE
@ -2284,7 +2261,6 @@ define build-systemimage-target
exit 1 ) exit 1 )
endef endef
$(BUILT_SYSTEMIMAGE): $(BUILT_ASSEMBLED_SYSTEM_MANIFEST)
$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS) $(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
$(call build-systemimage-target,$@) $(call build-systemimage-target,$@)
@ -2917,6 +2893,48 @@ INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET))) $(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
endif endif
# -----------------------------------------------------------------
# Final Framework VINTF manifest including fragments. This is not assembled
# on the device because it depends on everything in a given device
# image which defines a vintf_fragment.
ifdef BUILDING_SYSTEM_IMAGE
ifndef BOARD_USES_PRODUCTIMAGE
# If no product image at all, check system manifest directly against device matrix.
check_framework_manifest := true
else ifdef BUILDING_PRODUCT_IMAGE
# If device has a product image, only check if the product image is built.
check_framework_manifest := true
endif
ifeq ($(check_framework_manifest),true)
BUILT_ASSEMBLED_FRAMEWORK_MANIFEST := $(PRODUCT_OUT)/verified_assembled_framework_manifest.xml
$(BUILT_ASSEMBLED_FRAMEWORK_MANIFEST): $(HOST_OUT_EXECUTABLES)/assemble_vintf \
$(BUILT_VENDOR_MATRIX) \
$(BUILT_SYSTEM_MANIFEST) \
$(FULL_SYSTEMIMAGE_DEPS) \
$(BUILT_PRODUCT_MANIFEST) \
$(BUILT_PRODUCTIMAGE_TARGET)
@echo "Verifying framework VINTF manifest."
PRODUCT_ENFORCE_VINTF_MANIFEST=$(PRODUCT_ENFORCE_VINTF_MANIFEST) \
$(HOST_OUT_EXECUTABLES)/assemble_vintf \
-o $@ \
-c $(BUILT_VENDOR_MATRIX) \
-i $(BUILT_SYSTEM_MANIFEST) \
$(addprefix -i ,\
$(filter $(TARGET_OUT)/etc/vintf/manifest/%.xml,$(FULL_SYSTEMIMAGE_DEPS)) \
$(BUILT_PRODUCT_MANIFEST) \
$(filter $(TARGET_OUT_PRODUCT)/etc/vintf/manifest/%.xml,$(INTERNAL_PRODUCTIMAGE_FILES)))
droidcore: $(BUILT_ASSEMBLED_FRAMEWORK_MANIFEST)
endif # check_framework_manifest
check_framework_manifest :=
endif # BUILDING_SYSTEM_IMAGE
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# product_services partition image # product_services partition image
ifdef BUILDING_PRODUCT_SERVICES_IMAGE ifdef BUILDING_PRODUCT_SERVICES_IMAGE
@ -3809,7 +3827,7 @@ $(BUILT_TARGET_FILES_PACKAGE): \
$(HOST_OUT_EXECUTABLES)/bsdiff \ $(HOST_OUT_EXECUTABLES)/bsdiff \
$(HOST_OUT_EXECUTABLES)/care_map_generator \ $(HOST_OUT_EXECUTABLES)/care_map_generator \
$(BUILD_IMAGE_SRCS) \ $(BUILD_IMAGE_SRCS) \
$(BUILT_ASSEMBLED_SYSTEM_MANIFEST) \ $(BUILT_ASSEMBLED_FRAMEWORK_MANIFEST) \
$(BUILT_ASSEMBLED_VENDOR_MANIFEST) \ $(BUILT_ASSEMBLED_VENDOR_MANIFEST) \
$(BUILT_SYSTEM_MATRIX) \ $(BUILT_SYSTEM_MATRIX) \
$(BUILT_VENDOR_MATRIX) \ $(BUILT_VENDOR_MATRIX) \
@ -4156,8 +4174,8 @@ ifdef BUILDING_SYSTEM_OTHER_IMAGE
endif endif
@# Metadata for compatibility verification. @# Metadata for compatibility verification.
$(hide) cp $(BUILT_SYSTEM_MATRIX) $(zip_root)/META/system_matrix.xml $(hide) cp $(BUILT_SYSTEM_MATRIX) $(zip_root)/META/system_matrix.xml
ifdef BUILT_ASSEMBLED_SYSTEM_MANIFEST ifdef BUILT_ASSEMBLED_FRAMEWORK_MANIFEST
$(hide) cp $(BUILT_ASSEMBLED_SYSTEM_MANIFEST) $(zip_root)/META/system_manifest.xml $(hide) cp $(BUILT_ASSEMBLED_FRAMEWORK_MANIFEST) $(zip_root)/META/system_manifest.xml
endif endif
ifdef BUILT_ASSEMBLED_VENDOR_MANIFEST ifdef BUILT_ASSEMBLED_VENDOR_MANIFEST
$(hide) cp $(BUILT_ASSEMBLED_VENDOR_MANIFEST) $(zip_root)/META/vendor_manifest.xml $(hide) cp $(BUILT_ASSEMBLED_VENDOR_MANIFEST) $(zip_root)/META/vendor_manifest.xml

View File

@ -19,3 +19,4 @@ PRODUCT_PACKAGES += \
healthd \ healthd \
ModuleMetadata \ ModuleMetadata \
product_compatibility_matrix.xml \ product_compatibility_matrix.xml \
product_manifest.xml \

View File

@ -268,7 +268,7 @@ PRODUCT_PACKAGES += \
# VINTF data for system image # VINTF data for system image
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
framework_manifest.xml \ system_manifest.xml \
system_compatibility_matrix.xml \ system_compatibility_matrix.xml \
# Host tools to install # Host tools to install

View File

@ -318,13 +318,24 @@ class BuildInfo(object):
@property @property
def vendor_fingerprint(self): def vendor_fingerprint(self):
if "vendor.build.prop" not in self.info_dict: return self._fingerprint_of("vendor")
@property
def product_fingerprint(self):
return self._fingerprint_of("product")
@property
def odm_fingerprint(self):
return self._fingerprint_of("odm")
def _fingerprint_of(self, partition):
if partition + ".build.prop" not in self.info_dict:
return None return None
vendor_build_prop = self.info_dict["vendor.build.prop"] build_prop = self.info_dict[partition + ".build.prop"]
if "ro.vendor.build.fingerprint" in vendor_build_prop: if "ro." + partition + ".build.fingerprint" in build_prop:
return vendor_build_prop["ro.vendor.build.fingerprint"] return build_prop["ro." + partition + ".build.fingerprint"]
if "ro.vendor.build.thumbprint" in vendor_build_prop: if "ro." + partition + ".build.thumbprint" in build_prop:
return vendor_build_prop["ro.vendor.build.thumbprint"] return build_prop["ro." + partition + ".build.thumbprint"]
return None return None
@property @property
@ -692,14 +703,26 @@ def HasRecoveryPatch(target_files_zip):
"SYSTEM/etc/recovery.img" in namelist) "SYSTEM/etc/recovery.img" in namelist)
def HasVendorPartition(target_files_zip): def HasPartition(target_files_zip, partition):
try: try:
target_files_zip.getinfo("VENDOR/") target_files_zip.getinfo(partition.upper() + "/")
return True return True
except KeyError: except KeyError:
return False return False
def HasVendorPartition(target_files_zip):
return HasPartition(target_files_zip, "vendor")
def HasProductPartition(target_files_zip):
return HasPartition(target_files_zip, "product")
def HasOdmPartition(target_files_zip):
return HasPartition(target_files_zip, "odm")
def HasTrebleEnabled(target_files_zip, target_info): def HasTrebleEnabled(target_files_zip, target_info):
return (HasVendorPartition(target_files_zip) and return (HasVendorPartition(target_files_zip) and
target_info.GetBuildProp("ro.treble.enabled") == "true") target_info.GetBuildProp("ro.treble.enabled") == "true")
@ -745,23 +768,24 @@ def AddCompatibilityArchiveIfTrebleEnabled(target_zip, output_zip, target_info,
generating an incremental OTA; None otherwise. generating an incremental OTA; None otherwise.
""" """
def AddCompatibilityArchive(system_updated, vendor_updated): def AddCompatibilityArchive(framework_updated, device_updated):
"""Adds compatibility info based on system/vendor update status. """Adds compatibility info based on update status of both sides of Treble
boundary.
Args: Args:
system_updated: If True, the system image will be updated and therefore framework_updated: If True, the system / product image will be updated
its metadata should be included. and therefore their metadata should be included.
vendor_updated: If True, the vendor image will be updated and therefore device_updated: If True, the vendor / odm image will be updated and
its metadata should be included. therefore their metadata should be included.
""" """
# Determine what metadata we need. Files are names relative to META/. # Determine what metadata we need. Files are names relative to META/.
compatibility_files = [] compatibility_files = []
vendor_metadata = ("vendor_manifest.xml", "vendor_matrix.xml") device_metadata = ("vendor_manifest.xml", "vendor_matrix.xml")
system_metadata = ("system_manifest.xml", "system_matrix.xml") framework_metadata = ("system_manifest.xml", "system_matrix.xml")
if vendor_updated: if device_updated:
compatibility_files += vendor_metadata compatibility_files += device_metadata
if system_updated: if framework_updated:
compatibility_files += system_metadata compatibility_files += framework_metadata
# Create new archive. # Create new archive.
compatibility_archive = tempfile.NamedTemporaryFile() compatibility_archive = tempfile.NamedTemporaryFile()
@ -785,6 +809,11 @@ def AddCompatibilityArchiveIfTrebleEnabled(target_zip, output_zip, target_info,
arcname="compatibility.zip", arcname="compatibility.zip",
compress_type=zipfile.ZIP_STORED) compress_type=zipfile.ZIP_STORED)
def FingerprintChanged(source_fp, target_fp):
if source_fp is None or target_fp is None:
return True
return source_fp != target_fp
# Will only proceed if the target has enabled the Treble support (as well as # Will only proceed if the target has enabled the Treble support (as well as
# having a /vendor partition). # having a /vendor partition).
if not HasTrebleEnabled(target_zip, target_info): if not HasTrebleEnabled(target_zip, target_info):
@ -795,7 +824,7 @@ def AddCompatibilityArchiveIfTrebleEnabled(target_zip, output_zip, target_info,
if OPTIONS.skip_compatibility_check: if OPTIONS.skip_compatibility_check:
return return
# Full OTA carries the info for system/vendor both. # Full OTA carries the info for system/vendor/product/odm
if source_info is None: if source_info is None:
AddCompatibilityArchive(True, True) AddCompatibilityArchive(True, True)
return return
@ -804,16 +833,19 @@ def AddCompatibilityArchiveIfTrebleEnabled(target_zip, output_zip, target_info,
target_fp = target_info.fingerprint target_fp = target_info.fingerprint
system_updated = source_fp != target_fp system_updated = source_fp != target_fp
source_fp_vendor = source_info.vendor_fingerprint # other build fingerprints could be possibly blacklisted at build time. For
target_fp_vendor = target_info.vendor_fingerprint # such a case, we consider those images being changed.
# vendor build fingerprints could be possibly blacklisted at build time. For vendor_updated = FingerprintChanged(source_info.vendor_fingerprint,
# such a case, we consider the vendor images being changed. target_info.vendor_fingerprint)
if source_fp_vendor is None or target_fp_vendor is None: product_updated = HasProductPartition(target_zip) and \
vendor_updated = True FingerprintChanged(source_info.product_fingerprint,
else: target_info.product_fingerprint)
vendor_updated = source_fp_vendor != target_fp_vendor odm_updated = HasOdmPartition(target_zip) and \
FingerprintChanged(source_info.odm_fingerprint,
target_info.odm_fingerprint)
AddCompatibilityArchive(system_updated, vendor_updated) AddCompatibilityArchive(system_updated or product_updated,
vendor_updated or odm_updated)
def WriteFullOTAPackage(input_zip, output_file): def WriteFullOTAPackage(input_zip, output_file):