aboutsummaryrefslogtreecommitdiff
path: root/tools/releasetools/ota_from_target_files.py
diff options
context:
space:
mode:
authormosimchah <mosimchah@gmail.com>2025-12-02 09:26:21 -0500
committermosimchah <mosimchah@gmail.com>2025-12-02 09:26:21 -0500
commit278dd9b39c5a3de6320e17d3dd1d10bf447bcc49 (patch)
tree333c700c958401ad1ef3446d93eee54dac639cfa /tools/releasetools/ota_from_target_files.py
parent9b9f43f3305e3304678676813d1fd5945a5f40bf (diff)
parent00fcf469ba572bbce3f7c81fb346cccdbfa04219 (diff)
Merge branch 'lineage-23.1' of https://github.com/LineageOS/android_build into HEADw16.1
* 'lineage-23.1' of https://github.com/LineageOS/android_build: (415 commits) Exclude perf-setup-sh from userdebug builds Reapply "Drop legacy vboot support." Revert "build: Enable super image build rules depending on single super block device" Version bump to BP3A.250905.014 [core/build_id.mk] Version bump to BP3A.250905.013 [core/build_id.mk] Version bump to BP3A.250905.012 [core/build_id.mk] Version bump to BP3A.250905.011 [core/build_id.mk] Version bump to BP3A.250905.007.W1 [core/build_id.mk] Version bump to BP3A.250905.005.X5 [core/build_id.mk] Add apexd.mainline_patch_level_2 to PRODUCT_PACKAGES Version bump to BP3A.250905.009 [core/build_id.mk] Version bump to BP3A.250905.008 [core/build_id.mk] Version bump to BP3A.250905.005.X4 [core/build_id.mk] Version bump to BP3A.250905.005.Y1 [core/build_id.mk] Version bump to BP3A.250905.007 [core/build_id.mk] Version bump to BP3A.250905.005.X3 [core/build_id.mk] Version bump to BP3A.250905.005.X2 [core/build_id.mk] Version bump to BP3A.250905.005.X1 [core/build_id.mk] Version bump to BP3A.250905.006 [core/build_id.mk] Version bump to BP3A.250905.005 [core/build_id.mk] ... Change-Id: I84161b0f013eb40002a433053b9383240274e9ea
Diffstat (limited to 'tools/releasetools/ota_from_target_files.py')
-rwxr-xr-xtools/releasetools/ota_from_target_files.py153
1 files changed, 10 insertions, 143 deletions
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 26a09f8fb1..aebcda1eea 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -64,13 +64,6 @@ Common options that apply to both of non-A/B and A/B OTAs
Generate an OTA package that will wipe the user data partition when
installed.
- --retrofit_dynamic_partitions
- Generates an OTA package that updates a device to support dynamic
- partitions (default False). This flag is implied when generating
- an incremental OTA where the base build does not support dynamic
- partitions but the target build does. For A/B, when this flag is set,
- --skip_postinstall is implied.
-
--skip_compatibility_check
Skip checking compatibility of the input target files package.
@@ -253,9 +246,9 @@ A/B OTA specific options
older SPL.
--vabc_compression_param
- Compression algorithm to be used for VABC. Available options: gz, lz4, zstd, brotli, none.
- Compression level can be specified by appending ",$LEVEL" to option.
- e.g. --vabc_compression_param=gz,9 specifies level 9 compression with gz algorithm
+ Compression algorithm to be used for VABC. Available options: lz4, zstd, none.
+ Compression level can be specified by appending ",$LEVEL" to option.
+ e.g. --vabc_compression_param=zstd,9 specifies level 9 compression with zstd algorithm
--security_patch_level
Override the security patch level in target files
@@ -358,7 +351,6 @@ AB_PARTITIONS = 'META/ab_partitions.txt'
TARGET_DIFFING_UNZIP_PATTERN = ['BOOT', 'RECOVERY', 'SYSTEM/*', 'VENDOR/*',
'PRODUCT/*', 'SYSTEM_EXT/*', 'ODM/*',
'VENDOR_DLKM/*', 'ODM_DLKM/*', 'SYSTEM_DLKM/*']
-RETROFIT_DAP_UNZIP_PATTERN = ['OTA/super_*.img', AB_PARTITIONS]
# Images to be excluded from secondary payload. We essentially only keep
# 'system_other' and bootloader partitions.
@@ -485,7 +477,7 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False):
content = f.read()
# Remove virtual_ab flag from secondary payload so that OTA client
# don't use snapshots for secondary update
- delete_keys = ['virtual_ab', "virtual_ab_retrofit"]
+ delete_keys = ['virtual_ab']
return UpdatesInfoForSpecialUpdates(
content, lambda p: p not in SECONDARY_PAYLOAD_SKIPPED_IMAGES,
delete_keys)
@@ -698,77 +690,6 @@ def GetTargetFilesZipForPartialUpdates(input_file, ab_partitions):
return input_file
-def GetTargetFilesZipForRetrofitDynamicPartitions(input_file,
- super_block_devices,
- dynamic_partition_list):
- """Returns a target-files.zip for retrofitting dynamic partitions.
-
- This allows brillo_update_payload to generate an OTA based on the exact
- bits on the block devices. Postinstall is disabled.
-
- Args:
- input_file: The input target-files.zip filename.
- super_block_devices: The list of super block devices
- dynamic_partition_list: The list of dynamic partitions
-
- Returns:
- The filename of target-files.zip with *.img replaced with super_*.img for
- each block device in super_block_devices.
- """
- assert super_block_devices, "No super_block_devices are specified."
-
- replace = {'OTA/super_{}.img'.format(dev): 'IMAGES/{}.img'.format(dev)
- for dev in super_block_devices}
-
- # Remove partitions from META/ab_partitions.txt that is in
- # dynamic_partition_list but not in super_block_devices so that
- # brillo_update_payload won't generate update for those logical partitions.
- ab_partitions_lines = common.ReadFromInputFile(
- input_file, AB_PARTITIONS).split("\n")
- ab_partitions = [line.strip() for line in ab_partitions_lines]
- # Assert that all super_block_devices are in ab_partitions
- super_device_not_updated = [partition for partition in super_block_devices
- if partition not in ab_partitions]
- assert not super_device_not_updated, \
- "{} is in super_block_devices but not in {}".format(
- super_device_not_updated, AB_PARTITIONS)
- # ab_partitions -= (dynamic_partition_list - super_block_devices)
- to_delete = [AB_PARTITIONS]
-
- # Always skip postinstall for a retrofit update.
- to_delete += [POSTINSTALL_CONFIG]
-
- # Delete dynamic_partitions_info.txt so that brillo_update_payload thinks this
- # is a regular update on devices without dynamic partitions support.
- to_delete += [DYNAMIC_PARTITION_INFO]
-
- # Remove the existing partition images as well as the map files.
- to_delete += list(replace.values())
- to_delete += ['IMAGES/{}.map'.format(dev) for dev in super_block_devices]
- for item in to_delete:
- os.unlink(os.path.join(input_file, item))
-
- # Write super_{foo}.img as {foo}.img.
- for src, dst in replace.items():
- assert DoesInputFileContain(input_file, src), \
- 'Missing {} in {}; {} cannot be written'.format(src, input_file, dst)
- source_path = os.path.join(input_file, *src.split("/"))
- target_path = os.path.join(input_file, *dst.split("/"))
- os.rename(source_path, target_path)
-
- # Write new ab_partitions.txt file
- new_ab_partitions = os.path.join(input_file, AB_PARTITIONS)
- with open(new_ab_partitions, 'w') as f:
- for partition in ab_partitions:
- if (partition in dynamic_partition_list and
- partition not in super_block_devices):
- logger.info("Dropping %s from ab_partitions.txt", partition)
- continue
- f.write(partition + "\n")
-
- return input_file
-
-
def GetTargetFilesZipForCustomImagesUpdates(input_file, custom_images: dict):
"""Returns a target-files.zip for custom partitions update.
@@ -822,45 +743,6 @@ def GeneratePartitionTimestampFlagsDowngrade(
]
-def SupportsMainlineGkiUpdates(target_file):
- """Return True if the build supports MainlineGKIUpdates.
-
- This function scans the product.img file in IMAGES/ directory for
- pattern |*/apex/com.android.gki.*.apex|. If there are files
- matching this pattern, conclude that build supports mainline
- GKI and return True
-
- Args:
- target_file: Path to a target_file.zip, or an extracted directory
- Return:
- True if thisb uild supports Mainline GKI Updates.
- """
- if target_file is None:
- return False
- if os.path.isfile(target_file):
- target_file = common.UnzipTemp(target_file, ["IMAGES/product.img"])
- if not os.path.isdir(target_file):
- assert os.path.isdir(target_file), \
- "{} must be a path to zip archive or dir containing extracted"\
- " target_files".format(target_file)
- image_file = os.path.join(target_file, "IMAGES", "product.img")
-
- if not os.path.isfile(image_file):
- return False
-
- if IsSparseImage(image_file):
- # Unsparse the image
- tmp_img = common.MakeTempFile(suffix=".img")
- subprocess.check_output(["simg2img", image_file, tmp_img])
- image_file = tmp_img
-
- cmd = ["debugfs_static", "-R", "ls -p /apex", image_file]
- output = subprocess.check_output(cmd).decode()
-
- pattern = re.compile(r"com\.android\.gki\..*\.apex")
- return pattern.search(output) is not None
-
-
def ExtractOrCopyTargetFiles(target_file):
if os.path.isdir(target_file):
return CopyTargetFilesDir(target_file)
@@ -1050,11 +932,7 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
target_file = GetTargetFilesZipForCustomImagesUpdates(
target_file, OPTIONS.custom_images)
- if OPTIONS.retrofit_dynamic_partitions:
- target_file = GetTargetFilesZipForRetrofitDynamicPartitions(
- target_file, target_info.get("super_block_devices").strip().split(),
- target_info.get("dynamic_partition_list").strip().split())
- elif OPTIONS.partial:
+ if OPTIONS.partial:
target_file = GetTargetFilesZipForPartialUpdates(target_file,
OPTIONS.partial)
if vabc_compression_param != target_info.vabc_compression_param:
@@ -1273,7 +1151,7 @@ def main(argv):
elif o == "--skip_postinstall":
OPTIONS.skip_postinstall = True
elif o == "--retrofit_dynamic_partitions":
- OPTIONS.retrofit_dynamic_partitions = True
+ raise ValueError("Retrofit dynamic partitions is no longer supported")
elif o == "--skip_compatibility_check":
OPTIONS.skip_compatibility_check = True
elif o == "--output_metadata_path":
@@ -1380,7 +1258,6 @@ def main(argv):
"log_diff=",
"extracted_input_target_files=",
"skip_postinstall",
- "retrofit_dynamic_partitions",
"skip_compatibility_check",
"output_metadata_path=",
"disable_fec_computation",
@@ -1437,7 +1314,7 @@ def main(argv):
if OPTIONS.incremental_source is None and OPTIONS.downgrade:
raise ValueError("Cannot generate downgradable full OTAs")
- # TODO(xunchang) for retrofit and partial updates, maybe we should rebuild the
+ # TODO(xunchang) for partial updates, maybe we should rebuild the
# target-file and reload the info_dict. So the info will be consistent with
# the modified target-file.
@@ -1467,22 +1344,12 @@ def main(argv):
# Load OEM dicts if provided.
OPTIONS.oem_dicts = _LoadOemDicts(OPTIONS.oem_source)
- # Assume retrofitting dynamic partitions when base build does not set
- # use_dynamic_partitions but target build does.
if (OPTIONS.source_info_dict and
OPTIONS.source_info_dict.get("use_dynamic_partitions") != "true" and
OPTIONS.target_info_dict.get("use_dynamic_partitions") == "true"):
- if OPTIONS.target_info_dict.get("dynamic_partition_retrofit") != "true":
- raise common.ExternalError(
- "Expect to generate incremental OTA for retrofitting dynamic "
- "partitions, but dynamic_partition_retrofit is not set in target "
- "build.")
- logger.info("Implicitly generating retrofit incremental OTA.")
- OPTIONS.retrofit_dynamic_partitions = True
-
- # Skip postinstall for retrofitting dynamic partitions.
- if OPTIONS.retrofit_dynamic_partitions:
- OPTIONS.skip_postinstall = True
+ logger.error("Retrofitting dynamic partitions is no longer supported.")
+ raise common.ExternalError(
+ "Both source and target builds must have dynamic partition support")
ab_update = OPTIONS.info_dict.get("ab_update") == "true"
allow_non_ab = OPTIONS.info_dict.get("allow_non_ab") == "true"