Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4b69cf2

Browse files
authored
[tools][fuchsia] Do not tar debug symbol CIPD uploads (#17506)
Fuchsia is the main consumer of these CIPD packages and - to simplify its infrastructure - it is migrating its SDK partners over to producing a CIPD package containing a flat .build-id directory. This change also updates the CIPD package so that the .build-id directory is placed at the root. Bug: fxbug.dev/41443
1 parent faf44fe commit 4b69cf2

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

tools/fuchsia/merge_and_upload_debug_symbols.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,22 @@ def ProcessCIPDPackage(upload, cipd_yaml, engine_version, out_dir, target_arch):
7373
if tries == num_tries - 1:
7474
raise
7575

76-
def CreateTarFile(folder_path, base_dir):
77-
archive_name = os.path.basename(folder_path)
78-
tar_file_path = os.path.join(base_dir, archive_name + '.tar.bz2')
79-
with tarfile.open(tar_file_path, "w:bz2") as archive:
80-
for root, dirs, _ in os.walk(folder_path):
81-
for dir_name in dirs:
82-
dir_path = os.path.join(root, dir_name)
83-
archive.add(dir_path, arcname=dir_name)
84-
return tar_file_path
85-
76+
# Recursively hardlinks contents from one directory to another,
77+
# skipping over collisions.
78+
def HardlinkContents(dirA, dirB):
79+
for src_dir, _, filenames in os.walk(dirA):
80+
for filename in filenames:
81+
src = os.path.join(src_dir, filename)
82+
dest_dir = os.path.join(dirB, os.path.relpath(src_dir, dirA))
83+
os.makedirs(dest_dir, exist_ok=True)
84+
dest = os.path.join(dest_dir, filename)
85+
if os.path.exists(dest):
86+
# The last two path components provide a content address for a .build-id entry.
87+
tokens = os.path.split(dest)
88+
name = os.path.join(tokens[-2], tokens[-1])
89+
print('%s already exists in destination; skipping linking' % name)
90+
continue
91+
os.link(src, dest)
8692

8793
def main():
8894
parser = argparse.ArgumentParser()
@@ -114,18 +120,17 @@ def main():
114120
for symbol_dir in symbol_dirs:
115121
assert os.path.exists(symbol_dir) and os.path.isdir(symbol_dir)
116122

117-
arch = args.target_arch
118-
out_dir = os.path.join(args.out_dir,
119-
'flutter-fuchsia-debug-symbols-%s' % arch)
123+
out_dir = args.out_dir
124+
120125
if os.path.exists(out_dir):
121126
print 'Directory: %s is not empty, deleting it.' % out_dir
122127
shutil.rmtree(out_dir)
123128
os.makedirs(out_dir)
124129

125130
for symbol_dir in symbol_dirs:
126-
archive_path = CreateTarFile(symbol_dir, out_dir)
127-
print('Created archive: ' + archive_path)
131+
HardlinkContents(symbol_dir, out_dir)
128132

133+
arch = args.target_arch
129134
cipd_def = WriteCIPDDefinition(arch, out_dir)
130135
ProcessCIPDPackage(args.upload, cipd_def, args.engine_version, out_dir, arch)
131136
return 0

0 commit comments

Comments
 (0)