Started over on the installer.

This commit is contained in:
Scott Duensing 2019-06-26 21:47:38 -05:00
parent 780a045672
commit 090af4bbba
2 changed files with 313 additions and 171 deletions

View file

@ -182,4 +182,3 @@ export CC=""
rm -rf build
popd
set +x

View file

@ -1,188 +1,331 @@
#!/bin/bash -e
#
# JoeyLib
# Copyright (C) 2018-2019 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.
#
# --- COLLECT AND CHECK COMMAND LINE ARGUMENTS
usage() {
echo "Usage: $0 [-o PathToORCA.iso] [-i PathForInstall]"
exit 1
#
# Global variables
#
G_TITLE="JoeyLib Installer"
G_PARENT=
function buildPCDeps() {
local DIST=$1
local PREFIX=$2
local CROSS=$3
local CC_EXPORT=$4
local CXX_EXPORT=$5
local CC_OLD=$CC
local CXX_OLD=$CXX
local SRC="${G_PARENT}/joeylib/joeylib/src"
local G_CFLAGS="-Wall -D_REENTRANT_ -I${SRC} -c"
echo ""
tBoldBox tCYAN "NOTE: If an error is encountered, installer will exit!"
# Clear any existing built libraries
if [[ -d ${PREFIX} ]]; then
rm -rf ${PREFIX}
fi
mkdir -p ${PREFIX}
pushd deps >& /dev/null
export CC="${CC_EXPORT}"
export CXX="${CXX_EXPORT}"
# SDL2
if [[ ! -d SDL ]]; then
echo ""
tBoldBox tPURPLE "Building SDL2"
echo ""
hg clone http://hg.libsdl.org/SDL
clearPCDepsBuild
pushd build >& /dev/null
../SDL/configure \
--target="${CROSS}" \
--host="${CROSS}" \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--prefix=${PREFIX}
make
make install
popd >& /dev/null
fi
# libModPlug
if [[ ! -d libmodplug ]]; then
echo ""
tBoldBox tPURPLE "Building libModPlug"
echo ""
git clone https://github.com/Konstanty/libmodplug.git
pushd libmodplug >& /dev/null
libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
popd >& /dev/null
clearPCDepsBuild
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
if [[ ! -d SDL_mixer ]]; then
echo ""
tBoldBox tPURPLE "Building SDL_mixer"
echo ""
hg clone http://hg.libsdl.org/SDL_mixer
clearPCDepsBuild
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-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}"
# JoeyLib
echo ""
tBoldBox tPURPLE "Building JoeyLib"
echo ""
if [[ -d "${DIST}" ]]; then
rm -rf "${DIST}"
fi
mkdir -p "${DIST}"
clearPCDepsBuild
pushd build >& /dev/null
${CC_EXPORT} ${G_CFLAGS} -o jPC.o ${SRC}/jPC.c
${CC_EXPORT} ${G_CFLAGS} -o joey.o ${SRC}/joey.c
ar x ${PREFIX}/lib/libSDL2.a
ar x ${PREFIX}/lib/libSDL2_mixer.a
ar x ${PREFIX}/lib/libmodplug.a
ar rcs ${DIST}/libjoeylib.a *.o
cp -f ${SRC}/joey.h ${DIST}/../..
cp -f ${SRC}/../joey.pri ${DIST}/../..
popd >& /dev/null
popd >& /dev/null
}
while getopts ":o:i:" OPT; do
case ${OPT} in
o )
ORCA=${OPTARG}
;;
i )
INSTALL=${OPTARG}
;;
\? )
echo "Invalid option: ${OPTARG}"
usage
;;
: )
echo "Invalid option: ${OPTARG} requires an argument"
usage
;;
* )
usage
;;
esac
function clearPCDepsBuild() {
if [[ -d $(pwd)/build ]]; then
rm -rf $(pwd)/build
fi
mkdir -p $(pwd)/build
}
function installLinux32() {
buildPCDeps \
"$(pwd)/../dist/linux/i386" \
"$(pwd)/deps/installed/linux/i386" \
"x86_64-linux-gnu" \
"x86_64-linux-gnu-gcc -m32" \
"x86_64-linux-gnu-g++ -m32"
}
function installLinux64() {
buildPCDeps \
"$(pwd)/../dist/linux/x64" \
"$(pwd)/deps/installed/linux/x64" \
"x86_64-linux-gnu" \
"x86_64-linux-gnu-gcc" \
"x86_64-linux-gnu-g++"
}
function installWin32() {
buildPCDeps \
"$(pwd)/../dist/windows/i386" \
"$(pwd)/deps/installed/windows/i386" \
"i686-w64-mingw32" \
"i686-w64-mingw32-gcc -static-libgcc" \
""
}
function installWin64() {
buildPCDeps \
"$(pwd)/../dist/windows/x64" \
"$(pwd)/deps/installed/windows/x64" \
"x86_64-w64-mingw32" \
"x86_64-w64-mingw32-gcc -static-libgcc" \
"x86_64-w64-mingw32-g++ -static-libstdc++"
}
function mainMenu() {
local ITEMS=(
# "IIgs" "Amiga" "ST"
"Linux32" "Linux64"
"Win32" "Win64"
# "macOS32" "macOS64"
# "Android" "iOS"
)
local DESC=(
# "Apple IIgs 16" "Commodore Amiga 16" "Atari ST 16"
"Linux 32" "Linux 64"
"Windows 32" "Windows 64"
# "macOS 32" "macOS 64"
# "Android 32" "iOS 64"
)
local TOTAL=${#ITEMS[*]}
local MENU=()
local X=
local CHOICE="x"
while [[ "${CHOICE}" != "" ]]; do
MENU=()
for (( X=0; X<=$(( ${TOTAL}-1 )); X++ )); do
MENU+=( "${ITEMS[$X]}" )
MENU+=( "Install ${DESC[$X]} Bit JoeyLib Library" )
done
shift $((OPTIND -1))
if [ -z "${ORCA}" ] || [ -z "${INSTALL}" ]; then
usage
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
CHOICE="install${CHOICE}"
${CHOICE}
fi
if [ -z "${ORCA}" ]; then
echo "Must specify the location of the ORCA ISO."
exit 1
fi
if [ ! -e "${ORCA}" ]; then
echo "Unable to locate the ORCA ISO at \"${ORCA}\"."
exit 1
fi
ORCA=`realpath "${ORCA}"`
if [ -z "${INSTALL}" ]; then
echo "Must specify the location to install the JoeyLib SDK."
exit 1
fi
INSTALL=`realpath "${INSTALL}"`
if [ -e "${INSTALL}" ]; then
echo "The specified installation path, \"${INSTALL}\" already exists."
exit 1
fi
# --- INSTALL NEEDED PACKAGES
getPackages() {
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get -y install cmake ragel hfsplus hfsutils hfsprogs libreadline-dev libedit-dev
sudo apt-get -y install build-essential git mercurial texinfo libtool autoconf automake
sudo apt-get -y install gcc-multilib g++-multilib mingw-w64 gdb-mingw-w64 clang llvm-dev libxml2-dev
sudo apt-get -y install uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio
sudo apt-get -y install libpulse-dev{,:i386} libasound-dev{,:i386}
sudo apt-get -y install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev libpcap0.8-dev
sudo apt-get -y install php-cli
done
}
# --- INSTALL GOLDENGATE
# --- START
installGoldenGate() {
#git clone git@gitlab.com:GoldenGate/GoldenGate.git
if [ ! -d GoldenGate ]; then
echo "Unable to clone the GoldenGate repository!"
echo "Must be a paying member of the GoldenGate project!"
echo "See: https://goldengate.gitlab.io/about/"
if [[ $EUID -ne 0 ]]; then
echo "The installer must be run as root."
exit 1
fi
pushd GoldenGate
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
echo "Failed to build GoldenGate."
exit 1
fi
cp -f bin/{iix,dumpobj,opus-extractor} "${IIGS}/."
popd
}
# --- INSTALL ORCA SUITE ON HFS VOLUME
updateOrca() {
COMPONENT=$1
URL=`curl -s https://api.github.com/repos/byteworksinc/${COMPONENT}/releases \
| grep "browser_download_url.*2mg" \
| cut -d : -f 2,3 \
| tr -d \" \
| head -n 1`
FILE=${URL##*/}
#wget ${URL}
${IIGS}/opus-extractor -v -s / ${FILE} ${IIGS}/ORCA
}
installOrca() {
O=${IIGS}/mountORCA.sh
echo "#!/bin/bash" > "${O}"
echo "IIX=${IIGS}" >> "${O}"
echo "fsck.hfsplus \${IIX}/hfsDrive.img" >> "${O}"
echo "IIGSDISK=\$(sudo losetup --partscan --find --show \${IIX}/hfsDrive.img)" >> "${O}"
echo "sudo mount \${IIGSDISK} \${IIX}/ORCA" >> "${O}"
echo "echo LOOP=\${IIGSDISK} > \${IIX}/lastMount.cfg" >> "${O}"
echo "echo MOUNT=\${IIX}/ORCA >> \${IIX}/lastMount.cfg" >> "${O}"
chmod +x ${O}
O=${IIGS}/unmountORCA.sh
echo "#!/bin/bash" > "${O}"
echo "IIX=${IIGS}" >> "${O}"
echo "source \${IIX}/lastMount.cfg" >> "${O}"
echo "sudo umount \${MOUNT}" >> "${O}"
echo "sudo losetup -d \${LOOP}" >> "${O}"
echo "sudo rm \${IIX}/lastMount.cfg" >> "${O}"
chmod +x ${O}
fallocate -l 32M "${IIGS}/hfsDrive.img"
mkfs.hfs -v IIgs "${IIGS}/hfsDrive.img"
mkdir -p "${IIGS}/ORCA"
${IIGS}/mountORCA.sh
sudo 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
updateOrca ORCA-C
${IIGS}/unmountORCA.sh
}
# --- INSTALL GSPLUS
installGsPlus() {
#git clone https://github.com/digarok/gsplus.git
pushd gsplus/src
ln -sf vars_x86linux_sdl2 vars
#make
if [ ! -e gsplus ]; then
echo "Failed to build GSplus."
exit 1
fi
mkdir -p "${IIGS}/gsplus"
cp -f gsplus "${IIGS}/gsplus/."
popd
#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 "s7d1 = System601.po\n\ng_limit_speed = 0\n" > "${IIGS}/gsplus/config.txt"
echo "s7d1 = System601.po\ns7d2 = /tmp/IIgs/import.po\n" > "${IIGS}/gsplus/IIgsTest.cfg"
}
# --- MAIN
mkdir -p installerWork
pushd installerWork
IIGS=${INSTALL}/sdks/IIgs
# Do we have Towel yet?
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
fi
echo "Downloading towel.sh support library..."
git clone https://skunkworks.kangaroopunch.com/skunkworks/towel.git installerWork/towel >& /dev/null
fi
mkdir -p "${IIGS}"
# Load Towel
source installerWork/towel/towel.sh
#getPackages
installGoldenGate
installOrca
installGsPlus
# Remember where we live.
G_PARENT=$(pwd)
popd
# Don't change directories until Towel is loaded.
pushd installerWork >& /dev/null
:<<'SKIP'
# See if all the packages we need are installed
echo ""
tBoldBox tBLUE "Examining system..."
tCheckPackages MISSING cmake ragel hfsplus hfsutils hfsprogs libreadline-dev libedit-dev \
build-essential git mercurial texinfo libtool autoconf automake \
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} \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev libpcap0.8-dev \
php-cli
if [[ "${MISSING}" != "" ]]; then
if (whiptail --title "${G_TITLE}" --yesno "Some required packages are missing.\n\nInstall them now?" 9 40); then
TEMP=" ${MISSING//[^ ]}"
TOTAL=${#TEMP}
COUNT=0
{
for PACKAGE in ${MISSING}; do
PERCENT=$(( 100*(++COUNT)/TOTAL ))
echo ${PERCENT}
apt-get -y install ${PACAKGE} >& /dev/null
done
} | whiptail --title "${G_TITLE}" --gauge "\nInstalling packages..." 7 50 0
else
tBoldBox tRED "Canceled!"
echo ""
echo "Installation cannot continue without the following pacakges:"
echo ""
echo ${MISSING}
echo ""
exit 1
fi
fi
SKIP
# 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
fi
mainMenu
clear
tBoldBox tBLUE "Goodbye!"
echo ""
# --- EXIT
popd >& /dev/null