Skip to content

Instantly share code, notes, and snippets.

@sys9kdr
Last active April 15, 2023 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sys9kdr/069921fd13e9d606c73f982ac0a4736f to your computer and use it in GitHub Desktop.
Save sys9kdr/069921fd13e9d606c73f982ac0a4736f to your computer and use it in GitHub Desktop.
Haxe for Linux Installer/Uninstaller. Use at your own risk. I think asdf-haxe is better than this script. https://github.com/asdf-community/asdf-haxe
#!/usr/bin/env bash
# Haxe for Linux Installer.
# This script installs Haxe and neko on a Linux system.
# It is not well tested, checked, or documented.
# After installation, you may need to set $HAXE_STD_PATH to the directory where the Haxe standard library is located.
# Use at your own risk.
set -euo pipefail
# set -x
# Define the platform
PLATFORM=linux64
################
# Install Haxe
################
REPO=HaxeFoundation/Haxe
# Create a temporary directory
TEMP_DIR=$(mktemp -d)
# Retrieve the latest release version number
VERSION=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# Download the binary to the temporary directory
URL=https://github.com/$REPO/releases/download/$VERSION/haxe-$VERSION-$PLATFORM.tar.gz
# wget $URL -O $TEMP_DIR/haxe.tar.gz
wget -qO- $URL | tar xz -C $TEMP_DIR --strip-components=1
# Move haxe and haxelib to /usr/local/bin/
sudo mv $TEMP_DIR/{haxe,haxelib} /usr/local/bin/
# Move std directory to /usr/local/share/haxe/
sudo mkdir -p /usr/local/share/haxe/
sudo cp -R $TEMP_DIR/std /usr/local/share/haxe/
# Set HAXE_STD_PATH environment variable
# echo 'export HAXE_STD_PATH=/usr/local/share/haxe/std'
################
# Install neko
################
NEKO_REPO="HaxeFoundation/neko"
NEKO_DIR=$(mktemp -d)
NEKO_VERSION=$(curl -s https://api.github.com/repos/$NEKO_REPO/releases/latest | grep "tag_name" | cut -d\" -f4)
NEKO_VERSION_REMOVE_V=${NEKO_VERSION#"v"}
NEKO_VERSION_MOD=${NEKO_VERSION_REMOVE_V//-/\.} # tag_name is "v0-0-0", but filename is "neko-0.0.0-$PLATFORM.tar.gz". Why?
NEKO_URL="https://github.com/$NEKO_REPO/releases/download/$NEKO_VERSION/neko-$NEKO_VERSION_MOD-$PLATFORM.tar.gz"
wget -qO- $NEKO_URL | tar xz -C $NEKO_DIR --strip-components=1
# Move so, ndll files and executables to appropriate directories
sudo mkdir -p /usr/local/lib/x86_64-linux-gnu
sudo mv $NEKO_DIR/*.ndll /usr/local/lib/x86_64-linux-gnu
sudo mv $NEKO_DIR/libneko.so* /usr/local/lib/x86_64-linux-gnu
sudo mv $NEKO_DIR/{neko,nekoc,nekotools,nekoml} /usr/local/bin/
# Update libpath for /usr/local/lib/x86_64-linux-gnu
# sudo ldconfig
echo "Neko $NEKO_VERSION_MOD has been installed."
echo "Installation complete. Please run 'sudo ldconfig' to update the library cache if you get missing libs error."
# Clean up
rm -rf $TEMP_DIR
rm -rf $NEKO_DIR
#!/bin/bash
# Haxe for Linux Uninstaller.
# This script removes the Haxe installation.
set -euo pipefail
# Ask for confirmation
read -p "Are you sure you want to uninstall Haxe? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
################
# Uninstall Haxe
################
# Remove haxe and haxelib from /usr/local/bin/
sudo rm /usr/local/bin/{haxe,haxelib}
# Remove std directory from /usr/local/share/haxe/
sudo rm -rf /usr/local/share/haxe/std
################
# Uninstall neko
################
# Remove ndll files and executables from appropriate directories
sudo rm /usr/local/lib/x86_64-linux-gnu/*.ndll
sudo rm /usr/local/lib/x86_64-linux-gnu/libneko.so*
sudo rm /usr/local/bin/{neko,nekoc,nekotool,nekoml}
echo "Neko has been uninstalled."
echo "Run 'sudo ldcofig' if you need"
else
echo "Uninstallation cancelled."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment