Skip to content

Commit

Permalink
build: ota: Support for install tools in /tmp/install
Browse files Browse the repository at this point in the history
 * Anything in OUT/install gets packaged up into the zip and extracted
   to /tmp/install immediately after FullOTA_InstallBegin.

 * Use /tmp/install in edify scripts and remove code related to using
   and manipulating /system for install tools.

 * Modified to support signing steps being split from build steps.

   Package install files into target-files INSTALL path
   Read from target-files for OTA package creation

   From Change-Id: I64f919c2a757b5474f6cc5f82bd6c33c2a8b558a

 * This also fully reverts commit 6a324ba and partially reverts
   commit f388104 as the functions are still needed here.

   From Change-Ids: I4911244ec9945d197d2b56d0d11eab6d2f7b6d3e
                    I4943e2e89ee5c810a63746c570dc5e31e95b8c53

Signed-off-by: Anush02198 <[email protected]>
  • Loading branch information
tdmcyngn authored and Anush02198 committed May 18, 2020
1 parent 5b8acc8 commit 4135d41
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
43 changes: 43 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4596,6 +4596,9 @@ ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_
$(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
$(hide) $(call package_files-copy-root, \
$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
@# OTA install helpers
$(hide) $(call package_files-copy-root, \
$(PRODUCT_OUT)/install,$(zip_root)/INSTALL)
ifdef INSTALLED_KERNEL_TARGET
cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
endif
Expand Down Expand Up @@ -4759,6 +4762,46 @@ endif
$(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
$(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
$(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
$(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
$(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
ifdef BOARD_FLASH_BLOCK_SIZE
$(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
$(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
endif
ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
endif
ifdef BOARD_INCLUDE_RECOVERY_DTBO
$(hide) echo "include_recovery_dtbo=true" >> $(zip_root)/META/misc_info.txt
endif
ifdef BOARD_INCLUDE_RECOVERY_ACPIO
$(hide) echo "include_recovery_acpio=true" >> $(zip_root)/META/misc_info.txt
endif
ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
$(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_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.
$(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
else
$(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
endif
$(hide) echo "tool_extensions=$(PRIVATE_TOOL_EXTENSIONS)" >> $(zip_root)/META/misc_info.txt
$(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
ifdef PRODUCT_EXTRA_RECOVERY_KEYS
$(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
endif
$(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
$(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt
$(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 "blockimgdiff_versions=3,4" >> $(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
endif
ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Expand Down
24 changes: 24 additions & 0 deletions tools/releasetools/edify_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,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("")
Expand Down Expand Up @@ -306,6 +311,25 @@ def PatchPartition(self, target, source, patch):
target=target, source=source, patch=patch,
code=common.ErrorCode.APPLY_PATCH_FAILURE)))

def SetPermissionsRecursive(self, fn, uid, gid, dmode, fmode, selabel,
capabilities):
"""Recursively set path ownership and permissions."""
if not self.info.get("use_set_metadata", False):
self.script.append('set_perm_recursive(%d, %d, 0%o, 0%o, "%s");'
% (uid, gid, dmode, fmode, fn))
else:
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."""
Expand Down
18 changes: 17 additions & 1 deletion tools/releasetools/ota_from_target_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt'
AB_PARTITIONS = 'META/ab_partitions.txt'
UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'OTA/*', 'RADIO/*']
# Files to be unzipped for target diffing purpose.
TARGET_DIFFING_UNZIP_PATTERN = ['BOOT', 'RECOVERY', 'SYSTEM/*', 'VENDOR/*',
'PRODUCT/*', 'SYSTEM_EXT/*', 'ODM/*']
UNZIP_PATTERN = ['IMAGES/*', 'INSTALL/*', 'META/*', 'RADIO/*']
RETROFIT_DAP_UNZIP_PATTERN = ['OTA/super_*.img', AB_PARTITIONS]

# Images to be excluded from secondary payload. We essentially only keep
Expand Down Expand Up @@ -910,6 +910,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)

Expand Down Expand Up @@ -1011,6 +1020,13 @@ def WriteFullOTAPackage(input_zip, output_file):
# 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
CopyInstallTools(output_zip)
script.UnpackPackageDir("install", "/tmp/install")
script.SetPermissionsRecursive("/tmp/install", 0, 0, 0755, 0644, None, None)
script.SetPermissionsRecursive("/tmp/install/bin", 0, 0, 0755, 0755, None, None)

system_progress = 0.75

if OPTIONS.wipe_user_data:
system_progress -= 0.1
progress_dict = {partition: 0.1 for partition in block_diff_dict}
Expand Down

0 comments on commit 4135d41

Please sign in to comment.