forked from succinctlabs/sp1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
61 lines (50 loc) · 2.09 KB
/
install
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
#!/usr/bin/env bash
# Reference: https://github.com/foundry-rs/foundry/blob/master/foundryup/install
set -e
echo Installing sp1up...
BASE_DIR=${XDG_CONFIG_HOME:-$HOME}
SP1_DIR=${SP1_DIR-"$BASE_DIR/.sp1"}
SP1_BIN_DIR="$SP1_DIR/bin"
BIN_URL="https://raw.githubusercontent.com/succinctlabs/sp1/main/sp1up/sp1up"
BIN_PATH="$SP1_BIN_DIR/sp1up"
# Create the .sp1 bin directory and sp1up binary if it doesn't exist.
mkdir -p $SP1_BIN_DIR
curl -# -L $BIN_URL -o $BIN_PATH
chmod +x $BIN_PATH
# Store the correct profile file (i.e. .profile for bash or .zshenv for ZSH).
case $SHELL in
*/zsh)
PROFILE=${ZDOTDIR-"$HOME"}/.zshenv
PREF_SHELL=zsh
;;
*/bash)
PROFILE=$HOME/.bashrc
PREF_SHELL=bash
;;
*/fish)
PROFILE=$HOME/.config/fish/config.fish
PREF_SHELL=fish
;;
*/ash)
PROFILE=$HOME/.profile
PREF_SHELL=ash
;;
*)
echo "sp1up: could not detect shell, manually add ${SP1_BIN_DIR} to your PATH."
exit 1
esac
# Only add sp1up if it isn't already in PATH.
if [[ ":$PATH:" != *":${SP1_BIN_DIR}:"* ]]; then
# Add the sp1up directory to the path and ensure the old PATH variables remain.
echo >> $PROFILE && echo "export PATH=\"\$PATH:$SP1_BIN_DIR\"" >> $PROFILE
fi
# Warn MacOS users that they may need to manually install libusb via Homebrew:
if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib && ! -f /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib ]]; then
echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install libusb)."
fi
# Warn MacOS users that they may need to manually install opensll via Homebrew:
if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/openssl/lib/libssl.3.dylib && ! -f /opt/homebrew/opt/openssl/lib/libssl.3.dylib ]]; then
echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install openssl)."
fi
echo && echo "Detected your preferred shell is ${PREF_SHELL} and added sp1up to PATH. Run 'source ${PROFILE}' or start a new terminal session to use sp1up."
echo "Then, simply run 'sp1up' to install SP1."