diff --git a/scripts/installer.sh b/scripts/installer.sh index 3894d8a..725c71b 100755 --- a/scripts/installer.sh +++ b/scripts/installer.sh @@ -27,6 +27,7 @@ # G_TITLE="JoeyLib Installer" G_PARENT= +G_HAS_IIGS=0 function buildPCDeps() { @@ -156,6 +157,7 @@ function buildPCDeps() { ar rcs ${DIST}/libjoeylib.a *.o cp -f ${SRC}/joey.h ${DIST}/../.. cp -f ${SRC}/../joey.pri ${DIST}/../.. + cp -f ${SRC}/../../scripts/build-PC.helper.sh ${DIST}/../.. popd >& /dev/null popd >& /dev/null @@ -170,6 +172,223 @@ function clearPCDepsBuild() { } +function configRead() { + if [[ -e "${G_PARENT}/joeyDev.sh" ]]; then + source "${G_PARENT}/joeyDev.sh" + fi +} + + +function configWrite() { + local O=${G_PARENT}/joeyDev.sh + echo "#!/bin/bash" > "${O}" + echo "if [[ -z \$JOEYPATH || \"\${JOEYPATH}\" == \"\" ]]; then" >> "${O}" + echo -e "\texport JOEYPATH=\"\${PATH}\"" >> "${O}" + echo "fi" >> "${O}" + echo "export PATH=\"\${JOEYPATH}\"" >> "${O}" + echo "export JOEY=\"${G_PARENT}\"" >> "${O}" + if [[ ${G_HAS_IIGS} == 1 ]]; then + # IIgs Runtime & ORCA Compilers + echo "export GOLDEN_GATE=\"\${JOEY}/sdks/IIgs/ORCA\"" >> "${O}" + echo "export PATH=\"\${JOEY}/sdks/IIgs:\${PATH}\"" >> "${O}" + fi + chmod +x "${O}" +} + + +function fetchGitHubRelease() { + local __RESULT=$1 + local DEVELOPER=$2 + local COMPONENT=$3 + local EXTENSION=$4 + local URL=`curl -s https://api.github.com/repos/${DEVELOPER}/${COMPONENT}/releases \ + | grep "browser_download_url.*${EXTENSION}" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | head -n 1` + local FILE=${URL##*/} + if [[ -e "${FILE}" ]]; then + rm "${FILE}" + fi + wget ${URL} + eval $__RESULT=\${FILE} +} + + +function installIIgs() { + local RESULT= + local PREFIX= + local O= + local ORCA= + local IIGS="${G_PARENT}/sdks/IIgs" + + mkdir -p "${IIGS}/ORCA" + + if [[ ! -e "${IIGS}/hfsDrive.img" ]]; then + echo "" + tBoldBox tPURPLE "Creating HFS Volume" + echo "" + O=${IIGS}/mountORCA.sh + echo "#!/bin/bash" > "${O}" + echo "IIGS=${IIGS}" >> "${O}" + echo "if ! mount | grep \${IIGS}/ORCA | grep -q hfsplus; then" >> "${O}" + echo -e "\tfsck.hfsplus \${IIGS}/hfsDrive.img" >> "${O}" + echo -e "\tIIGSDISK=\$(sudo losetup --partscan --find --show \${IIGS}/hfsDrive.img)" >> "${O}" + echo -e "\tsudo mount \${IIGSDISK} \${IIGS}/ORCA" >> "${O}" + echo -e "\techo LOOP=\${IIGSDISK} > \${IIGS}/lastMount.cfg" >> "${O}" + echo -e "\techo MOUNT=\${IIGS}/ORCA >> \${IIGS}/lastMount.cfg" >> "${O}" + echo "fi" >> "${O}" + chmod +x "${O}" + O=${IIGS}/unmountORCA.sh + echo "#!/bin/bash" > "${O}" + echo "IIGS=${IIGS}" >> "${O}" + echo "if [[ -e \${IIGS}/lastMount.cfg ]]; then" >> "${O}" + echo -e "\tsource \${IIGS}/lastMount.cfg" >> "${O}" + echo -e "\tsudo umount \${MOUNT}" >> "${O}" + echo -e "\tsudo losetup -d \${LOOP}" >> "${O}" + echo -e "\tsudo rm \${IIGS}/lastMount.cfg" >> "${O}" + echo "fi" >> "${O}" + chmod +x "${O}" + fallocate -l 32M "${IIGS}/hfsDrive.img" + mkfs.hfs -v IIgs "${IIGS}/hfsDrive.img" + fi + + "${IIGS}/mountORCA.sh" + + if [[ ! -e "${IIGS}/ORCA/Languages/cc" ]]; then + tFileBrowser ORCA "Please locate your 'OPUS ][ The Software' ISO" .iso .. + if [[ -z ${ORCA} || "${ORCA}" == "" ]]; then + return 0 + fi + fi + + echo "" + tBoldBox tCYAN "NOTE: If an error is encountered, installer will exit!" + + if [[ ! -d GoldenGate ]]; then + echo "" + tBoldBox tPURPLE "Building GoldenGate" + echo "" + git clone git@gitlab.com:GoldenGate/GoldenGate.git + if [ ! -d GoldenGate ]; then + tBoldBox tRED "Unable to clone the GoldenGate repository!" + echo "Must be a paying member of the GoldenGate project!" + echo "See: https://goldengate.gitlab.io/about/" + exit 1 + fi + pushd GoldenGate >& /dev/null + git submodule init + git submodule update + PREFIX=`pwd`/installed + mkdir -p build + cd build + cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} .. | tee make.out + make | tee -a make.out + if [[ ! -e bin/iix ]]; then + tBoldBox tRED "Failed to build GoldenGate." + exit 1 + fi + cp -f bin/{iix,dumpobj,opus-extractor} "${IIGS}/." + popd >& /dev/null + fi + + if [[ ! -e "${IIGS}/ORCA/Languages/cc" ]]; then + echo "" + tBoldBox tPURPLE "Installing ORCA/C" + echo "" + chown -R `id -ru`:`id -rg` "${IIGS}/ORCA" + isoinfo -i "${ORCA}" -x /FOR_EMUL/BYTEWORK.S\;1 > BYTEWORKS + "${IIGS}/opus-extractor" -v BYTEWORKS "${IIGS}/ORCA" + + echo "" + tBoldBox tPURPLE "Upgrading ORCA/C" + echo "" + fetchGitHubRelease RESULT byteworksinc ORCA-C 2mg + "${IIGS}/opus-extractor" -v -s / ${RESULT} orcaUpdate + cp -rf orcaUpdate/* "${IIGS}/ORCA/." + fi + + if [[ ! -d gsplus ]]; then + echo "" + tBoldBox tPURPLE "Building GSplus" + echo "" + git clone https://github.com/digarok/gsplus.git + mkdir gsplus/build + pushd gsplus/build >& /dev/null + cmake .. + make + if [[ ! -e bin/GSplus ]]; then + tBoldBox tRED "Failed to build GSplus." + exit 1 + fi + mkdir -p "${IIGS}/gsplus" + cp -f bin/{GSplus,partls,to_pro} "${IIGS}/gsplus/." + popd >& /dev/null + wget http://www.whatisthe2gs.apple2.org.za/files/rom3.zip + unzip rom3.zip + mv -f APPLE2GS.ROM2 "${IIGS}/gsplus/ROM.03" + wget http://www.whatisthe2gs.apple2.org.za/files/harddrive_image.zip + unzip harddrive_image.zip + mv -f "System 6 and Free Games.hdv" "${IIGS}/gsplus/System601.po" + echo -e "s7d1 = System601.po\n\ng_limit_speed = 0\n" > "${IIGS}/gsplus/config.txt" + echo -e "s7d1 = System601.po\ns7d2 = /tmp/IIgs/import.po\n" > "${IIGS}/gsplus/IIgsTest.cfg" + fi + + if [[ ! -d cadius ]]; then + echo "" + tBoldBox tPURPLE "Building Cadius" + echo "" + git clone https://github.com/mach-kernel/cadius.git + pushd cadius >& /dev/null + make + if [[ ! -e bin/release/cadius ]]; then + tBoldBox tRED "Failed to build Cadius." + exit 1 + fi + mkdir -p "${IIGS}/cadius" + cp -f bin/release/cadius "${IIGS}/cadius/." + popd >& /dev/null + fi + + if [[ ! -e ntconverter.zip ]]; then + echo "" + tBoldBox tPURPLE "Installing NinjaTracker Converter" + echo "" + wget https://www.ninjaforce.com/downloads/ntconverter.zip + unzip ntconverter.zip + mkdir -p "${IIGS}/ntconverter" + cp -f ntconverter.php "${IIGS}/ntconverter/." + fi + + echo "" + tBoldBox tPURPLE "Building JoeyLib" + echo "" + set -x + O=${IIGS}/ORCA/out/joey + if [[ -d "${O}" ]]; then + rm -rf "${O}" + fi + mkdir -p "${O}" + G_HAS_IIGS=1 + configWrite + configRead + pushd ${JOEY}/joeylib/joeylib/src >& /dev/null + iix assemble +L jIIgs.asm keep=31:/out/joey/jIIgsasm > jIIgs.asm.dis + iix compile jIIgs.c keep=31:/out/joey/jIIgsc + iix compile joey.c keep=31:/out/joey/joey + iix makelib 31:/out/joey/joeylib +31:/out/joey/jIIgsasm.A + iix makelib 31:/out/joey/joeylib +31:/out/joey/jIIgsasm.ROOT + iix makelib 31:/out/joey/joeylib +31:/out/joey/jIIgsc.a + iix makelib 31:/out/joey/joeylib +31:/out/joey/joey.a + popd >& /dev/null + mkdir -p ${JOEY}/dist/IIgs + cp -f ${JOEY}/joeylib/joeylib/lib/IIgs/Tool221#ba0000 ${JOEY}/dist/IIgs/. + cp -f ${O}/joeylib ${JOEY}/dist/IIgs/joeylib#b20000 + cp -f ${JOEY}/joeylib/joeylib/src/joey.h ${JOEY}/dist/. + cp -f ${JOEY}/joeylib/scripts/build-IIgs.helper.sh ${JOEY}/dist/. +} + + function installLinux32() { buildPCDeps \ "$(pwd)/../dist/linux/i386" \ @@ -212,14 +431,16 @@ function installWin64() { function mainMenu() { local ITEMS=( -# "IIgs" "Amiga" "ST" + "IIgs" +# "Amiga" "ST" "Linux32" "Linux64" "Win32" "Win64" # "macOS32" "macOS64" # "Android" "iOS" ) local DESC=( -# "Apple IIgs 16" "Commodore Amiga 16" "Atari ST 16" + "Apple IIgs 16" +# "Commodore Amiga 16" "Atari ST 16" "Linux 32" "Linux 64" "Windows 32" "Windows 64" # "macOS 32" "macOS 64" @@ -283,7 +504,7 @@ pushd installerWork >& /dev/null echo "" tBoldBox tBLUE "Examining system..." tCheckPackages MISSING cmake ragel hfsplus hfsutils hfsprogs libreadline-dev libedit-dev \ - build-essential git mercurial texinfo libtool autoconf automake \ + build-essential git mercurial texinfo libtool autoconf automake re2c \ gcc-multilib g++-multilib mingw-w64 gdb-mingw-w64 clang llvm-dev libxml2-dev \ uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio \ libpulse-dev{,:i386} libasound-dev{,:i386} \ @@ -322,10 +543,11 @@ if [[ ! -f ${G_PARENT}/joeylib/LICENSE ]]; then fi mainMenu +configWrite clear tBoldBox tBLUE "Goodbye!" echo "" # --- EXIT -popd >& /dev/null +popd >& /dev/null