Skip to content

Commit

Permalink
Update ityfuzzup
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAWM committed Oct 5, 2023
1 parent f5c5459 commit 079b5d4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 11 deletions.
55 changes: 55 additions & 0 deletions ityfuzzup/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -e

echo Installing ityfuzzup...

BASE_DIR=${XDG_CONFIG_HOME:-$HOME}
ITYFUZZ_DIR=${ITYFUZZ_DIR-"$BASE_DIR/.ityfuzz"}
ITYFUZZ_BIN_DIR="$ITYFUZZ_DIR/bin"

BIN_URL="https://raw.githubusercontent.com/fuzzland/ityfuzz/master/ityfuzzup/ityfuzzup"
BIN_PATH="$ITYFUZZ_BIN_DIR/ityfuzzup"


# Create the .ityfuzz bin directory and ityfuzzup binary if it doesn't exist.
mkdir -p $ITYFUZZ_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 "ityfuzzup: could not detect shell, manually add ${ITYFUZZ_BIN_DIR} to your PATH."
exit 1
esac

# Only add ityfuzzup if it isn't already in PATH.
if [[ ":$PATH:" != *":${ITYFUZZ_BIN_DIR}:"* ]]; then
# Add the ityfuzzup directory to the path and ensure the old PATH variables remain.
echo >> $PROFILE && echo "export PATH=\"\$PATH:$ITYFUZZ_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

echo && echo "Detected your preferred shell is ${PREF_SHELL} and added ityfuzzup to PATH. Run 'source ${PROFILE}' or start a new terminal session to use ityfuzzup."
echo "Then, simply run 'ityfuzzup' to install ityfuzz."
21 changes: 10 additions & 11 deletions ityfuzzup → ityfuzzup/ityfuzzup
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ main() {
exit 0
fi

ITYFUZZ_REPO=${ITYFUZZ_REPO:fuzzland/ityfuzz}
ITYFUZZ_REPO=${ITYFUZZ_REPO:-fuzzland/ityfuzz}

# Install by downloading binaries
if [[ "$ITYFUZZ_REPO" == "fuzzland/ityfuzz" && -z "$ITYFUZZ_BRANCH" && -z "$ITYFUZZ_COMMIT" ]]; then
Expand All @@ -94,7 +94,7 @@ main() {
ITYFUZZ_TAG="${ITYFUZZ_VERSION}"
fi

say "installing ITYFUZZ (version ${ITYFUZZ_VERSION}, tag ${ITYFUZZ_TAG})"
say "installing ityfuzz (version ${ITYFUZZ_VERSION}, tag ${ITYFUZZ_TAG})"

PLATFORM="$(uname -s)"
EXT="tar.gz"
Expand Down Expand Up @@ -128,15 +128,14 @@ main() {
ARCHITECTURE="amd64" # Amd.
fi

# Compute the URL of the release tarball in the ITYFUZZ repository.
# Compute the URL of the release tarball in the ityfuzz repository.
RELEASE_URL="https://github.com/${ITYFUZZ_REPO}/releases/download/${ITYFUZZ_TAG}/"
BIN_ARCHIVE_URL="${RELEASE_URL}ITYFUZZ_${ITYFUZZ_VERSION}_${PLATFORM}_${ARCHITECTURE}.$EXT"
MAN_TARBALL_URL="${RELEASE_URL}ITYFUZZ_man_${ITYFUZZ_VERSION}.tar.gz"
BIN_ARCHIVE_URL="${RELEASE_URL}ityfuzz_${ITYFUZZ_VERSION}_${PLATFORM}_${ARCHITECTURE}.$EXT"

# Download and extract the binaries archive
say "downloading latest forge, cast, anvil, and chisel"
say "downloading latest ityfuzz binaries"
if [ "$PLATFORM" = "win32" ]; then
tmp="$(mktemp -d 2>/dev/null || echo ".")/ITYFUZZ.zip"
tmp="$(mktemp -d 2>/dev/null || echo ".")/ityfuzz.zip"
ensure download "$BIN_ARCHIVE_URL" "$tmp"
ensure unzip "$tmp" -d "$ITYFUZZ_BIN_DIR"
rm -f "$tmp"
Expand Down Expand Up @@ -173,7 +172,7 @@ EOF
ITYFUZZ_BRANCH=${ITYFUZZ_BRANCH:-master}
REPO_PATH="$ITYFUZZ_DIR/$ITYFUZZ_REPO"

# If repo path does not exist, grab the author from the repo, make a directory in .ITYFUZZ, cd to it and clone.
# If repo path does not exist, grab the author from the repo, make a directory in .ityfuzz, cd to it and clone.
if [ ! -d "$REPO_PATH" ]; then
AUTHOR="$(echo "$ITYFUZZ_REPO" | cut -d'/' -f1 -)"
ensure mkdir -p "$ITYFUZZ_DIR/$AUTHOR"
Expand All @@ -192,7 +191,7 @@ EOF
ensure git checkout "$ITYFUZZ_COMMIT"
fi

# Build the repo and install the binaries locally to the .ITYFUZZ bin directory.
# Build the repo and install the binaries locally to the .ityfuzz bin directory.
ensure cargo build --bins --release
for bin in "${BINS[@]}"; do
for try_path in target/release/$bin target/release/$bin.exe; do
Expand All @@ -209,7 +208,7 @@ EOF

usage() {
cat 1>&2 <<EOF
The installer for ITYFUZZ.
The installer for ityfuzz.
Update or revert to a specific ITYFUZZ version with ease.
Expand All @@ -228,7 +227,7 @@ EOF
}

say() {
printf "ITYFUZZ: %s\n" "$1"
printf "ityfuzz: %s\n" "$1"
}

warn() {
Expand Down

0 comments on commit 079b5d4

Please sign in to comment.