From 0315c830123a9fffaa35b07315ec26d5019b216a Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Fri, 12 Jul 2019 21:48:19 -0500 Subject: [PATCH] IIgs installer works! No longer requires being run as root. --- joeylib/build-IIgs.sh | 4 +- scripts/installer.sh | 136 ++++++++++++++++++++++++++++++++---------- 2 files changed, 108 insertions(+), 32 deletions(-) diff --git a/joeylib/build-IIgs.sh b/joeylib/build-IIgs.sh index 160e524..2f6724b 100755 --- a/joeylib/build-IIgs.sh +++ b/joeylib/build-IIgs.sh @@ -8,7 +8,7 @@ fi mkdir -p ${OUT} pushd ${JOEY}/joeylib/joeylib/src -iix assemble +L jIIgs.asm keep=31:/out/joey/jIIgsasm > jIIgs.asm.map +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 @@ -37,7 +37,7 @@ if [ ! -z $1 ]; then VOL=Import mkdir -p `dirname ${IMPORT}` - rm ${OUT}/JLSTATS 2> /dev/null || true + rm /tmp/IIgs/JLSTATS#040000 2> /dev/null || true rm ${IMPORT} 2> /dev/null || true cp ${OUT}/test ${OUT}/Test#B30000 diff --git a/scripts/installer.sh b/scripts/installer.sh index 725c71b..b380833 100755 --- a/scripts/installer.sh +++ b/scripts/installer.sh @@ -27,6 +27,8 @@ # G_TITLE="JoeyLib Installer" G_PARENT= +G_UID=$(id -ru) +G_GID=$(id -rg) G_HAS_IIGS=0 @@ -201,11 +203,11 @@ function fetchGitHubRelease() { local DEVELOPER=$2 local COMPONENT=$3 local EXTENSION=$4 - local URL=`curl -s https://api.github.com/repos/${DEVELOPER}/${COMPONENT}/releases \ + 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` + | head -n 1) local FILE=${URL##*/} if [[ -e "${FILE}" ]]; then rm "${FILE}" @@ -217,12 +219,20 @@ function fetchGitHubRelease() { function installIIgs() { local RESULT= - local PREFIX= local O= local ORCA= + local GGATE= local IIGS="${G_PARENT}/sdks/IIgs" + G_HAS_IIGS=1 + configWrite + configRead + + if [[ -e "${IIGS}/unmountORCA.sh" ]]; then + "${IIGS}/unmountORCA.sh" + fi mkdir -p "${IIGS}/ORCA" + chmod 777 "${IIGS}/ORCA" if [[ ! -e "${IIGS}/hfsDrive.img" ]]; then echo "" @@ -254,6 +264,7 @@ function installIIgs() { fi "${IIGS}/mountORCA.sh" + sudo chown ${G_UID}:${G_GID} "${IIGS}/ORCA/." if [[ ! -e "${IIGS}/ORCA/Languages/cc" ]]; then tFileBrowser ORCA "Please locate your 'OPUS ][ The Software' ISO" .iso .. @@ -266,6 +277,10 @@ function installIIgs() { tBoldBox tCYAN "NOTE: If an error is encountered, installer will exit!" if [[ ! -d GoldenGate ]]; then + tFileBrowser GGATE "Please locate your 'Golden Gate' MSI" .msi .. + if [[ -z ${GGATE} || "${GGATE}" == "" ]]; then + return 0 + fi echo "" tBoldBox tPURPLE "Building GoldenGate" echo "" @@ -279,16 +294,20 @@ function installIIgs() { 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 + cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/installed .. + make + make install if [[ ! -e bin/iix ]]; then tBoldBox tRED "Failed to build GoldenGate." exit 1 fi cp -f bin/{iix,dumpobj,opus-extractor} "${IIGS}/." + cd installed + msiextract "${GGATE}" + find -name ".*" -delete + cp -rf GoldenGate/* "${IIGS}/ORCA/." popd >& /dev/null fi @@ -296,7 +315,6 @@ function installIIgs() { 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" @@ -304,8 +322,34 @@ function installIIgs() { tBoldBox tPURPLE "Upgrading ORCA/C" echo "" fetchGitHubRelease RESULT byteworksinc ORCA-C 2mg - "${IIGS}/opus-extractor" -v -s / ${RESULT} orcaUpdate - cp -rf orcaUpdate/* "${IIGS}/ORCA/." + "${IIGS}/opus-extractor" -v -s / ${RESULT} "${IIGS}/ORCA" + + pushd ${GOLDEN_GATE} >& /dev/null + #find . -type d -exec chmod 755 {} \; + #find . -type f -exec chmod 644 {} \; + for O in etc/* ; do iix chtyp -t txt "${O}" ; done + for O in lib/* ; do if [ -f "${O}" ] ; then iix chtyp -t lib "${O}" ; fi ; done + for O in usr/lib/lib* ; do iix chtyp -t lib "${O}" ; done + for O in usr/lib/tmac/* ; do iix chtyp -t txt "${O}" ; done + for O in bin/* ; do iix chtyp -t exe "${O}" ; done + for O in usr/bin/* ; do iix chtyp -t exe "${O}" ; done + for O in usr/local/bin/* ; do iix chtyp -t exe "${O}" ; done + for O in Languages/* ; do if [ -f "${O}" ] ; then iix chtyp -t exe "${O}" ; fi ; done ; + for O in Utilities/Help/* ; do if [ -f "${O}" ] ; then iix chtyp -t txt "${O}" ; fi ; done ; + for O in Utilities/* ; do if [ -f "${O}" ] ; then iix chtyp -t exe "${O}" ; fi ; done ; + for O in Libraries/* ; do if [ -f "${O}" ] ; then iix chtyp -t lib "${O}" ; fi ; done ; + for O in Libraries/AInclude/* ; do if [ -f "${O}" ] ; then iix chtyp -t txt "${O}" ; fi ; done ; + for O in Libraries/APWCInclude/* ; do if [ -f "${O}" ] ; then iix chtyp -t txt "${O}" ; fi ; done ; + for O in Libraries/AppleUtil/* ; do if [ -f "${O}" ] ; then iix chtyp -t txt "${O}" ; fi ; done ; + for O in Libraries/ORCACDefs/* ; do if [ -f "${O}" ] ; then iix chtyp -l cc "${O}" ; fi ; done ; + for O in Libraries/ORCAInclude/* ; do if [ -f "${O}" ] ; then iix chtyp -l asm "${O}" ; fi ; done ; + for O in Libraries/RInclude/* ; do if [ -f "${O}" ] ; then iix chtyp -l rez "${O}" ; fi ; done ; + for O in Libraries/Tool.Interface/* ; do if [ -f "${O}" ] ; then iix chtyp -l pascal "${O}" ; fi ; done ; + for O in Libraries/GSoftDefs/* ; do if [ -f "${O}" ] ; then iix chtyp -t 0x5e -a 0x8007 "${O}" ; fi ; done ; + for O in Libraries/ORCAPascalDefs/* ; do if [ -f "${O}" ] ; then iix chtyp -t 0x5e -a 0x8009 "${O}" ; fi ; done ; + for O in Libraries/m2defs/* ; do if [ -f "${O}" ] ; then iix chtyp -t 0x5e -a 0x8006 "${O}" ; fi ; done ; + + popd >& /dev/null fi if [[ ! -d gsplus ]]; then @@ -324,14 +368,32 @@ function installIIgs() { mkdir -p "${IIGS}/gsplus" cp -f bin/{GSplus,partls,to_pro} "${IIGS}/gsplus/." popd >& /dev/null + 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 [[ ! -f "${IIGS}/gsplus/ROM.03" ]]; then + echo "" + tBoldBox tPURPLE "Installing IIgs ROM" + echo "" + if [[ -e rom3.zip ]]; then + rm -f rom3.zip + fi wget http://www.whatisthe2gs.apple2.org.za/files/rom3.zip unzip rom3.zip mv -f APPLE2GS.ROM2 "${IIGS}/gsplus/ROM.03" + fi + + if [[ ! -f "${IIGS}/gsplus/System601.po" ]]; then + echo "" + tBoldBox tPURPLE "Installing GS/OS" + echo "" + if [[ -e harddrive_image.zip ]]; then + rm -f harddrive_image.zip + fi 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 @@ -350,29 +412,42 @@ function installIIgs() { popd >& /dev/null fi - if [[ ! -e ntconverter.zip ]]; then + if [[ ! -e "${IIGS}/ntconverter/ntconverter.php" ]]; then echo "" tBoldBox tPURPLE "Installing NinjaTracker Converter" echo "" + if [[ -e ntconverter.zip ]]; then + rm -f ntconverter.zip + fi wget https://www.ninjaforce.com/downloads/ntconverter.zip unzip ntconverter.zip mkdir -p "${IIGS}/ntconverter" cp -f ntconverter.php "${IIGS}/ntconverter/." fi + mkdir -p "${JOEY}/dist/IIgs" + + if [[ ! -e "${JOEY}/dist/IIgs/Tool221#ba0000" ]]; then + echo "" + tBoldBox tPURPLE "Installing Tool221" + echo "" + if [[ -e ninjatracker_tool221_v2.1.2mg ]]; then + rm -f ninjatracker_tool221_v2.1.2mg + fi + wget https://www.brutaldeluxe.fr/products/apple2gs/tool221/ninjatracker_tool221_v2.1.2mg + "${IIGS}/cadius/cadius" extractfile ninjatracker_tool221_v2.1.2mg NT.TOOL221.V2.1/SYSTEM/TOOLS/TOOL221 . + cp -f TOOL221#BA0000 "${JOEY}/dist/IIgs/Tool221#ba0000" + 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 + 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 @@ -381,11 +456,15 @@ function installIIgs() { 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/. + 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/." + + "${IIGS}/unmountORCA.sh" + + if [[ ! -e "${IIGS}/hfsDrive.img.backup.tar.bz2" ]]; then + tar cjf "${IIGS}/hfsDrive.img.backup.tar.bz2" "${IIGS}/hfsDrive.img" + fi } @@ -463,6 +542,7 @@ function mainMenu() { set e- ) if [[ "${CHOICE}" != "" ]]; then + sudo -v CHOICE="install${CHOICE}" ${CHOICE} fi @@ -472,11 +552,6 @@ function mainMenu() { # --- START -if [[ $EUID -ne 0 ]]; then - echo "The installer must be run as root." - exit 1 -fi - mkdir -p installerWork # Do we have Towel yet? @@ -484,7 +559,7 @@ if [[ ! -f installerWork/towel/towel.sh ]]; then # Do we have GIT? if [[ "$(which git || true)" == "" ]]; then echo "Installing git..." - apt-get -y install git >& /dev/null + sudo apt-get -y install git >& /dev/null fi echo "Downloading towel.sh support library..." git clone https://skunkworks.kangaroopunch.com/skunkworks/towel.git installerWork/towel >& /dev/null @@ -509,9 +584,10 @@ tCheckPackages MISSING cmake ragel hfsplus hfsutils hfsprogs libreadline-dev lib uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio \ libpulse-dev{,:i386} libasound-dev{,:i386} \ libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev libpcap0.8-dev \ - php-cli + php-cli msitools if [[ "${MISSING}" != "" ]]; then + sudo -v if (whiptail --title "${G_TITLE}" --yesno "Some required packages are missing.\n\nInstall them now?" 9 40); then TEMP=" ${MISSING//[^ ]}" TOTAL=${#TEMP} @@ -520,7 +596,7 @@ if [[ "${MISSING}" != "" ]]; then for PACKAGE in ${MISSING}; do PERCENT=$(( 100*(++COUNT)/TOTAL )) echo ${PERCENT} - apt-get -y install ${PACAKGE} >& /dev/null + sudo apt-get -y install ${PACAKGE} >& /dev/null done } | whiptail --title "${G_TITLE}" --gauge "\nInstalling packages..." 7 50 0 else