diff --git a/core/Makefile b/core/Makefile index b280500916..ea80e3409c 100644 --- a/core/Makefile +++ b/core/Makefile @@ -2124,6 +2124,8 @@ ifdef BUILDING_RECOVERY_IMAGE INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \ $(ALL_DEFAULT_INSTALLED_MODULES)) +INTERNAL_RECOVERYIMAGE_FILES += $(filter $(PRODUCT_OUT)/install/%, \ + $(ALL_DEFAULT_INSTALLED_MODULES)) INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json) @@ -5747,6 +5749,9 @@ ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) $(hide) $(call package_files-copy-root, \ $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK) endif + @# OTA install helpers + $(hide) $(call package_files-copy-root, \ + $(PRODUCT_OUT)/install,$(zip_root)/INSTALL) ifdef INSTALLED_KERNEL_TARGET ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/ diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index f8247ee196..3c3ba8627a 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -245,6 +245,11 @@ def Mount(self, mount_point, mount_options_by_format=""): p.mount_point, mount_flags)) self.mounts.add(p.mount_point) + def UnpackPackageDir(self, src, dst): + """Unpack a given directory from the OTA package into the given + destination directory.""" + self.script.append('package_extract_dir("%s", "%s");' % (src, dst)) + def Comment(self, comment): """Write a comment into the update script.""" self.script.append("") @@ -383,6 +388,21 @@ def _CheckSecondTokenNotSlotSuffixed(self, s, fn): assert not entry.slotselect, \ "Use %s because %s is slot suffixed" % (fn, lst[1]) + def SetPermissionsRecursive(self, fn, uid, gid, dmode, fmode, selabel, + capabilities): + """Recursively set path ownership and permissions.""" + if capabilities is None: + capabilities = "0x0" + cmd = 'set_metadata_recursive("%s", "uid", %d, "gid", %d, ' \ + '"dmode", 0%o, "fmode", 0%o' \ + % (fn, uid, gid, dmode, fmode) + if not fn.startswith("/tmp"): + cmd += ', "capabilities", "%s"' % capabilities + if selabel is not None: + cmd += ', "selabel", "%s"' % selabel + cmd += ');' + self.script.append(cmd) + def WriteRawImage(self, mount_point, fn, mapfn=None): """Write the given package file into the partition for the given mount point.""" diff --git a/tools/releasetools/non_ab_ota.py b/tools/releasetools/non_ab_ota.py index f67cddd502..25e08b4a72 100644 --- a/tools/releasetools/non_ab_ota.py +++ b/tools/releasetools/non_ab_ota.py @@ -116,6 +116,15 @@ def GetIncrementalBlockDifferenceForPartition(name): return block_diff_dict +def CopyInstallTools(output_zip): + install_path = os.path.join(OPTIONS.input_tmp, "INSTALL") + for root, subdirs, files in os.walk(install_path): + for f in files: + install_source = os.path.join(root, f) + install_target = os.path.join("install", os.path.relpath(root, install_path), f) + output_zip.write(install_source, install_target) + + def WriteFullOTAPackage(input_zip, output_file): target_info = common.BuildInfo(OPTIONS.info_dict, OPTIONS.oem_dicts) @@ -220,6 +229,11 @@ def WriteFullOTAPackage(input_zip, output_file): script.Print(" ") device_specific.FullOTA_InstallBegin() + CopyInstallTools(output_zip) + script.UnpackPackageDir("install", "/tmp/install") + script.SetPermissionsRecursive("/tmp/install", 0, 0, 0o755, 0o644, None, None) + script.SetPermissionsRecursive("/tmp/install/bin", 0, 0, 0o755, 0o755, None, None) + # All other partitions as well as the data wipe use 10% of the progress, and # the update of the system partition takes the remaining progress. system_progress = 0.9 - (len(block_diff_dict) - 1) * 0.1 diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py index 5d403dc9f4..ff98ba9fb2 100644 --- a/tools/releasetools/ota_utils.py +++ b/tools/releasetools/ota_utils.py @@ -39,7 +39,7 @@ METADATA_NAME = 'META-INF/com/android/metadata' METADATA_PROTO_NAME = 'META-INF/com/android/metadata.pb' -UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'OTA/*', 'RADIO/*'] +UNZIP_PATTERN = ['IMAGES/*', 'INSTALL/*', 'META/*', 'OTA/*', 'RADIO/*'] SECURITY_PATCH_LEVEL_PROP_NAME = "ro.build.version.security_patch"