diff --git a/ityfuzzup/install b/ityfuzzup/install new file mode 100755 index 000000000..9576e3f2b --- /dev/null +++ b/ityfuzzup/install @@ -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." \ No newline at end of file diff --git a/ityfuzzup b/ityfuzzup/ityfuzzup old mode 100644 new mode 100755 similarity index 94% rename from ityfuzzup rename to ityfuzzup/ityfuzzup index ad7b55776..beeb7aad5 --- a/ityfuzzup +++ b/ityfuzzup/ityfuzzup @@ -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 @@ -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" @@ -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" @@ -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" @@ -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 @@ -209,7 +208,7 @@ EOF usage() { cat 1>&2 <