mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 04:12:42 +00:00
add homebrew-portable-ruby
This commit is contained in:
parent
fab8f1e39a
commit
86273c4881
@ -13,6 +13,7 @@ import requests
|
|||||||
BASE_URL = os.getenv("TUNASYNC_UPSTREAM_URL", "https://api.github.com/repos/")
|
BASE_URL = os.getenv("TUNASYNC_UPSTREAM_URL", "https://api.github.com/repos/")
|
||||||
WORKING_DIR = os.getenv("TUNASYNC_WORKING_DIR")
|
WORKING_DIR = os.getenv("TUNASYNC_WORKING_DIR")
|
||||||
REPOS = [
|
REPOS = [
|
||||||
|
"Homebrew/homebrew-portable-ruby", # Used by homebrew-bottles
|
||||||
"googlefonts/noto-fonts",
|
"googlefonts/noto-fonts",
|
||||||
"googlefonts/noto-cjk",
|
"googlefonts/noto-cjk",
|
||||||
"googlefonts/noto-emoji",
|
"googlefonts/noto-emoji",
|
||||||
@ -22,16 +23,16 @@ REPOS = [
|
|||||||
"openark/orchestrator",
|
"openark/orchestrator",
|
||||||
"git-lfs/git-lfs",
|
"git-lfs/git-lfs",
|
||||||
"prometheus/prometheus",
|
"prometheus/prometheus",
|
||||||
"commercialhaskell/stackage-content",
|
"commercialhaskell/stackage-content", # Used by stackage
|
||||||
"xxr3376/Learn-Project",
|
"xxr3376/Learn-Project",
|
||||||
"robertying/learnX",
|
"robertying/learnX",
|
||||||
"rust-analyzer/rust-analyzer",
|
"rust-analyzer/rust-analyzer",
|
||||||
]
|
]
|
||||||
|
|
||||||
FULL_DOWNLOAD_REPOS = [
|
FULL_DOWNLOAD_REPOS = [
|
||||||
"xxr3376/Learn-Project",
|
"xxr3376/Learn-Project",
|
||||||
"robertying/learnX",
|
"robertying/learnX",
|
||||||
]
|
]
|
||||||
|
|
||||||
# connect and read timeout value
|
# connect and read timeout value
|
||||||
TIMEOUT_OPTION = (7, 10)
|
TIMEOUT_OPTION = (7, 10)
|
||||||
@ -41,12 +42,12 @@ TIMEOUT_OPTION = (7, 10)
|
|||||||
def github_get(*args, **kwargs):
|
def github_get(*args, **kwargs):
|
||||||
headers = kwargs['headers'] if 'headers' in kwargs else {}
|
headers = kwargs['headers'] if 'headers' in kwargs else {}
|
||||||
if 'GITHUB_TOKEN' in os.environ:
|
if 'GITHUB_TOKEN' in os.environ:
|
||||||
headers['Authorization'] = 'token {}'.format(os.environ['GITHUB_TOKEN'])
|
headers['Authorization'] = 'token {}'.format(
|
||||||
|
os.environ['GITHUB_TOKEN'])
|
||||||
kwargs['headers'] = headers
|
kwargs['headers'] = headers
|
||||||
return requests.get(*args, **kwargs)
|
return requests.get(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def do_download(remote_url: str, dst_file: Path, remote_ts: float):
|
def do_download(remote_url: str, dst_file: Path, remote_ts: float):
|
||||||
# NOTE the stream=True parameter below
|
# NOTE the stream=True parameter below
|
||||||
with github_get(remote_url, stream=True) as r:
|
with github_get(remote_url, stream=True) as r:
|
||||||
@ -126,7 +127,8 @@ def main():
|
|||||||
|
|
||||||
if len(release['assets']) == 0:
|
if len(release['assets']) == 0:
|
||||||
url = release['tarball_url']
|
url = release['tarball_url']
|
||||||
updated = datetime.strptime(release['published_at'], '%Y-%m-%dT%H:%M:%SZ').timestamp()
|
updated = datetime.strptime(
|
||||||
|
release['published_at'], '%Y-%m-%dT%H:%M:%SZ').timestamp()
|
||||||
dst_file = repo_dir / name / 'repo-snapshot.tar.gz'
|
dst_file = repo_dir / name / 'repo-snapshot.tar.gz'
|
||||||
remote_filelist.append(dst_file.relative_to(working_dir))
|
remote_filelist.append(dst_file.relative_to(working_dir))
|
||||||
|
|
||||||
@ -138,13 +140,15 @@ def main():
|
|||||||
|
|
||||||
for asset in release['assets']:
|
for asset in release['assets']:
|
||||||
url = asset['browser_download_url']
|
url = asset['browser_download_url']
|
||||||
updated = datetime.strptime(asset['updated_at'], '%Y-%m-%dT%H:%M:%SZ').timestamp()
|
updated = datetime.strptime(
|
||||||
|
asset['updated_at'], '%Y-%m-%dT%H:%M:%SZ').timestamp()
|
||||||
dst_file = repo_dir / name / ensure_safe_name(asset['name'])
|
dst_file = repo_dir / name / ensure_safe_name(asset['name'])
|
||||||
remote_filelist.append(dst_file.relative_to(working_dir))
|
remote_filelist.append(dst_file.relative_to(working_dir))
|
||||||
|
|
||||||
if dst_file.is_file():
|
if dst_file.is_file():
|
||||||
if args.fast_skip:
|
if args.fast_skip:
|
||||||
print("fast skipping", dst_file.relative_to(working_dir), flush=True)
|
print("fast skipping", dst_file.relative_to(
|
||||||
|
working_dir), flush=True)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
stat = dst_file.stat()
|
stat = dst_file.stat()
|
||||||
@ -153,14 +157,14 @@ def main():
|
|||||||
# print(f"{local_filesize} vs {asset['size']}")
|
# print(f"{local_filesize} vs {asset['size']}")
|
||||||
# print(f"{local_mtime} vs {updated}")
|
# print(f"{local_mtime} vs {updated}")
|
||||||
if asset['size'] == local_filesize and local_mtime == updated:
|
if asset['size'] == local_filesize and local_mtime == updated:
|
||||||
print("skipping", dst_file.relative_to(working_dir), flush=True)
|
print("skipping", dst_file.relative_to(
|
||||||
|
working_dir), flush=True)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
dst_file.parent.mkdir(parents=True, exist_ok=True)
|
dst_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
task_queue.put((url, dst_file, working_dir, updated))
|
task_queue.put((url, dst_file, working_dir, updated))
|
||||||
|
|
||||||
|
|
||||||
for repo in args.repo:
|
for repo in args.repo:
|
||||||
repo_dir = working_dir / Path(repo)
|
repo_dir = working_dir / Path(repo)
|
||||||
print(f"syncing {repo} to {repo_dir}")
|
print(f"syncing {repo} to {repo_dir}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user