joeylib/scripts/installer.sh

1331 lines
32 KiB
Bash
Executable file

#!/bin/bash -e
#
# JoeyLib
# Copyright (C) 2018-2021 Scott Duensing <scott@kangaroopunch.com>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
#
# Global variables
#
G_TITLE="JoeyLib Installer"
G_WORK=installerWork
G_PARENT=
G_SCRIPT=
G_UID=$(id -ru)
G_GID=$(id -rg)
G_IS_INSTALLED=()
G_ITEMS=()
G_DESC=()
G_CHECK=()
G_AUTOMATED=
G_PASSWORD=
G_ORCA_FILE=
G_GOLDEN_GATE_FILE=
G_GOLDEN_GATE_USER=
G_GOLDEN_GATE_PASS=
G_GOLDEN_GATE_PUBLIC=
G_GOLDEN_GATE_PRIVATE=
G_MAC_INTEL_MIN=10.6
G_MAC_INTEL_DARWIN=17
G_MAC_INTEL_XIP="$(pwd)/Xcode_9.4.1.xip"
G_MAC_APPLE_MIN=10.9
G_MAC_APPLE_DARWIN=20.4
G_MAC_APPLE_XIP="$(pwd)/Xcode_12.5.1.xip"
G_IIGS=0
#G_AMIGA=1
#G_ATARIST=2
G_LINUX32=1
G_LINUX64=2
G_WIN32=3
G_WIN64=4
G_MACX32=5
G_MACX64=6
G_MACA64=7
#G_ANDROID=9
#G_IOS=10
G_ITEMS=(
"IIgs"
# "Amiga"
# "ST"
"Linux32"
"Linux64"
"Win32"
"Win64"
"macOSX32"
"macOSX64"
"macOSA64"
# "Android"
# "iOS"
)
G_DESC=(
"Apple IIgs 16"
# "Commodore Amiga 16"
# "Atari ST 16"
"Linux 32"
"Linux 64"
"Windows 32"
"Windows 64"
"macOS Intel 32"
"macOS Intel 64"
"macOS Apple 64"
# "Android 32"
# "iOS 64"
)
G_CHECK=(
"IIgs/joey.a#b10000"
# "amiga/libjoeylib.a"
# "st/libjoeylib.a"
"linux/i386/libjoeylib.a"
"linux/x64/libjoeylib.a"
"windows/i386/libjoeylib.a"
"windows/x64/libjoeylib.a"
"macOS/i386/libjoeylib.a"
"macOS/x64/libjoeylib.a"
"macOS/a64/libjoeylib.a"
# "Android"
# "iOS"
)
G_IS_INSTALLED=(
0
# 0
# 0
0
0
0
0
0
0
0
# 0
# 0
)
function buildMacOSXSDK() {
local ARCH=$1
local RESULT=$2
local XCODE=
local XIP=
local OSX="${G_PARENT}/sdks/macOS"
eval $RESULT=0
if [[ "${ARCH}" == "APPLE" ]]; then
OSX="${OSX}/apple"
XIP="${G_MAC_APPLE_XIP}"
else
OSX="${OSX}/intel"
XIP="${G_MAC_INTEL_XIP}"
fi
mkdir -p "${G_PARENT}/sdks"
if [[ -e "${OSX}/SDK" ]]; then
eval $RESULT=1
return 0
fi
if [[ ! -z ${G_AUTOMATED} ]]; then
XCODE=${XIP}
if [[ ! -e "${XCODE}" ]]; then
return 0
fi
else
tFileBrowser XCODE "Please locate ${XIP}" .xip ..
if [[ -z ${XCODE} || "${XCODE}" == "" ]]; then
return 0
fi
fi
purple "Building macOS SDK"
if [[ ! -d osxcross ]]; then
git clone https://github.com/tpoechtrager/osxcross.git
pushd osxcross &> /dev/null
git checkout 26ebac26899650b12b99de86ebbde785de6ca173
popd &> /dev/null
fi
pushd osxcross &> /dev/null
./tools/gen_sdk_package_pbzx.sh "${XCODE}"
mv -f MacOSX* tarballs/.
# SDK_VERSION=
# OSX_VERSION_MIN=${G_MAC_INTEL_MIN}
UNATTENDED=1 ./build.sh
doSudo ENABLE_COMPILER_RT_INSTALL=1 ./build_compiler_rt.sh
mkdir -p "${OSX}"
mv -f target/* "${OSX}"
./cleanup.sh
popd &> /dev/null
# If we don't do this, we use the system ar / ranlib which is bad.
pushd "${OSX}/bin" &> /dev/null
ln -s $(find . -type f -name "*-ar") ar
popd &> /dev/null
eval $RESULT=1
}
function buildPCDepsM1Hack() {
local TARGET=$1
local FOLDER=$2
pushd "${FOLDER}" &> /dev/null
if [[ "${TARGET}" == "macosa64" ]]; then
[[ -f config.guess ]] && mv -f config.guess config.guess.joey
[[ -f config.sub ]] && mv -f config.sub config.sub.joey
mkdir -p build-scripts
pushd build-scripts &> /dev/null
[[ -f config.guess ]] && mv -f config.guess config.guess.joey
[[ -f config.sub ]] && mv -f config.sub config.sub.joey
wget https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
wget https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
popd &> /dev/null
cp -f build-scripts/config.guess .
cp -f build-scripts/config.sub .
else
[[ -f config.guess.joey ]] && mv -f config.guess.joey config.guess
[[ -f config.sub.joey ]] && mv -f config.sub.joey config.sub
mkdir -p build-scripts
pushd build-scripts &> /dev/null
[[ -f config.guess.joey ]] && mv -f config.guess.joey config.guess
[[ -f config.sub.joey ]] && mv -f config.sub.joey config.sub
popd &> /dev/null
fi
popd &> /dev/null
}
function buildPCDeps() {
local TARGET=$1
local FOLDER=$2
local CROSS=$3
local CC_EXPORT=$4
local CXX_EXPORT=$5
local LD_EXPORT=$6
local ADD_PATH=$7
local DIST="$(pwd)/../dist/${FOLDER}"
local PREFIX="$(pwd)/../sdks/${FOLDER}"
local CC_OLD=${CC}
local CXX_OLD=${CXX}
local LD_OLD=${LD_LIBRARY_PATH}
local PATH_OLD=${PATH}
local SRC="${G_PARENT}/joeylib/joeylib/src"
local G_CFLAGS="-Wall -D_REENTRANT_ -I${SRC} -I${PREFIX}/include -c"
mkdir -p ${PREFIX}
mkdir -p deps
pushd deps &> /dev/null
export CC="${CC_EXPORT}"
export CXX="${CXX_EXPORT}"
export LD_LIBRARY_PATH="${LD_EXPORT}"
if [[ ! -z ${ADD_PATH} ]]; then
export PATH="${ADD_PATH}:${PATH}"
fi
# SDL2
purple "Building SDL2 ${TARGET}"
if [[ ! -d SDL ]]; then
git clone https://github.com/libsdl-org/SDL.git
fi
if [[ ! -e "${PREFIX}/lib/libSDL2.a" ]]; then
pushd SDL &> /dev/null
if [[ "${TARGET}" == "macosa64" ]]; then
git checkout 97a5e744497ff7cc93edc5119d67cad3ee86dd57
else
git checkout 25f9ed87ff6947d9576fc9d79dee0784e638ac58
fi
popd &> /dev/null
buildPCDepsM1Hack ${TARGET} SDL
clearDepsBuild
pushd build &> /dev/null
../SDL/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--disable-video-wayland \
--disable-render-metal \
--disable-video-metal \
--prefix=${PREFIX}
make
make install
popd &> /dev/null
fi
# libModPlug
purple "Building libModPlug ${TARGET}"
if [[ ! -d libmodplug ]]; then
git clone https://github.com/Konstanty/libmodplug.git
pushd libmodplug &> /dev/null
git checkout 48be2218a60fdcc4f0d8f474ddeaebd8c429f998
libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
popd &> /dev/null
fi
if [[ ! -e "${PREFIX}/lib/libmodplug.a" ]]; then
buildPCDepsM1Hack ${TARGET} libmodplug
clearDepsBuild
pushd build &> /dev/null
../libmodplug/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--prefix=${PREFIX}
make
make install
popd &> /dev/null
fi
# SDL_mixer
purple "Building SDL_mixer ${TARGET}"
if [[ ! -d SDL_mixer ]]; then
git clone https://github.com/libsdl-org/SDL_mixer.git
fi
if [[ ! -e "${PREFIX}/lib/libSDL2_mixer.a" ]]; then
pushd SDL_mixer &> /dev/null
if [[ "${TARGET}" == "macosa64" ]]; then
git checkout 3dddc9f4e83e722ff8b53fdc2010090f6fd655c2
else
git checkout da75a58c19de9fedea62724a5f7770cbbe39adf9
fi
popd &> /dev/null
buildPCDepsM1Hack ${TARGET} SDL_mixer
clearDepsBuild
pushd build &> /dev/null
MODPLUG_CFLAGS="-I${PREFIX}/include -DMODPLUG_STATIC" \
MODPLUG_LIBS="-L${PREFIX}/lib -lmodplug -lstdc++ -lm" \
../SDL_mixer/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--prefix=${PREFIX} \
--with-sdl-prefix=${PREFIX} \
--disable-sdltest \
--disable-music-cmd \
--disable-music-wave \
--enable-music-mod-modplug \
--disable-music-mod-modplug-shared \
--disable-music-mod-mikmod \
--disable-music-midi \
--disable-music-ogg \
--disable-music-flac \
--disable-music-opus \
--disable-music-mp3 \
--disable-music-mp3-mpg123
make
make install
popd &> /dev/null
fi
export CC="${CC_OLD}"
export CXX="${CXX_OLD}"
export LD_LIBRARY_PATH="${LD_OLD}"
export PATH="${PATH_OLD}"
configWrite
configRead
purple "Building JoeyLib ${TARGET}"
(source "${G_PARENT}/joeyDev.sh" && "${G_PARENT}/joeylib/joeylib/build.sh" ${TARGET}) &> /dev/null
popd &> /dev/null
}
function buildSDL12() {
local CROSS=$1
local PREFIX=$2
mkdir -p deps
pushd deps &> /dev/null
purple "Building SDL"
if [[ ! -d SDL-1.2 ]]; then
# ***TODO*** Change to git repo & checkout specific version.
hg clone http://hg.libsdl.org/SDL SDL-1.2 -r SDL-1.2
fi
if [[ ! -e "${PREFIX}/lib/libSDL.a" ]]; then
clearDepsBuild
pushd build &> /dev/null
CC="${CROSS}-gcc" \
../SDL-1.2/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--disable-threads \
--disable-video-opengl \
--prefix="${PREFIX}"
make
make install
popd &> /dev/null # build
fi
purple "Building SDL_mixer and libMikMod"
if [[ ! -d SDL_mixer-1.2 ]]; then
# ***TODO*** Change to git repo & checkout specific version.
hg clone http://hg.libsdl.org/SDL_mixer SDL_mixer-1.2 -r SDL-1.2
fi
if [[ ! -e "${PREFIX}/lib/libmikmod.a" ]]; then
clearDepsBuild
pushd build &> /dev/null
unzip ../SDL_mixer-1.2/libmikmod-*.zip
mv libmikmod-* libmikmod
CC="${CROSS}-gcc" \
libmikmod/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--prefix="${PREFIX}"
make
make install
popd &> /dev/null # build
fi
if [[ ! -e "${PREFIX}/lib/libSDL_mixer.a" ]]; then
clearDepsBuild
pushd build &> /dev/null
SDL_CONFIG="${PREFIX}/bin/sdl-config" \
LIBMIKMOD_CONFIG="${PREFIX}/bin/libmikmod-config" \
CC="${CROSS}-gcc" \
../SDL_mixer-1.2/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--disable-music-midi \
--enable-music-mod \
--disable-music-mod-shared \
--prefix="${PREFIX}"
make
make install
popd &> /dev/null # build
fi
}
function checkInstalled() {
local TOTAL=${#G_ITEMS[*]}
local X=
for (( X=0; X<=$(( ${TOTAL}-1 )); X++ )); do
if [[ -e "${G_PARENT}/dist/${G_CHECK[$X]}" ]]; then
G_IS_INSTALLED[$X]=1
else
G_IS_INSTALLED[$X]=0
fi
done
}
function clearDepsBuild() {
if [[ -d $(pwd)/build ]]; then
rm -rf $(pwd)/build
fi
mkdir -p $(pwd)/build
}
function configRead() {
if [[ -e "${G_PARENT}/joeyDev.sh" ]]; then
source "${G_PARENT}/joeyDev.sh"
fi
}
function configWrite() {
local O=${G_PARENT}/joeyDev.sh
local P=\${JOEYPATH}
local SDKLIST="["
echo "#!/bin/bash" > "${O}"
# Remember the initial path so we can run this more than once
echo "if [[ -z \$JOEYPATH || \"\${JOEYPATH}\" == \"\" ]]; then" >> "${O}"
echo -e "\texport JOEYPATH=\"\${PATH}\"" >> "${O}"
echo "fi" >> "${O}"
echo "export JOEY=\"${G_PARENT}\"" >> "${O}"
if [[ ${G_IS_INSTALLED[$G_IIGS]} == 1 ]]; then
SDKLIST="${SDKLIST} IIGS"
# IIgs Runtime & ORCA Compilers
P=\${JOEY}/sdks/IIgs:${P}
fi
echo "export GOLDEN_GATE=\"\${JOEY}/sdks/IIgs/ORCA\"" >> "${O}"
echo "if [[ -e \"\${JOEY}/sdks/IIgs/mountORCA.sh\" ]]; then" >> "${O}"
echo -e "\t\"\${JOEY}/sdks/IIgs/mountORCA.sh\"" >> "${O}"
echo "fi" >> "${O}"
#if [[ ${G_IS_INSTALLED[$G_AMIGA]} == 1 ]]; then
# SDKLIST="${SDKLIST} AMIGA"
# P=\${JOEY}/sdks/amiga/bin:${P}
#fi
#if [[ ${G_IS_INSTALLED[$G_ATARIST]} == 1 ]]; then
# SDKLIST="${SDKLIST} ST"
# P=\${JOEY}/sdks/st/bin:${P}
#fi
if [[ ${G_IS_INSTALLED[$G_MACA64]} == 1 ]]; then
SDKLIST="${SDKLIST} MACOSA64"
fi
if [[ ${G_IS_INSTALLED[$G_MACX32]} == 1 ]]; then
SDKLIST="${SDKLIST} MACOSX32"
fi
if [[ ${G_IS_INSTALLED[$G_MACX64]} == 1 ]]; then
SDKLIST="${SDKLIST} MACOSX64"
fi
echo "export MACOSX_INTEL_PATH=\"\${JOEY}/sdks/macOS/intel/bin\"" >> "${O}"
echo "export MACOSX_INTEL_DEPLOYMENT_TARGET=${G_MAC_INTEL_MIN}" >> "${O}"
echo "export MACOSX_INTEL_DARWIN=${G_MAC_INTEL_DARWIN}" >> "${O}"
echo "export MACOSX_APPLE_PATH=\"\${JOEY}/sdks/macOS/apple/bin\"" >> "${O}"
echo "export MACOSX_APPLE_DEPLOYMENT_TARGET=${G_MAC_APPLE_MIN}" >> "${O}"
echo "export MACOSX_APPLE_DARWIN=${G_MAC_APPLE_DARWIN}" >> "${O}"
echo "export PATH=\"${P}\"" >> "${O}"
if [[ ${G_IS_INSTALLED[$G_WIN32]} == 1 ]]; then
SDKLIST="${SDKLIST} WIN32"
fi
if [[ ${G_IS_INSTALLED[$G_WIN64]} == 1 ]]; then
SDKLIST="${SDKLIST} WIN64"
fi
if [[ ${G_IS_INSTALLED[$G_LINUX32]} == 1 ]]; then
SDKLIST="${SDKLIST} LINUX32"
fi
if [[ ${G_IS_INSTALLED[$G_LINUX64]} == 1 ]]; then
SDKLIST="${SDKLIST} LINUX64"
fi
SDKLIST="${SDKLIST} ]"
echo "export JOEYLIB_SDKS=\"${SDKLIST}\"" >> "${O}"
chmod +x "${O}"
}
function doSudo() {
local ARGS="$@"
local ASK="${G_PARENT}/${G_WORK}/askPass.sh"
if [[ "${G_PASSWORD}x" == "x" ]]; then
cat <<- ASKPASS > "${ASK}"
#!/bin/bash
"${G_PARENT}/${G_SCRIPT}" ASKPASS
ASKPASS
else
cat <<- ASKPASS > "${ASK}"
#!/bin/bash
echo "${G_PASSWORD}"
ASKPASS
fi
chmod +x "${ASK}"
if [[ "${ARGS}x" == "x" ]]; then
SUDO_ASKPASS="${ASK}" sudo -A -v
else
SUDO_ASKPASS="${ASK}" sudo -A ${ARGS}
fi
rm "${ASK}"
}
function doSudoAskPass() {
local RET=
local PASSWORD=
set +e
PASSWORD=$(
whiptail --passwordbox "\n${G_TITLE} needs superuser access.\n\nPlease enter your password:" 12 60 --title "Need Root" 3>&1 1>&2 2>&3
)
RET=$?
set -e
if [[ ${RET} -ne 0 ]]; then
echo "Cannot continue without superuser access." 1>&2
exit 1
fi
printf "${PASSWORD}\n"
exit 0
}
function download() {
local URL=$1
local FILE=
tTrim FILE "$2"
if [[ -z ${FILE} ]]; then
FILE=${URL##*/}
fi
if [[ -e "${FILE}" ]]; then
rm -f "${FILE}"
fi
wget -O "${FILE}" ${URL}
}
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##*/}
download ${URL}
eval $__RESULT=\${FILE}
}
function installAmiga() {
local RESULT=
local AMIGA="${G_PARENT}/sdks/amiga"
purple "Installing Amiga GCC"
if [[ ! -d amiga-gcc ]]; then
# ***TODO*** Checkout specific version.
git clone https://github.com/bebbo/amiga-gcc.git
fi
pushd amiga-gcc &> /dev/null
make all PREFIX="${AMIGA}"
popd &> /dev/null
#***TODO*** SDL & Friends
purple "Building JoeyLib Amiga"
(source "${G_PARENT}/joeyDev.sh" && "${G_PARENT}/joeylib/joeylib/build.sh" amiga) &> /dev/null
#***TODO*** Needs emulator
G_IS_INSTALLED[$G_AMIGA]=1
configWrite
configRead
}
function installIIgs() {
local RESULT=
local O=
local ORCA=
local GGATE=
local IIGS="${G_PARENT}/sdks/IIgs"
local RET=
if [[ ! -z ${G_AUTOMATED} ]]; then
GGATE=${G_GOLDEN_GATE_FILE}
if [[ ! -e "${GGATE}" ]]; then
return 0
fi
if [[ ! -e "${G_GOLDEN_GATE_PUBLIC}" || ! -e "${G_GOLDEN_GATE_PRIVATE}" ]]; then
return 0
fi
mkdir -p ~/.ssh
cp -f "${G_GOLDEN_GATE_PUBLIC}" ~/.ssh/id_rsa.pub
cp -f "${G_GOLDEN_GATE_PRIVATE}" ~/.ssh/id_rsa
touch ${HOME}/.ssh/authorized_keys
touch ${HOME}/.ssh/config
chmod go-w ${HOME}
chmod 700 ${HOME}/.ssh
chmod 600 ${HOME}/.ssh/*id_rsa
chmod 644 ${HOME}/.ssh/*.pub
chmod 644 ${HOME}/.ssh/authorized_keys
chmod 644 ${HOME}/.ssh/config
fi
if [[ -e "${IIGS}/unmountORCA.sh" ]]; then
"${IIGS}/unmountORCA.sh"
fi
mkdir -p "${IIGS}/ORCA"
chmod 777 "${IIGS}/ORCA"
if [[ ! -e "${IIGS}/jfsDrive.img" ]]; then
purple "Creating JFS Volume"
O=${IIGS}/mountORCA.sh
echo "#!/bin/bash" > "${O}"
echo "IIGS=${IIGS}" >> "${O}"
echo "if ! mount | grep \${IIGS}/ORCA | grep -q jfs; then" >> "${O}"
echo -e "\tfsck.jfs -a \${IIGS}/jfsDrive.img" >> "${O}"
#echo -e "\tIIGSDISK=\$(sudo losetup --partscan --find --show \${IIGS}/jfsDrive.img)" >> "${O}"
#echo -e "\tsudo mount -t jfs \${IIGSDISK} \${IIGS}/ORCA" >> "${O}"
echo -e "\tsudo mount -t jfs \${IIGS}/jfsDrive.img \${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 "\trm \${IIGS}/lastMount.cfg" >> "${O}"
echo "fi" >> "${O}"
chmod +x "${O}"
fallocate -l 32M "${IIGS}/jfsDrive.img"
mkfs.jfs -O -q -L IIgs "${IIGS}/jfsDrive.img"
# mkntfs -q -F -L IIgs jfsDrive.img
# sudo mount -t ntfs-3g jfsDrive.img ORCA/
fi
"${IIGS}/mountORCA.sh"
doSudo chown ${G_UID}:${G_GID} "${IIGS}/ORCA/."
G_IS_INSTALLED[$G_IIGS]=1
configWrite
configRead
if [[ ! -e "${IIGS}/ORCA/Languages/cc" ]]; then
if [[ ! -z ${G_AUTOMATED} ]]; then
ORCA=${G_ORCA_FILE}
if [[ ! -e "${ORCA}" ]]; then
return 0
fi
else
tFileBrowser ORCA "Please locate your 'OPUS ][ The Software' ISO" .iso ..
if [[ -z ${ORCA} || "${ORCA}" == "" ]]; then
return 0
fi
fi
fi
if [[ ! -d GoldenGate ]]; then
if [[ -z ${G_AUTOMATED} ]]; then
tFileBrowser GGATE "Please locate your 'Golden Gate' MSI" .msi ..
if [[ -z ${GGATE} || "${GGATE}" == "" ]]; then
return 0
fi
set +e
G_GOLDEN_GATE_USER=$(
whiptail --inputbox "\nGolden Gate needs GitLab access.\n\nPlease enter your username:" 12 60 --title "GitLab Account" 3>&1 1>&2 2>&3
)
RET=$?
set -e
if [[ ${RET} -ne 0 ]]; then
echo "Cannot continue without GitLab access." 1>&2
exit 1
fi
set +e
G_GOLDEN_GATE_PASS=$(
whiptail --passwordbox "\nGolden Gate needs GitLab access.\n\nPlease enter your password:" 12 60 --title "GitLab Account" 3>&1 1>&2 2>&3
)
RET=$?
set -e
if [[ ${RET} -ne 0 ]]; then
echo "Cannot continue without GitLab access." 1>&2
exit 1
fi
fi
purple "Building GoldenGate"
mkdir -p ~/.ssh
chmod go-rwx ~/.ssh
ssh-keygen -F gitlab.com || ssh-keyscan gitlab.com > ~/.ssh/known_hosts 2> /dev/null
git config --global credential.helper cache
git clone https://${G_GOLDEN_GATE_USER}:${G_GOLDEN_GATE_PASS}@gitlab.com/GoldenGate/GoldenGate.git
# ***TODO*** Checkout specific version.
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
mkdir -p build
cd build
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
if [[ ! -e "${IIGS}/ORCA/Languages/cc" ]]; then
purple "Installing ORCA/C"
isoinfo -i "${ORCA}" -x /FOR_EMUL/BYTEWORK.S\;1 > BYTEWORKS
"${IIGS}/opus-extractor" -v BYTEWORKS "${IIGS}/ORCA"
purple "Upgrading ORCA/C"
fetchGitHubRelease RESULT byteworksinc ORCA-C 2mg
#***TODO*** This fails with a mmap error sometimes - no idea why
"${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 [[ -z ${AUTOMATED} ]]; then
if [[ ! -d gsplus ]]; then
purple "Building GSplus"
git clone https://github.com/digarok/gsplus.git
# ***TODO*** Checkout specific version.
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
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
purple "Installing IIgs ROM"
download 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
purple "Installing GS/OS"
download 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"
fi
fi
if [[ ! -d cadius ]]; then
purple "Building Cadius"
git clone https://github.com/mach-kernel/cadius.git
# ***TODO*** Checkout specific version.
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 "${IIGS}/ntpconverter/ntpconverter.php" ]]; then
purple "Installing NinjaTrackerPlus Converter"
download http://www.ninjaforce.com/downloads/ntconverter.zip
unzip ntconverter.zip
mkdir -p "${IIGS}/ntpconverter"
cp -f ntconverter.php "${IIGS}/ntpconverter/ntpconverter.php"
fi
if [[ ! -e "${IIGS}/Tool222#ba0000" ]]; then
purple "Installing NinjaTrackerPlus Tool222"
download http://www.ninjaforce.com/downloads/ninjatrackerplus_tool222_v1.4.2mg
"${IIGS}/cadius/cadius" extractfile ninjatrackerplus_tool222_v1.4.2mg NTP.TOOL222V1.4/SYSTEM/TOOLS/TOOL222 .
cp -f TOOL222#BA0000 "${IIGS}/Tool222#ba0000"
fi
mkdir -p "${JOEY}/dist/IIgs"
purple "Building JoeyLib IIgs"
(source "${G_PARENT}/joeyDev.sh" && "${G_PARENT}/joeylib/joeylib/build.sh" iigs) &> /dev/null
"${IIGS}/unmountORCA.sh"
if [[ ! -e "${IIGS}/jfsDrive.img.backup.tar.bz2" ]]; then
tar cjf "${IIGS}/jfsDrive.img.backup.tar.bz2" "${IIGS}/jfsDrive.img" &> /dev/null
fi
}
function installLinux32() {
buildPCDeps \
"linux32" \
"linux/i386" \
"x86_64-linux-gnu" \
"x86_64-linux-gnu-gcc -m32" \
"x86_64-linux-gnu-g++ -m32" \
"" \
""
}
function installLinux64() {
buildPCDeps \
"linux64" \
"linux/x64" \
"x86_64-linux-gnu" \
"x86_64-linux-gnu-gcc" \
"x86_64-linux-gnu-g++" \
"" \
""
#buildSDL12 "x86_64-linux-gnu" "${JOEY}/sdks/linux/x64"
}
function installmacOSA64() {
local INSTALLED=
buildMacOSXSDK APPLE INSTALLED
if [[ ${INSTALLED} -eq 1 ]]; then
buildPCDeps \
"macosa64" \
"macOS/a64" \
"aarch64-apple-darwin${G_MAC_APPLE_DARWIN}" \
"oa64-clang" \
"" \
"${JOEY}/sdks/macOS/a64/lib:${JOEY}/sdks/macOS/apple/lib" \
"${JOEY}/sdks/macOS/apple/bin"
G_IS_INSTALLED[$G_MACA64]=1
configWrite
configRead
fi
}
function installmacOSX32() {
local INSTALLED=
buildMacOSXSDK INTEL INSTALLED
if [[ ${INSTALLED} -eq 1 ]]; then
buildPCDeps \
"macosx32" \
"macOS/i386" \
"i386-apple-darwin${G_MAC_INTEL_DARWIN}" \
"o32-clang" \
"" \
"${JOEY}/sdks/macOS/i386/lib:${JOEY}/sdks/macOS/intel/lib" \
"${JOEY}/sdks/macOS/intel/bin"
G_IS_INSTALLED[$G_MACX32]=1
configWrite
configRead
fi
}
function installmacOSX64() {
local INSTALLED=
buildMacOSXSDK INTEL INSTALLED
if [[ ${INSTALLED} -eq 1 ]]; then
buildPCDeps \
"macosx64" \
"macOS/x64" \
"x86_64-apple-darwin${G_MAC_INTEL_DARWIN}" \
"o64-clang" \
"" \
"${JOEY}/sdks/macOS/x64/lib:${JOEY}/sdks/macOS/intel/lib" \
"${JOEY}/sdks/macOS/intel/bin"
G_IS_INSTALLED[$G_MACX64]=1
configWrite
configRead
fi
}
function installST() {
local ST="${G_PARENT}/sdks/st"
local ST_GCC="m68k-atari-mint-base-20190606-linux.tar"
mkdir -p "${ST}"
if [[ ! -e "${ST}/tos104us.img" ]]; then
purple "Installing TOS & Language Disk"
download http://www.avtandil.narod.ru/tos/tos104us.zip
unzip tos104us.zip
mv tos104us.img "${ST}/."
fi
if [[ ! -e "${ST}/ST_language_disk_ca026062-004.ST" ]]; then
purple "Installing Language Disk"
download http://www.atarimania.com/pgedump.awp?id=28777 1040languagedisk.zip
unzip 1040languagedisk.zip
mv ST_language_disk_ca026062-004.ST "${ST}/."
fi
if [[ ! -e "${ST}/hatari.cfg" ]]; then
purple "Configuring Hatari"
cat <<-CONFIG > "${ST}/hatari.cfg"
[Screen]
bResizable = TRUE
[Joystick1]
nJoystickMode = 1
nJoyId = 0
[Sound]
szYMCaptureFileName = "${ST}/hatari.wav"
[Memory]
szMemoryCaptureFileName = "${ST}/hatari.sav"
szAutoSaveFileName = "${ST}/auto.sav"
[Floppy]
szDiskAFileName = "${ST}/ST_language_disk_ca026062-004.ST"
szDiskImageDirectory = "${ST}"
[HardDisk]
szHardDiskDirectory = "${ST}"
szHardDiskImage = "${ST}"
szIdeMasterHardDiskImage = "${ST}"
szIdeSlaveHardDiskImage = "${ST}"
[ROM]
szTosImageFileName = "${ST}/tos104us.img"
bPatchTos = TRUE
[Printer]
szPrintToFileName = "${ST}/hatari.prn"
[System]
bPatchTimerD = TRUE
bFastBoot = TRUE
[Video]
AviRecordFile = "${ST}/hatari.avi"
CONFIG
fi
if [[ ! -d "${ST}/bin" ]]; then
purple "Installing Atari ST GCC"
if [[ -e "${ST_GCC}" ]]; then
rm "${ST_GCC}"
fi
#***TODO*** Build from github instead
download http://tho-otto.de/download/mint/${ST_GCC}.xz
xz -d ${ST_GCC}.xz
pushd "${ST}" &> /dev/null
tar --strip-components=1 -xf "${G_PARENT}/${G_WORK}/${ST_GCC}"
popd &> /dev/null
fi
buildSDL12 "m68k-atari-mint" "${ST}"
G_IS_INSTALLED[$G_ATARIST]=1
configWrite
configRead
purple "Building JoeyLib Atari ST"
(source "${G_PARENT}/joeyDev.sh" && "${G_PARENT}/joeylib/joeylib/build.sh" st) &> /dev/null
}
function installWin32() {
buildPCDeps \
"win32" \
"windows/i386" \
"i686-w64-mingw32" \
"i686-w64-mingw32-gcc -static-libgcc" \
"" \
"" \
""
}
function installWin64() {
buildPCDeps \
"win64" \
"windows/x64" \
"x86_64-w64-mingw32" \
"x86_64-w64-mingw32-gcc -static-libgcc" \
"x86_64-w64-mingw32-g++ -static-libstdc++" \
"" \
""
}
function mainMenu() {
local TOTAL=${#G_ITEMS[*]}
local MENU=()
local X=
local WHAT=
local CHOICE="x"
if [[ ! -z ${G_AUTOMATED} ]]; then
checkInstalled
for (( X=0; X<=$(( ${TOTAL}-1 )); X++ )); do
CHOICE="install${G_ITEMS[$X]}"
echo ""
tBoldBox tCYAN "NOTE: If an error is encountered, installer will exit!"
${CHOICE}
done
else
while [[ "${CHOICE}" != "" ]]; do
checkInstalled
MENU=()
for (( X=0; X<=$(( ${TOTAL}-1 )); X++ )); do
MENU+=( "${G_ITEMS[$X]}" )
if [[ ${G_IS_INSTALLED[$X]} == 1 ]]; then
WHAT="Rebuild"
else
WHAT="Install"
fi
MENU+=( "${WHAT} ${G_DESC[$X]} Bit JoeyLib Library" )
done
CHOICE=$(
set e+
whiptail --title "${G_TITLE}" --cancel-button "Exit" --menu "" $(( ${TOTAL}+7 )) 65 ${TOTAL} "${MENU[@]}" 3>&2 2>&1 1>&3
set e-
)
if [[ "${CHOICE}" != "" ]]; then
doSudo
CHOICE="install${CHOICE}"
echo ""
tBoldBox tCYAN "NOTE: If an error is encountered, installer will exit!"
${CHOICE}
fi
done
fi
}
function purple() {
local TEXT=$1
echo ""
tBoldBox tPURPLE "${TEXT}"
echo ""
}
# --- START
function start() {
local DOINSTALL=0
# This has to exist before doSudo is called
mkdir -p "${G_WORK}"
doSudo
# Do we have Towel yet?
if [[ ! -f "${G_WORK}/towel/towel.sh" ]]; then
# Do we have GIT?
if [[ "$(which git || true)" == "" ]]; then
echo "Installing git..."
doSudo apt-get -y install git &> /dev/null
fi
echo "Downloading towel.sh support library..."
git clone https://skunkworks.kangaroopunch.com/skunkworks/towel.git "${G_WORK}/towel" &> /dev/null
fi
# Load Towel
source "${G_WORK}/towel/towel.sh"
# Don't change directories until Towel is loaded.
pushd "${G_WORK}" &> /dev/null
# See if all the packages we need are installed
echo ""
tBoldBox tBLUE "Examining system..."
doSudo dpkg --add-architecture i386
doSudo apt-get -y update
tCheckPackages MISSING \
autoconf \
automake \
bash \
bison \
build-essential \
bzip2 \
ciopfs \
clang \
cmake \
cpio \
curl \
flex \
g++-multilib \
gcc-multilib \
gdb-mingw-w64 \
genisoimage \
gettext \
gimp \
git \
git-lfs \
gzip \
hatari \
jfsutils \
lhasa \
libasound2-dev{,:i386} \
libbz2-dev \
libedit-dev \
libdrm-dev{,:i386} \
libfreetype6-dev \
libfuse-dev \
libgbm-dev{,:i386} \
libgmp-dev \
liblzma-dev \
libmpc-dev \
libmpfr-dev \
libncurses5-dev \
libpcap0.8-dev \
libpulse-dev{,:i386} \
libreadline-dev \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libssl-dev \
libtool \
libxml2-dev \
llvm-dev \
make \
mercurial \
mingw-w64 \
msitools \
patch \
php-cli \
ragel \
re2c \
sed \
tar \
texinfo \
unzip \
uuid-dev \
wget \
xz-utils
if [[ "${MISSING}" != "" ]]; then
if [[ ! -z ${G_AUTOMATED} ]]; then
DOINSTALL=1
else
if (whiptail --title "${G_TITLE}" --yesno "Some required packages are missing.\n\nInstall them now?" 9 40); then
DOINSTALL=1
fi
fi
if [[ "${DOINSTALL}" == "1" ]]; then
if [[ ! -z ${G_AUTOMATED} ]]; then
doSudo apt-get -y install ${MISSING}
else
TEMP=" ${MISSING//[^ ]}"
TOTAL=${#TEMP}
COUNT=0
{
for PACKAGE in ${MISSING}; do
PERCENT=$(( 100*(++COUNT)/TOTAL ))
echo ${PERCENT}
doSudo apt-get -y install ${PACKAGE} &> /dev/null
done
} | whiptail --title "${G_TITLE}" --gauge "\nInstalling packages..." 7 50 0
fi
else
tBoldBox tRED "Canceled!"
echo ""
echo "Installation cannot continue without the following pacakges:"
echo ""
echo ${MISSING}
echo ""
echo ${MISSING} > ${G_WORK}/missing.lst
exit 1
fi
fi
# Do we have JoeyLib yet?
if [[ ! -f ${G_PARENT}/joeylib/LICENSE ]]; then
echo ""
tBoldBox tBLUE "Downloading JoeyLib source..."
git clone https://skunkworks.kangaroopunch.com/skunkworks/joeylib.git ${G_PARENT}/joeylib &> /dev/null
#***TODO*** Swap the manually downloaded install script for the one in the archive with a symlink.
fi
mainMenu
checkInstalled
configWrite
clear
tBoldBox tBLUE "Goodbye!"
echo ""
# --- EXIT
popd &> /dev/null
}
# Remember where we live.
G_PARENT=$(pwd)
G_SCRIPT=$(basename -- "$0")
# Set this in case we don't have a config file yet.
export JOEY=${G_PARENT}
# Is SUDO after us?
if [[ "$1" == "ASKPASS" ]]; then
doSudoAskPass # Does not return.
fi
# Are we doing a totally automated install?
if [[ "$1" == "AUTOMATED" ]]; then
G_AUTOMATED=1
G_PASSWORD="$2"
G_ORCA_FILE="$3"
G_GOLDEN_GATE_FILE="$4"
G_GOLDEN_GATE_USER="$5"
G_GOLDEN_GATE_PASS="$6"
G_GOLDEN_GATE_PUBLIC="$7"
G_GOLDEN_GATE_PRIVATE="$8"
fi
# Don't run as root.
if [[ ${EUID} -eq 0 ]]; then
echo "Do not run the installer as root."
exit 1
fi
# At the very end so we can stream this script from a web server.
start