Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/hack/brew-install-version.sh
1637 views
1
#!/bin/bash
2
3
# SPDX-FileCopyrightText: Copyright The Lima Authors
4
# SPDX-License-Identifier: Apache-2.0
5
6
# This script only works for formulas in the homebrew-core.
7
# It assumes the homebrew-core has been checked out into ./homebrew-core.
8
# It only needs commit messages, so the checkout can be filtered with tree:0.
9
10
set -eu -o pipefail
11
12
FORMULA=$1
13
VERSION=$2
14
15
export HOMEBREW_NO_AUTO_UPDATE=1
16
export HOMEBREW_NO_INSTALL_UPGRADE=1
17
export HOMEBREW_NO_INSTALL_CLEANUP=1
18
19
TAP=lima/tap
20
if ! brew tap | grep -q "^${TAP}\$"; then
21
brew tap-new "$TAP"
22
fi
23
24
# Get the latest commit id for the commit that updated this bottle
25
SHA=$(git -C homebrew-core log --max-count 1 --grep "^${FORMULA}: update ${VERSION} bottle" --format="%H")
26
if [[ -z $SHA ]]; then
27
echo "${FORMULA} ${VERSION} not found"
28
exit 1
29
fi
30
31
OUTPUT="$(brew --repo "$TAP")/Formula/${FORMULA}.rb"
32
RAW="https://raw.githubusercontent.com/Homebrew/homebrew-core"
33
curl -s "${RAW}/${SHA}/Formula/${FORMULA::1}/${FORMULA}.rb" -o "$OUTPUT"
34
35
if brew ls -1 | grep -q "^${FORMULA}\$"; then
36
brew uninstall "$FORMULA" --ignore-dependencies
37
fi
38
brew install "${TAP}/${FORMULA}"
39
40