-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstaller.sh
executable file
·83 lines (61 loc) · 2.64 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/zsh
#/bin/zsh -c "$(curl -fsSL https://raw.githubusercontent.com/cbusillo/BD_to_AVP/release/installer.sh)"
handle_error() {
echo "Error: $1"
exit 1
}
echo "Checking macOS version and architecture..."
ARCH=$(uname -m)
MACOS_VERSION=$(sw_vers -productVersion)
MACOS_MAJOR_VERSION=${MACOS_VERSION%%.*}
if [[ "$ARCH" != "arm64" ]]; then
handle_error "This script is intended for use on Apple Silicon (M1+) Macs only."
fi
if [[ "$MACOS_MAJOR_VERSION" -lt 14 ]]; then
handle_error "This script requires macOS Sonoma 14.0 or higher."
fi
cd ~ || handle_error "Failed to change directory to ~"
echo "Checking for Homebrew..."
if command -v /opt/homebrew/bin/brew &>/dev/null; then
BREW_PATH="/opt/homebrew/bin"
else
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || handle_error "Failed to install Homebrew"
BREW_PATH="/opt/homebrew/bin"
fi
touch ~/.zshrc
if ! grep -q "$BREW_PATH" ~/.zshrc; then
echo "export PATH=\"$BREW_PATH:\$PATH\"" >> ~/.zshrc
fi
export PATH="$BREW_PATH:$PATH"
echo "Homebrew installed at $BREW_PATH."
echo "Updating Homebrew..."
"$BREW_PATH/brew" update
echo "Installing dependencies..."
"$BREW_PATH/brew" install python@3.12 2>/dev/null || handle_error "Failed to install dependencies"
echo "Creating a virtual environment for BD_to_AVP..."
VENV_PATH="$HOME/.bd_to_avp_venv"
python3.12 -m venv "$VENV_PATH" || handle_error "Failed to create a virtual environment"
echo "Activating the virtual environment..."
source "$VENV_PATH/bin/activate"
echo "Installing or updating BD_to_AVP from PyPI..."
pip install --upgrade bd_to_avp || echo "Failed to install/update BD_to_AVP from PyPI"
echo "Making BD_to_AVP executable accessible system-wide..."
EXECUTABLE_PATH="$VENV_PATH/bin/bd-to-avp"
SYSTEM_WIDE_PATH="/opt/homebrew/bin/bd-to-avp"
if [ -L "$SYSTEM_WIDE_PATH" ] || [ -e "$SYSTEM_WIDE_PATH" ]; then
echo "Existing BD_to_AVP executable or symlink found. Removing..."
rm -f "$SYSTEM_WIDE_PATH"
fi
ln -s "$EXECUTABLE_PATH" "$SYSTEM_WIDE_PATH" || handle_error "Failed to link BD_to_AVP executable system-wide"
echo "BD_to_AVP is now accessible system-wide as 'bd-to-avp'"
echo "Installing Rosetta 2 (if required)..."
if arch -x86_64 true 2>/dev/null; then
echo "Rosetta 2 support detected."
else
echo "Rosetta 2 not detected, attempting installation."
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
fi
echo "BD_to_AVP environment setup complete. Refresh your terminal's environment to use new paths."
echo "1. Refresh environment: source $HOME/.zshrc"
echo "2. Execute BD_to_AVP: bd-to-avp"