Use embedded mruby for portablity
This commit is contained in:
56
installer.sh
56
installer.sh
@@ -4,59 +4,20 @@ set -eu
|
||||
|
||||
install() {
|
||||
BINARY_NAME="crib"
|
||||
VERSION="v0.0.1-alpha"
|
||||
RUBY_VERSION="3.4"
|
||||
HAVE_34=0
|
||||
HAVE_32=0
|
||||
VERSION="latest"
|
||||
BIN_URL="https://git.syedm.dev/SyedM-dev/crib/releases/download/$VERSION/crib-linux-x86_64"
|
||||
|
||||
if ldconfig -p | grep -q libruby.so.3.4; then
|
||||
HAVE_34=1
|
||||
fi
|
||||
if ldconfig -p | grep -q libruby-3.2.so; then
|
||||
HAVE_32=1
|
||||
fi
|
||||
ldconfig -p | grep libmagic >/dev/null 2>&1
|
||||
|
||||
if [ "$HAVE_34" = "1" ] && [ "$HAVE_32" = "1" ]; then
|
||||
echo "Multiple Ruby versions detected."
|
||||
echo "Select Ruby ABI:"
|
||||
echo " 1) Ruby 3.4"
|
||||
echo " 2) Ruby 3.2"
|
||||
read -r choice </dev/tty
|
||||
case "$choice" in
|
||||
1) RUBY_VERSION="3.4" ;;
|
||||
2) RUBY_VERSION="3.2" ;;
|
||||
*)
|
||||
echo "Invalid choice"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
elif [ "$HAVE_34" = "1" ]; then
|
||||
RUBY_VERSION="3.4"
|
||||
elif [ "$HAVE_32" = "1" ]; then
|
||||
RUBY_VERSION="3.2"
|
||||
else
|
||||
echo "No compatible Ruby library found need Ruby 3.2 or 3.4."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GITHUB_URL="https://github.com/SyedM-dev/crib/releases/download/$VERSION/crib-linux-x86_64-ruby$RUBY_VERSION"
|
||||
|
||||
missing_ruby=""
|
||||
missing_magic=""
|
||||
command -v ruby >/dev/null 2>&1 || missing_ruby="ruby"
|
||||
ldconfig -p | grep libmagic >/dev/null 2>&1 || missing_magic="libmagic"
|
||||
|
||||
if [ -n "$missing_ruby" ] || [ -n "$missing_magic" ]; then
|
||||
echo "Missing dependencies: ${missing_ruby} ${missing_magic}"
|
||||
if ! ldconfig -p | grep libmagic >/dev/null 2>&1; then
|
||||
echo "Missing dependency: libmagic (part of \`file\` package)"
|
||||
echo "Install them using your package manager:"
|
||||
echo "Ubuntu/Debian: sudo apt install ruby libmagic1"
|
||||
echo "Arch: sudo pacman -S ruby file"
|
||||
echo "Void: sudo xbps-install -Sy ruby file"
|
||||
echo "Arch: sudo pacman -S file"
|
||||
echo "Void: sudo xbps-install -Sy file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing Crib (Ruby $RUBY_VERSION)"
|
||||
|
||||
echo "Install locally (~/.local/bin) or globally (/usr/bin)? [l/g]"
|
||||
read -r choice </dev/tty
|
||||
case "$choice" in
|
||||
@@ -77,14 +38,13 @@ install() {
|
||||
$SUDO mkdir -p "$INSTALL_DIR"
|
||||
|
||||
echo "Downloading binary..."
|
||||
curl -L "$GITHUB_URL" -o /tmp/"$BINARY_NAME"
|
||||
curl -L "$BIN_URL" -o /tmp/"$BINARY_NAME"
|
||||
$SUDO install -m 755 /tmp/"$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
|
||||
rm -f /tmp/"$BINARY_NAME"
|
||||
|
||||
echo
|
||||
echo "✔ Crib installed to $INSTALL_DIR"
|
||||
echo "Run with: $BINARY_NAME"
|
||||
echo "Ruby ABI: $RUBY_VERSION"
|
||||
echo "Add $INSTALL_DIR to PATH if needed."
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user