HaxeQuick

Written on December 4, 2014

Bash script from OpenFL with modification to install any Haxe version, not just the current static.

#!/bin/sh

clear

NEKO_VERSION=2.0.0

wget -q http://haxe.org/website-content/downloads/versions.json
grep  -w "current" versions.json

echo -n "Provide the version of Haxe you need as x.x.x and then press [ENTER]: "
read HAXE_VERSION

if ! [[ "$HAXE_VERSION" =~ ^[0-9]+(\.[0-9]+)+(\.[0-9]+)?$ ]]; then 
	echo "This is not a valid number." 

else  

	if grep -q "$HAXE_VERSION" "versions.json"

		then  echo ""
		echo "---------------------------------------"
		echo "The version $HAXE_VERSION was found online."
		echo "---------------------------------------"
		HAXE_VERSION_COMMA="${HAXE_VERSION//./,}"
		rm versions.json

	if [ "$1" = "y" -o "$1" = "-y" ]; then
		
		echo "Do you want to install Haxe $HAXE_VERSION and Neko $NEKO_VERSION? (y/n) y"
		RESP=y
		
	else
		
		read -p "Do you want to install Haxe $HAXE_VERSION and Neko $NEKO_VERSION? (y/n) " RESP
		
	fi


	if [ $RESP = "y" ]; then
		
		
		if [ -n "$(command -v yum)" ]; then
			
			echo ""
			echo "---------------------------------------"
			echo "    Installing Dependencies"
			echo "---------------------------------------"
			
			yum -y install wget
			
		elif [ -n "$(command -v pacman)" ]; then
			
			echo ""
			echo "---------------------------------------"
			echo "    Installing Dependencies"
			echo "---------------------------------------"
			
			set -e
			pacman -S wget --noconfirm
			
		elif [ -n "$(command -v apt-get)" ]; then
			
			echo ""
			echo "---------------------------------------"
			echo "    Removing Haxe (if installed)"
			echo "---------------------------------------"
			
			set +e
			apt-get remove haxe neko
			set -e
			
		fi
		
		
		if [ `uname -m` = "x86_64" ]; then
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Downloading Neko $NEKO_VERSION (64-bit)"
			echo "---------------------------------------"	
		
			wget -c http://nekovm.org/_media/neko-$NEKO_VERSION-linux64.tar.gz
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Installing Neko $NEKO_VERSION"
			echo "---------------------------------------"
			
			# Extract and copy files to /usr/lib/neko
			
			tar xvzf neko-$NEKO_VERSION-linux64.tar.gz
			mkdir -p /usr/lib/neko
			rm -rf /usr/lib/neko/neko
			rm -rf /usr/lib/neko/nekotools
			cp -r neko-$NEKO_VERSION-linux/* /usr/lib/neko
			
			# Add symlinks
			
			rm -rf /usr/bin/neko
			rm -rf /usr/bin/nekoc
			rm -rf /usr/bin/nekotools
			rm -rf /usr/lib/libneko.so
			
			ln -s /usr/lib/neko/libneko.so /usr/lib/libneko.so
			ln -s /usr/lib/neko/neko /usr/bin/neko
			ln -s /usr/lib/neko/nekoc /usr/bin/nekoc
			ln -s /usr/lib/neko/nekotools /usr/bin/nekotools
			
			if [ -d "/usr/lib64" ]; then
				
				set +e
				rm -rf /usr/lib64/libneko.so
				ln -s /usr/lib/neko/libneko.so /usr/lib64/libneko.so
				set -e
				
			fi
			
			# Cleanup
			
			rm -rf neko-$NEKO_VERSION-linux
			rm neko-$NEKO_VERSION-linux64.tar.gz
			
			
		else
			
			
			echo ""
			echo "--------------------------------------"
			echo "    Downloading Neko $NEKO_VERSION (32-bit)"
			echo "---------------------------------------"	
			
			wget -c http://nekovm.org/_media/neko-$NEKO_VERSION-linux.tar.gz
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Installing Neko $NEKO_VERSION"
			echo "---------------------------------------"
			
			
			# Extract and copy files to /usr/lib/neko
			
			tar xvzf neko-$NEKO_VERSION-linux.tar.gz
			mkdir -p /usr/lib/neko
			rm -rf /usr/lib/neko/neko
			rm -rf /usr/lib/neko/nekotools
			cp -r neko-$NEKO_VERSION-linux/* /usr/lib/neko
			
			# Add symlinks
			
			rm -rf /usr/bin/neko
			rm -rf /usr/bin/nekoc
			rm -rf /usr/bin/nekotools
			rm -rf /usr/lib/libneko.so
			
			ln -s /usr/lib/neko/neko /usr/bin/neko
			ln -s /usr/lib/neko/nekoc /usr/bin/nekoc
			ln -s /usr/lib/neko/nekotools /usr/bin/nekotools
			ln -s /usr/lib/neko/libneko.so /usr/lib/libneko.so
			
			
			# Cleanup
			
			rm -rf neko-$NEKO_VERSION-linux
			rm neko-$NEKO_VERSION-linux.tar.gz
			
			
		fi
		
		
		# Install libgc, which is required for Neko
		
		if [ -n "$(command -v yum)" ]; then
			
			yum -y install libgc
			
		elif [ -n "$(command -v pacman)" ]; then
			
			pacman -S gc --noconfirm
			
		elif [ -n "$(command -v zypper)" ]; then
			
			zypper --non-interactive install libgc1
			
		else
			
			apt-get -y install libgc-dev
			
		fi
		
		if [ -d "/usr/lib64" ] && [ ! -f "/usr/lib64/libpcre.so.3" ]; then
			
			set +e
			ln -s /usr/lib64/libpcre.so.1 /usr/lib64/libpcre.so.3
			set -e
			
		fi
		
		
		if [ `uname -m` = "x86_64" ]; then
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Downloading Haxe $HAXE_VERSION (64-bit)"
			echo "---------------------------------------"	
			
			wget http://haxe.org/website-content/downloads/$HAXE_VERSION/downloads/haxe-$HAXE_VERSION-linux64.tar.gz
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Installing Haxe $HAXE_VERSION"
			echo "---------------------------------------"
			
			
			# Extract and copy files to /usr/lib/haxe
			
			mkdir -p /usr/lib/haxe
			rm -rf /usr/lib/haxe/haxe
			tar xvzf haxe-$HAXE_VERSION-linux64.tar.gz -C /usr/lib/haxe --strip-components=1
			
			
			# Add symlinks
			
			rm -rf /usr/bin/haxe
			rm -rf /usr/bin/haxelib
			rm -rf /usr/bin/haxedoc
			
			ln -s /usr/lib/haxe/haxe /usr/bin/haxe
			ln -s /usr/lib/haxe/haxelib /usr/bin/haxelib
			
			
			# Set up haxelib
			
			mkdir -p /usr/lib/haxe/lib
			chmod -R 777 /usr/lib/haxe/lib
			haxelib setup /usr/lib/haxe/lib
			
			
			# Cleanup
			
			rm haxe-$HAXE_VERSION-linux64.tar.gz
			
			# Lime setup
			
			haxelib install lime
			haxelib run lime setup
			
			# Flixel
			
			haxelib install flixel
			haxelib install flixel-ui
			haxelib install flixel-addons
			haxelib install flixel-demos
			haxelib install flixel-templates
			haxelib install flixel-tools
			
			# openfl
			
			haxelib install openfl
			haxelib run openfl setup
			haxelib install layout
			haxelib install swf
			
			# other
			haxelib install nodejs
			haxelib install jquery
			haxelib install yawf
			haxelib install Mage
			haxelib install actuate
			haxelib install nape
			haxelib install polygonal-ds
			haxelib install firetongue
			haxelib install pixijs
			haxelib install howlerjs
			haxelib install ufront
			haxelib install ufront-mvc
			
			
		else
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Downloading Haxe $HAXE_VERSION (32-bit)"
			echo "---------------------------------------"	
			
			wget http://haxe.org/website-content/downloads/$HAXE_VERSION/downloads/haxe-$HAXE_VERSION-linux32.tar.gz
			
			
			echo ""
			echo "---------------------------------------"
			echo "    Installing Haxe $HAXE_VERSION"
			echo "---------------------------------------"
			
			
			# Extract and copy files to /usr/lib/haxe
			
			mkdir -p /usr/lib/haxe
			rm -rf /usr/lib/haxe/haxe
			tar xvzf haxe-$HAXE_VERSION-linux32.tar.gz -C /usr/lib/haxe --strip-components=1
			
			
			# Add symlinks
			
			rm -rf /usr/bin/haxe
			rm -rf /usr/bin/haxelib
			rm -rf /usr/bin/haxedoc
			
			ln -s /usr/lib/haxe/haxe /usr/bin/haxe
			ln -s /usr/lib/haxe/haxelib /usr/bin/haxelib
			
			
			# Set up haxelib
			
			mkdir -p /usr/lib/haxe/lib
			chmod -R 777 /usr/lib/haxe/lib
			haxelib setup /usr/lib/haxe/lib
			
			
			# Cleanup
			
			rm haxe-$HAXE_VERSION-linux32.tar.gz
			
			# Lime setup
			
			haxelib install lime
			haxelib run lime setup
			
			# Flixel
			
			haxelib install flixel
			haxelib install flixel-ui
			haxelib install flixel-addons
			haxelib install flixel-demos
			haxelib install flixel-templates
			haxelib install flixel-tools
			
			# openfl
			
			haxelib install openfl
			haxelib run openfl setup
			haxelib install layout
			haxelib install swf
			
			# other
			haxelib install nodejs
			haxelib install jquery
			haxelib install yawf
			haxelib install Mage
			haxelib install actuate
			haxelib install nape
			haxelib install polygonal-ds
			haxelib install firetongue
			haxelib install pixijs
			haxelib install howlerjs
			haxelib install ufront
			haxelib install ufront-mvc
			
		fi
		
		
	fi


	echo ""


	else
		echo "There was no found version that matches $HAXE_VERSION"
		echo "Please go to http://haxe.org to find the latest Haxe version. Enter its number at the prompt."

	fi
fi

Take me home.

Check out the archive.