mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-24 18:38:39 +03:00

This adds a new script `update-mirror.sh` which generates the proper blob format for R2 (or any blob storage) to mirror all of our dependencies. It doesn't automate updating build.zig.zon but on an ongoing basis this should be easy to do manually, and we can strive to automate it in the future. I omitted iTerm2 color themes because we auto-update that via CI and updating all of the machinery to send it to our mirror and so on is a pain. Additionally, this doesn't mirror transitive dependencies because Zig doesn't have a way to fetch those from a mirror instead (unless you pre-generate a full cache like packagers but that's not practical for day to day development). It's hugely beneficial just to get most of our dependencies mirrored.
31 lines
1009 B
Bash
Executable File
31 lines
1009 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# This script generates a directory that can be uploaded to blob
|
|
# storage to mirror our dependencies. The dependencies are unmodified
|
|
# so their checksum and content hashes will match.
|
|
|
|
set -e # Exit immediately if a command exits with a non-zero status
|
|
|
|
SCRIPT_PATH="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
|
INPUT_FILE="$SCRIPT_PATH/../../build.zig.zon2json-lock"
|
|
OUTPUT_DIR="blob"
|
|
|
|
# Ensure the output directory exists
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
# Use jq to iterate over the JSON and download files
|
|
jq -r 'to_entries[] | "\(.key) \(.value.name) \(.value.url)"' "$INPUT_FILE" | while read -r key name url; do
|
|
# Skip URLs that don't start with http(s). They aren't necessary for
|
|
# our mirror.
|
|
if ! echo "$url" | grep -Eq "^https?://"; then
|
|
continue
|
|
fi
|
|
|
|
# Extract the file extension from the URL
|
|
extension=$(echo "$url" | grep -oE '\.[a-z0-9]+(\.[a-z0-9]+)?$')
|
|
|
|
filename="${name}-${key}${extension}"
|
|
echo "$url -> $filename"
|
|
curl -L -o "$OUTPUT_DIR/$filename" "$url"
|
|
done
|