Skip to content

Commit

Permalink
homebrew-bottles: Workaround for ISP reachable to formulae.brew.sh an…
Browse files Browse the repository at this point in the history
…d pkg-containers.githubusercontent.com

- Only IPv6 cernet accesses formulae.brew.sh fast
- While only mobile accesses pkg-containers.githubusercontent.com

Allow settings a different ISP besides BIND_ADDRESS for brew.sh.
  • Loading branch information
taoky committed Dec 4, 2024
1 parent 941f081 commit 9add1fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ A script for syncing projects (especially AOSP) using Google's `repo` tool.
| Parameter | Description |
| ----------------------- | ----------------------------------- |
| `HOMEBREW_BOTTLES_JOBS` | Parallel jobs. Defaults to `1` |
| `BREW_SH_BIND_ADDRESS` | Bind address for accessing formulae.brew.sh API |

### julia-storage

Expand Down
7 changes: 7 additions & 0 deletions homebrew-bottles/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CASK_SOURCES=$(mktemp)

curl_init

BOTTLES_BIND_ADDRESS="$BIND_ADDRESS"

# Step 1: Download new API jsons and extract

# 2 special jsons for further processing
Expand All @@ -30,6 +32,10 @@ FILES=(
)
URL_BASE="https://formulae.brew.sh/api"

if [ -n "$BREW_SH_BIND_ADDRESS" ]; then
BIND_ADDRESS="$BREW_SH_BIND_ADDRESS"
fi

for file in "${FILES[@]}"; do
$CURL_WRAP --compressed -sSL -o "$TO/api/$file".tmp "$URL_BASE/$file"
if [[ $? -ne 0 ]]; then
Expand Down Expand Up @@ -97,6 +103,7 @@ Authorization: Bearer QQ==
EOF

# parallel downloading
BIND_ADDRESS="$BOTTLES_BIND_ADDRESS"
export by_hash=$(realpath $TO/.by-hash)
export local_dir=$TO
export CURL_WRAP="$CURL_WRAP --header @$headers_file"
Expand Down

0 comments on commit 9add1fd

Please sign in to comment.