#!/bin/sh # -------------------------------------------------------------- # RetroForth/ilo - Wrapper Script # -------------------------------------------------------------- # # This serves several roles: # # - obtaining a working VM, rom, and block store # - updating an installed system # - launching RetroForth/ilo # # Supported Systems # # +------------+---------------------------------------------+ # | CPU Family | Host | # +============+=============================================+ # | amd64 | FreeBSD, NetBSD, OpenBSD, Linux | # | x86 | FreeBSD, Linux | # | aarch64 | Linux | # +------------+---------------------------------------------+ # # Dependencies: # # - Supported host # - Standard shell (ksh, bash, etc) # - curl # - gunzip # # Optional: # # - C compiler (`cc`) # - Nim compiler (`nim`) # - stty # - readline # - rlwrap # # Quick Start: # # # install # doas cp retro-ilo.sh /usr/local/bin/retro-ilo # retro-ilo install # # # run # retro-ilo # # # update # retro-ilo update # -------------------------------------------------------------- # -------------------------------------------------------------- # Installation (Common) # -------------------------------------------------------------- if [ "$1" = "install:common" ]; then if [ -x "$(which curl)" ] ; then true else exit fi echo " -> create ~/.retro-ilo" mkdir -p ~/.retro-ilo/ cd ~/.retro-ilo || exit rm -f ilo.rom ilo.blocks echo " -> download & decompress ilo.rom.gz" curl --silent http://ilo.retroforth.org/ilo.rom.gz -o ilo.rom.gz gunzip ilo.rom.gz echo " -> download & decompress ilo.blocks.gz" curl --silent http://ilo.retroforth.org/ilo.blocks.gz -o ilo.blocks.gz gunzip ilo.blocks.gz echo " -> download tab completion data (for use with rlwrap)" curl --silent http://ilo.retroforth.org/retroforth.words.txt -o retroforth.words.txt exit fi # -------------------------------------------------------------- # Installation (Binary) # -------------------------------------------------------------- if [ "$1" = "install" ]; then echo "** RetroForth/ilo Installation (using precompiled ilo)" echo " -> check for curl..." if [ -x "$(which curl)" ] ; then true else echo " FAILED. Please install curl" exit fi sh "$0" install:common cd ~/.retro-ilo || exit # Detect host system to decide what VM to get echo " -> determine host" H=$(uname | tr '[:upper:]' '[:lower:]') M=$(uname -m) V="ilo-$M-$H" echo " -> download ilo for $M-$H" curl --silent http://ilo.retroforth.org/binaries/"$V" -o ilo chmod +x ilo echo "** Installation complete. Run 'retro-ilo.sh' to start." exit fi # -------------------------------------------------------------- # Installation (from source) # -------------------------------------------------------------- if [ "$1" = "install:c" ]; then echo "** RetroForth/ilo Installation (ilo.c)" echo " -> check for curl..." if [ -x "$(which curl)" ] ; then true else echo " FAILED. Please install curl" exit fi sh "$0" install:common cd ~/.retro-ilo || exit echo " -> download ilo.c" curl --silent http://ilo.retroforth.org/ilo.c -o ilo.c echo " -> compile ilo" cc -O3 -s ilo.c -o ilo echo "** Installation complete. Run 'retro-ilo.sh' to start." exit fi if [ "$1" = "install:nim" ]; then echo "** RetroForth/ilo Installation (ilo.nim)" echo " -> check for curl..." if [ -x "$(which curl)" ] ; then true else echo " FAILED. Please install curl" exit fi sh "$0" install:common cd ~/.retro-ilo || exit echo " -> download ilo.nim" curl --silent http://ilo.retroforth.org/ilo.nim -o ilo.nim echo " -> compile ilo" nim c -d:release ilo.nim echo "** Installation complete. Run 'retro-ilo.sh' to start." exit fi # -------------------------------------------------------------- # Updating # -------------------------------------------------------------- if [ "$1" = "update" ]; then echo "** RetroForth/ilo Update" if [ -e ~/.retro-ilo ]; then echo "** switch to ~/.retro-ilo" cd ~/.retro-ilo || exit echo " -> check for curl..." if [ -x "$(which curl)" ] ; then true else echo " FAILED. Please install curl" exit fi echo " -> download & decompress latest ilo.rom.gz" rm -f ilo.rom curl --silent http://ilo.retroforth.org/ilo.rom.gz -o ilo.rom.gz gunzip ilo.rom.gz echo " -> download & decompress latest system.blocks.gz" curl --silent http://ilo.retroforth.org/system.blocks.gz -o system.blocks.gz gunzip system.blocks.gz echo " -> merge system.blocks into ilo.blocks" dd if=system.blocks of=ilo.blocks bs=4k count=128 conv=notrunc echo " -> download latest tab completion data (for use with rlwrap)" rm -f retroforth.words.txt curl --silent http://ilo.retroforth.org/retroforth.words.txt -o retroforth.words.txt echo " -> cleanup" rm system.blocks else echo "** ERROR: RetroForth/ilo not found in ~/.retro-ilo" echo "**" echo "** Try running 'retro-ilo.sh install'" fi exit fi # -------------------------------------------------------------- # Remove # -------------------------------------------------------------- if [ "$1" = "uninstall" ]; then cd ~ || exit rm -rfi .retro-ilo exit fi if [ "$1" = "help" ]; then echo "$0 help" echo " Display this help text" echo echo "$0 install" echo " Install RetroForth/ilo into ~/.retro-ilo" echo " Requires curl and gunzip to be installed." echo echo " Options:" echo echo " install:c" echo " As with 'install', but build ilo using the local C" echo " compiler (needs to be runnable as 'cc')" echo echo " install:nim" echo " As with 'install', but build ilo using the local nim" echo " compiler (needs to be runnable as 'nim')" echo echo "$0 uninstall" echo " Uninstall RetroForth/ilo by deleting ~/.retro-ilo" echo echo "$0 update" echo " Update the RetroForth image & system blocks" echo echo "$0" echo " Start RetroForth/ilo" echo echo " Options:" echo echo " --cbreak" echo " Run in character breaking mode. This will process" echo " input as you press space." echo echo " --rlwrap" echo " Run RetroForth/ilo under rlwrap. This will provide" echo " line editing, history, and tab completion." echo " Requires readline and rlwrap to be installed." exit fi # -------------------------------------------------------------- # Launching RetroForth/ilo # -------------------------------------------------------------- if [ "$1" = "--cbreak" ]; then stty cbreak fi if [ -e ~/.retro-ilo ]; then cd ~/.retro-ilo || exit if [ "$1" = "--rlwrap" ]; then rlwrap -b " \n" -f retroforth.words.txt ./ilo else ./ilo fi else echo "** ERROR: RetroForth/ilo not found in ~/.retro-ilo" echo "**" echo "** Try running '$0 install' or '$0 help'" fi if [ "$1" = "--cbreak" ]; then stty -cbreak fi