Implement Homebrew support

This commit is contained in:
dabruh 2022-11-10 16:27:35 +01:00
parent 6ad6cf3504
commit 7d510486d4
2 changed files with 46 additions and 2 deletions

View file

@ -14,4 +14,6 @@ apt-laptop:brightnessctl
apt-any:libxcb-render0-dev,libffi-dev,python3-dev,python3-cffi
pip-any:flashfocus
brew-formulas-any:helm,shellcheck,velero,azure/kubelogin/kubelogin,derailed/k9s/k9s,fluxcd/tap/flux,weaveworks/tap/gitops
krew-any:ctx,krew,ns,slice,stern,tree

View file

@ -130,6 +130,44 @@ function install_picom() {
rm -Rf "$tmp"
}
function setup_homebrew() {
local dir="$HOME/homebrew"
echo "Setting up Homebrew."
if [ ! -d "$dir" ]; then
echo "Homebrew is already installed."
mkdir "$dir" || return 1
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C "$dir" || return 2
fi
echo "Updating Homebrew."
eval "$("$dir/bin/brew" shellenv)"
brew update --force
chmod -R go-w "$(brew --prefix)/share/zsh"
}
function setup_brew_formulas() {
local targets=("brew-formulas-any") packages
brew update || return 1
for package in $(get_packages "${targets[@]}"); do
if brew list --full-name | grep -Eq "(^| )$package($| )" >/dev/null; then
if $UPGRADE_PACKAGES; then
echo "Package '$package' will be upgraded."
brew upgrade "$package" || return 2
else
echo "Package '$package' already exists."
continue
fi
else
echo "Package '$package' will be installed."
brew install "$package" || return 2
fi
done
}
function setup_krew_plugins() {
local targets=("krew-any") packages
@ -207,7 +245,9 @@ function setup_arch() {
setup_arch_with_pip || return 4
configure_sddm || return 5
configure_ufw || return 6
setup_krew_plugins || return 7
setup_homebrew || return 7
setup_brew_formulas || return 8
setup_krew_plugins || return 9
}
#
@ -263,7 +303,9 @@ function setup_debian() {
setup_debian_with_git || return 4
configure_sddm || return 5
configure_ufw || return 6
setup_krew_plugins || return 7
setup_homebrew || return 7
setup_brew_formulas || return 8
setup_krew_plugins || return 9
}
ID_LIKE="$(grep ID_LIKE= </etc/os-release | cut -d= -f2)"