Merge "Use symlinks instead of hard links" into main

This commit is contained in:
Treehugger Robot
2023-09-25 23:26:56 +00:00
committed by Gerrit Code Review

View File

@@ -755,12 +755,10 @@ def ExtractTargetFiles(path: str):
def LocatePartitionPath(target_files_dir: str, partition: str, allow_empty): def LocatePartitionPath(target_files_dir: str, partition: str, allow_empty):
path = os.path.join(target_files_dir, "RADIO", partition + ".img") for subdir in TARGET_FILES_IMAGES_SUBDIR:
if os.path.exists(path): path = os.path.join(target_files_dir, subdir, partition + ".img")
return path if os.path.exists(path):
path = os.path.join(target_files_dir, "IMAGES", partition + ".img") return path
if os.path.exists(path):
return path
if allow_empty: if allow_empty:
return "" return ""
raise common.ExternalError( raise common.ExternalError(
@@ -773,12 +771,10 @@ def GetPartitionImages(target_files_dir: str, ab_partitions, allow_empty=True):
def LocatePartitionMap(target_files_dir: str, partition: str): def LocatePartitionMap(target_files_dir: str, partition: str):
path = os.path.join(target_files_dir, "RADIO", partition + ".map") for subdir in TARGET_FILES_IMAGES_SUBDIR:
if os.path.exists(path): path = os.path.join(target_files_dir, subdir, partition + ".map")
return path if os.path.exists(path):
path = os.path.join(target_files_dir, "IMAGES", partition + ".map") return path
if os.path.exists(path):
return path
return "" return ""
@@ -1061,7 +1057,7 @@ def CopyTargetFilesDir(input_dir):
if common.IsSparseImage(src): if common.IsSparseImage(src):
return common.UnsparseImage(src, dst) return common.UnsparseImage(src, dst)
else: else:
return os.link(src, dst) return os.symlink(os.path.realpath(src), dst)
for subdir in TARGET_FILES_IMAGES_SUBDIR: for subdir in TARGET_FILES_IMAGES_SUBDIR:
if not os.path.exists(os.path.join(input_dir, subdir)): if not os.path.exists(os.path.join(input_dir, subdir)):