feat(install): add installation script for building and symlinking the binary
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BIN_NAME="zesdex"
|
||||
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
TARGET_DIR="$REPO_DIR/target/release"
|
||||
BIN_PATH="$TARGET_DIR/$BIN_NAME"
|
||||
|
||||
echo "==> Building $BIN_NAME (release)..."
|
||||
cargo build --release --manifest-path "$REPO_DIR/Cargo.toml"
|
||||
|
||||
if [ ! -f "$BIN_PATH" ]; then
|
||||
echo "ERROR: build succeeded but binary not found at $BIN_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "==> Binary built: $BIN_PATH"
|
||||
|
||||
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
SYMLINK_PATH="$INSTALL_DIR/$BIN_NAME"
|
||||
|
||||
if [ -L "$SYMLINK_PATH" ] || [ -f "$SYMLINK_PATH" ]; then
|
||||
echo "==> Removing existing symlink or file at $SYMLINK_PATH"
|
||||
rm -f "$SYMLINK_PATH"
|
||||
fi
|
||||
|
||||
ln -s "$BIN_PATH" "$SYMLINK_PATH"
|
||||
echo "==> Symlinked: $SYMLINK_PATH -> $BIN_PATH"
|
||||
echo ""
|
||||
echo "Done. Make sure $INSTALL_DIR is in your PATH."
|
||||
Reference in New Issue
Block a user