|
|
@@ -89,27 +89,51 @@ runs:
|
|
|
print(f"Syncing: {name} -> {path}")
|
|
|
print(f" Download URL: {url}")
|
|
|
try:
|
|
|
- aria_cmd = f"aria2c -x16 -s16 -k1M -j5 --file-allocation=none -o {name}.tar.gz '{url}'"
|
|
|
- subprocess.run(aria_cmd, shell=True, check=True)
|
|
|
+ def try_download(url, name):
|
|
|
+ aria_cmd = f"aria2c -x16 -s16 -k1M -j5 --file-allocation=none -o {name}.tar.gz '{url}'"
|
|
|
+ print(f" Trying download: {url}")
|
|
|
+ result = subprocess.run(aria_cmd, shell=True)
|
|
|
+ return result.returncode == 0
|
|
|
+
|
|
|
+ downloaded = False
|
|
|
+ # Only apply deprecated fallback for googlesource URLs
|
|
|
+ if "googlesource.com" in url:
|
|
|
+ # Try main branch first
|
|
|
+ downloaded = try_download(url, name)
|
|
|
+ if not downloaded:
|
|
|
+ # Try deprecated branch
|
|
|
+ if "+archive/" in url:
|
|
|
+ parts = url.split("+archive/")
|
|
|
+ branch = parts[1].split(".tar.gz")[0]
|
|
|
+ dep_url = f"{parts[0]}+archive/deprecated/{branch}.tar.gz"
|
|
|
+ print(f" Main branch failed, trying deprecated branch: {dep_url}")
|
|
|
+ downloaded = try_download(dep_url, name)
|
|
|
+ else:
|
|
|
+ downloaded = try_download(url, name)
|
|
|
+
|
|
|
+ if not downloaded:
|
|
|
+ print(f"Failed to download {name} from all attempted URLs.")
|
|
|
+ return False
|
|
|
+
|
|
|
tar_cmd = f"tar -I 'pigz -p {NPROC} -b 256' -x --record-size=1M -C {path} {strip} -f {name}.tar.gz"
|
|
|
subprocess.run(tar_cmd, shell=True, check=True)
|
|
|
os.remove(f"{name}.tar.gz")
|
|
|
# Handle linkfiles and copyfiles
|
|
|
top_dir = os.getcwd()
|
|
|
for src_rel, dest_rel in linkfiles:
|
|
|
- src_path = os.path.join(top_dir, path, src_rel)
|
|
|
- dest_path = os.path.join(top_dir, dest_rel)
|
|
|
- os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
|
|
- if os.path.lexists(dest_path): os.remove(dest_path)
|
|
|
- rel_target = os.path.relpath(src_path, os.path.dirname(dest_path))
|
|
|
- os.symlink(rel_target, dest_path)
|
|
|
- print(f" [Link] {dest_rel} -> {src_rel}")
|
|
|
+ src_path = os.path.join(top_dir, path, src_rel)
|
|
|
+ dest_path = os.path.join(top_dir, dest_rel)
|
|
|
+ os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
|
|
+ if os.path.lexists(dest_path): os.remove(dest_path)
|
|
|
+ rel_target = os.path.relpath(src_path, os.path.dirname(dest_path))
|
|
|
+ os.symlink(rel_target, dest_path)
|
|
|
+ print(f" [Link] {dest_rel} -> {src_rel}")
|
|
|
for src_rel, dest_rel in copyfiles:
|
|
|
- src_path = os.path.join(top_dir, path, src_rel)
|
|
|
- dest_path = os.path.join(top_dir, dest_rel)
|
|
|
- os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
|
|
- shutil.copy2(src_path, dest_path)
|
|
|
- print(f" [Copy] {dest_rel} from {src_rel}")
|
|
|
+ src_path = os.path.join(top_dir, path, src_rel)
|
|
|
+ dest_path = os.path.join(top_dir, dest_rel)
|
|
|
+ os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
|
|
+ shutil.copy2(src_path, dest_path)
|
|
|
+ print(f" [Copy] {dest_rel} from {src_rel}")
|
|
|
print(f"Synced {name} successfully!")
|
|
|
return True
|
|
|
except Exception as e:
|