From e94346d82cb5915cad81ee2ef3dc311d3d763369 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 21 Feb 2020 21:44:11 +0800 Subject: [PATCH] add script to sync linuxbrew-bottles --- linuxbrew-bottles.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 linuxbrew-bottles.sh diff --git a/linuxbrew-bottles.sh b/linuxbrew-bottles.sh new file mode 100755 index 0000000..3e9fd67 --- /dev/null +++ b/linuxbrew-bottles.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Run in Docker image: tunathu/homebrew-mirror +set -e +set -o pipefail + +export HOMEBREW_REPO=${HOMEBREW_REPO:-"https://github.com/Homebrew"} +export HOMEBREW_TAPS=${HOMEBREW_TAPS:-"core"} +export HOMEBREW_BOTTLE_DOMAIN=${TUNASYNC_UPSTREAM_URL:-"https://linuxbrew.bintray.com"} + +# Refer to https://github.com/gaoyifan/homebrew-bottle-mirror/blob/master/.docker/run + +for tap in $HOMEBREW_TAPS; +do + if [[ "$tap" = core ]];then # special case for homebrew-core + export HOMEBREW_CACHE="${TUNASYNC_WORKING_DIR}/bottles" + else + export HOMEBREW_CACHE="${TUNASYNC_WORKING_DIR}/bottles-$tap" + export HOMEBREW_TAP="$tap" + fi + if [[ "$RUN_LINUXBREW" = true ]];then + repo_name="linuxbrew-${tap}" + args="linux" + else + repo_name="homebrew-${tap}" + args="mac" + fi + + echo "===== SYNC STARTED AT $(date -R) =====" + dir_core=/home/homebrew/.linuxbrew/homebrew/Library/Taps/homebrew/homebrew-core + rm -fr "$dir_core" &>/dev/null || true + echo "> update package info from $HOMEBREW_REPO/$repo_name.git..." + git clone --depth 1 "$HOMEBREW_REPO/$repo_name.git" "$dir_core" + echo "" + echo "> RUN brew bottle-mirror $args..." + /home/homebrew/.linuxbrew/bin/brew bottle-mirror "$args" +done