···11+#!/usr/bin/bash
22+# SPDX-License-Identifier: AGPL-3.0-only
33+# Copyright (c) 2026 MatrixFurry <matrix@matrixfurry.com>
44+55+set -euo pipefail
66+77+TAP_NAME="matrixfurry.com/xr"
88+TAP_URL="https://tangled.org/matrixfurry.com/homebrew-xr"
99+1010+info() { printf '\e[0;34m[INFO]\e[0m %s\n' "$*"; }
1111+warn() { printf '\e[0;33m[WARNING]\e[0m %s\n' "$*"; }
1212+error() { printf '\e[0;31m[ERROR]\e[0m %s\n' "$*"; }
1313+fatal() { printf '\e[0;31m[FATAL]\e[0m %s\n' "$*"; exit 1; }
1414+success() { printf '\e[0;32m[SUCCESS]\e[0m %s\n' "$*"; }
1515+1616+check_cmd() {
1717+ local cmd="$1"
1818+1919+ if [[ -z "$cmd" ]]; then
2020+ fatal "check_cmd requires a command to check (missing argument)"
2121+ fi
2222+2323+ command -v "$cmd" &>/dev/null
2424+}
2525+2626+brew_env() {
2727+ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
2828+ echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bashrc
2929+}
3030+3131+install_brew() {
3232+ if ! check_cmd curl; then
3333+ fatal "Curl is required to install Homebrew. Please install curl using your system package manager and try again."
3434+ fi
3535+3636+ info "Installing Homebrew"
3737+ if ! /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
3838+ fatal "Homebrew installation failed. See the output above for details."
3939+ fi
4040+4141+ info "Setting up homebrew environment"
4242+ if ! brew_env; then
4343+ fatal "Failed to set up Homebrew's environment. You may have to manually run the commands shown by the installer above."
4444+ fi
4545+4646+ if ! check_cmd brew; then
4747+ fatal "Homebrew was installed but is not available on your PATH. You may need to restart your shell, or manually run the commands shown by the installer above."
4848+ fi
4949+5050+ success "Successfully installed Homebrew"
5151+}
5252+5353+add_tap() {
5454+ info "Adding Linux VR Tap to Homebrew"
5555+5656+ if ! brew tap $TAP_NAME $TAP_URL; then
5757+ fatal "Failed to add Linux VR Tap. Try checking your internet connection first. See the output above for more details."
5858+ fi
5959+6060+ success "Successfully added Linux VR Tap"
6161+}
6262+6363+update_brew() {
6464+ info "Updating Homebrew"
6565+ if ! brew update; then
6666+ warning "Homebrew update failed"
6767+ fi
6868+}
6969+7070+main() {
7171+ info "Setting up the Linux VR Homebrew Tap"
7272+7373+ if check_cmd brew; then
7474+ info "Homebrew is already installed"
7575+ update_brew
7676+ else
7777+ info "Homebrew is not installed"
7878+ install_brew
7979+ fi
8080+8181+ if brew tap | grep -qx "$TAP_NAME"; then
8282+ info "The Homebrew Tap is already installed"
8383+ update_brew
8484+ else
8585+ add_tap
8686+ fi
8787+8888+ success "Done!"
8989+}
9090+9191+main