Unsparse images before generating OTA
Test: th Bug: 283172692 Change-Id: Ie6d3dc704fd9a8c107e2888222e4c2bf804dad3e
This commit is contained in:
@@ -48,6 +48,7 @@ METADATA_PROTO_NAME = 'META-INF/com/android/metadata.pb'
|
||||
UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'OTA/*',
|
||||
'RADIO/*', '*/build.prop', '*/default.prop', '*/build.default', "*/etc/vintf/*"]
|
||||
SECURITY_PATCH_LEVEL_PROP_NAME = "ro.build.version.security_patch"
|
||||
TARGET_FILES_IMAGES_SUBDIR = ["IMAGES", "PREBUILT_IMAGES", "RADIO"]
|
||||
|
||||
|
||||
def FinalizeMetadata(metadata, input_file, output_file, needed_property_files=None, package_key=None, pw=None):
|
||||
@@ -727,6 +728,15 @@ def ExtractTargetFiles(path: str):
|
||||
return path
|
||||
extracted_dir = common.MakeTempDir("target_files")
|
||||
common.UnzipToDir(path, extracted_dir, UNZIP_PATTERN + [""])
|
||||
for subdir in TARGET_FILES_IMAGES_SUBDIR:
|
||||
image_dir = os.path.join(extracted_dir, subdir)
|
||||
if not os.path.exists(image_dir):
|
||||
continue
|
||||
for filename in os.listdir(image_dir):
|
||||
if not filename.endswith(".img"):
|
||||
continue
|
||||
common.UnsparseImage(os.path.join(image_dir, filename))
|
||||
|
||||
return extracted_dir
|
||||
|
||||
|
||||
@@ -1047,12 +1057,18 @@ def Fnmatch(filename, pattersn):
|
||||
|
||||
def CopyTargetFilesDir(input_dir):
|
||||
output_dir = common.MakeTempDir("target_files")
|
||||
IMAGES_DIR = ["IMAGES", "PREBUILT_IMAGES", "RADIO"]
|
||||
for subdir in IMAGES_DIR:
|
||||
|
||||
def SymlinkIfNotSparse(src, dst):
|
||||
if common.IsSparseImage(src):
|
||||
return common.UnsparseImage(src, dst)
|
||||
else:
|
||||
return os.link(src, dst)
|
||||
|
||||
for subdir in TARGET_FILES_IMAGES_SUBDIR:
|
||||
if not os.path.exists(os.path.join(input_dir, subdir)):
|
||||
continue
|
||||
shutil.copytree(os.path.join(input_dir, subdir), os.path.join(
|
||||
output_dir, subdir), dirs_exist_ok=True, copy_function=os.link)
|
||||
output_dir, subdir), dirs_exist_ok=True, copy_function=SymlinkIfNotSparse)
|
||||
shutil.copytree(os.path.join(input_dir, "META"), os.path.join(
|
||||
output_dir, "META"), dirs_exist_ok=True)
|
||||
|
||||
|
Reference in New Issue
Block a user