783 lines
20 KiB
Bash
Executable file
783 lines
20 KiB
Bash
Executable file
#!/bin/bash -xe
|
|
|
|
#
|
|
# 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.
|
|
#
|
|
|
|
|
|
SRC=${HOME}/joeylib/joeylib/src
|
|
IIGS=${HOME}/cross/gsos-wdc-orca
|
|
CADIUS=${IIGS}/cadius/cadius
|
|
SDL2_OLD=25f9ed87ff6947d9576fc9d79dee0784e638ac58
|
|
SDL2_NEW=97a5e744497ff7cc93edc5119d67cad3ee86dd57
|
|
OLD_PATH=${PATH}
|
|
|
|
export GOLDEN_GATE=${IIGS}/ORCA
|
|
|
|
|
|
function addBuildUser() {
|
|
local USER=$1
|
|
local PASS=$2
|
|
local SALT=$(LC_ALL=C tr -cd "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" < /dev/urandom | head -c 8)
|
|
local CRYPT=$(perl -e 'print crypt($ARGV[0], $ARGV[1])' ${PASS} ${SALT})
|
|
|
|
sudo useradd -m -G sftponly -s /sbin/false -p "${CRYPT}" "${USER}"
|
|
sudo chown root:root /home/${USER}
|
|
sudo chmod 755 /home/${USER}
|
|
sudo mkdir -p /home/${USER}/build
|
|
sudo chown ${USER}:${USER} /home/${USER}/build
|
|
sudo chmod u+rwX /home/${USER}/build
|
|
sudo chmod go-rwx /home/${USER}/build
|
|
}
|
|
|
|
|
|
function buildIIgsSDK() {
|
|
local GGATE=$1
|
|
local ORCA=$2
|
|
local PUBLIC=$3
|
|
local PRIVATE=$4
|
|
local GGUSER=$5
|
|
local GGPASS=$6
|
|
local RESULT=
|
|
local O=
|
|
|
|
mkdir -p "${IIGS}/ORCA"
|
|
chmod 777 "${IIGS}/ORCA"
|
|
|
|
mkdir -p ~/.ssh
|
|
cp -f "${PUBLIC}" ~/.ssh/id_rsa.pub
|
|
cp -f "${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
|
|
|
|
if [[ ! -e "${IIGS}/jfsDrive.img" ]]; then
|
|
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 "\tsudo mount -t jfs \${IIGS}/jfsDrive.img \${IIGS}/ORCA" >> "${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 "\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"
|
|
fi
|
|
|
|
"${IIGS}/mountORCA.sh"
|
|
sudo chown $(id -ru):$(id -rg) "${IIGS}/ORCA/."
|
|
|
|
if [[ ! -d GoldenGate ]]; then
|
|
ssh-keygen -F gitlab.com || ssh-keyscan gitlab.com > ~/.ssh/known_hosts
|
|
git config --global credential.helper cache
|
|
git clone https://${GGUSER}:${GGPASS}@gitlab.com/GoldenGate/GoldenGate.git
|
|
fi
|
|
|
|
pushd GoldenGate
|
|
git submodule init
|
|
git submodule update
|
|
mkdir -p build
|
|
cd build
|
|
cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/installed ..
|
|
make
|
|
make install
|
|
mkdir -p ${IIGS}
|
|
cp -f bin/{iix,dumpobj,opus-extractor} "${IIGS}/."
|
|
cd installed
|
|
msiextract "${HOME}/${GGATE}"
|
|
find -name ".*" -delete
|
|
cp -rf GoldenGate/* "${IIGS}/ORCA/."
|
|
popd
|
|
|
|
isoinfo -i "${ORCA}" -x /FOR_EMUL/BYTEWORK.S\;1 > BYTEWORKS
|
|
"${IIGS}/opus-extractor" -v BYTEWORKS "${IIGS}/ORCA"
|
|
rm BYTEWORKS
|
|
|
|
fetchGitHubRelease RESULT byteworksinc ORCA-C 2mg
|
|
"${IIGS}/opus-extractor" -v -s / ${RESULT} "${IIGS}/ORCA"
|
|
|
|
export PATH=${OLD_PATH}:${IIGS}
|
|
pushd ${GOLDEN_GATE}
|
|
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
|
|
export PATH=${OLD_PATH}
|
|
|
|
if [[ ! -d cadius ]]; then
|
|
git clone https://skunkworks.kangaroopunch.com/mirrors/cadius.git
|
|
pushd cadius
|
|
make
|
|
mkdir -p "${IIGS}/cadius"
|
|
cp -f bin/release/cadius "${IIGS}/cadius/."
|
|
popd
|
|
fi
|
|
|
|
if [[ ! -e "${IIGS}/ntpconverter/ntpconverter.php" ]]; then
|
|
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
|
|
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
|
|
|
|
"${IIGS}/unmountORCA.sh"
|
|
|
|
if [[ ! -e "${IIGS}/jfsDrive.img.backup.tar.bz2" ]]; then
|
|
tar cjf "${IIGS}/jfsDrive.img.backup.tar.bz2" "${IIGS}/jfsDrive.img"
|
|
fi
|
|
}
|
|
|
|
|
|
function buildJoeyLib() {
|
|
local OUT=
|
|
|
|
OLD_CFLAGS=${CFLAGS}
|
|
|
|
if [[ ! -d joeylib ]]; then
|
|
git clone https://skunkworks.kangaroopunch.com/skunkworks/joeylib.git
|
|
fi
|
|
|
|
rm -rf dist/${NAME}-${ARCH} && true
|
|
mkdir -p dist/${NAME}-${ARCH}
|
|
|
|
pushd dist/${NAME}-${ARCH}
|
|
case ${BACKEND} in
|
|
orca)
|
|
OUT=${GOLDEN_GATE}/out/joey
|
|
rm -rf ${OUT} && true
|
|
mkdir -p ${OUT}/out/joey
|
|
pushd ${SRC}
|
|
iix assemble jIIgs.asm keep=31:/out/joey/jIIgsasm
|
|
iix compile jIIgs.c keep=31:/out/joey/jIIgsc
|
|
iix compile joey.c keep=31:/out/joey/joey
|
|
popd
|
|
cp -f "${OUT}/jIIgsc.root" "jIIgsc.root#b10000"
|
|
cp -f "${OUT}/jIIgsc.a" "jIIgsc.a#b10000"
|
|
cp -f "${OUT}/jIIgsasm.root" "jIIgsasm.root#b10000"
|
|
cp -f "${OUT}/jIIgsasm.a" "jIIgsasm.a#b10000"
|
|
cp -f "${OUT}/joey.a" "joey.a#b10000"
|
|
cp -f "${IIGS}/Tool222#ba0000" .
|
|
;;
|
|
|
|
SDL2)
|
|
export CFLAGS="${CFLAGS} -Wall -D_REENTRANT_ -I${SRC} -I${INSTALLED}/include -c"
|
|
${CC} ${CFLAGS} -o jPixBuf.o ${SRC}/jPixBuf.c
|
|
${CC} ${CFLAGS} -o jSDL2.o ${SRC}/jSDL2.c
|
|
${CC} ${CFLAGS} -o joey.o ${SRC}/joey.c
|
|
${AR} x ${INSTALLED}/lib/libSDL2.a
|
|
${AR} x ${INSTALLED}/lib/libSDL2main.a
|
|
${AR} rcs libjoeylib.a *.o
|
|
rm *.o
|
|
rm __.SYMDEF* && true
|
|
;;
|
|
|
|
esac
|
|
|
|
cp -f ${SRC}/joey.h ../.
|
|
popd
|
|
|
|
export CFLAGS=${OLD_CFLAGS}
|
|
}
|
|
|
|
|
|
function buildMacOSSDK() {
|
|
local SDK=$1
|
|
local NAME=$2
|
|
|
|
if [[ ! -d osxcross ]]; then
|
|
git clone https://skunkworks.kangaroopunch.com/mirrors/osxcross.git
|
|
fi
|
|
|
|
pushd osxcross
|
|
cp -f ../"${SDK}" tarballs/.
|
|
UNATTENDED=1 ./build.sh
|
|
sudo ENABLE_COMPILER_RT_INSTALL=1 ./build_compiler_rt.sh
|
|
mkdir -p ../cross/${NAME}
|
|
mv -f target/* ../cross/${NAME}
|
|
sudo mv -f /usr/lib/llvm-10/lib/clang/10.0.0/lib/darwin ../cross/${NAME}/.
|
|
./cleanup.sh
|
|
popd
|
|
}
|
|
|
|
|
|
function buildSDL2() {
|
|
local TAG=$1
|
|
|
|
if [[ ! -d SDL ]]; then
|
|
git clone https://skunkworks.kangaroopunch.com/mirrors/SDL.git
|
|
fi
|
|
|
|
pushd SDL
|
|
git checkout ${TAG}
|
|
popd
|
|
|
|
rm -rf build && true
|
|
mkdir -p build
|
|
|
|
pushd build
|
|
../SDL/configure \
|
|
--target=${TRIPLE} \
|
|
--host=${TRIPLE} \
|
|
--build=x86_64-linux \
|
|
--enable-static \
|
|
--disable-shared \
|
|
--disable-video-wayland \
|
|
--disable-render-metal \
|
|
--disable-video-metal \
|
|
--prefix=${INSTALLED}
|
|
make
|
|
make install
|
|
popd
|
|
}
|
|
|
|
|
|
function configureSFTP() {
|
|
if [[ ! -f /etc/ssh/sftponly_ready ]]; then
|
|
sudo addgroup sftponly && true
|
|
sudo sed -i 's/^Subsystem/#Subsystem/g' /etc/ssh/sshd_config
|
|
echo "Subsystem sftp internal-sftp -f AUTH -l VERBOSE" | sudo tee -a /etc/ssh/sshd_config
|
|
echo "Match Group sftponly" | sudo tee -a /etc/ssh/sshd_config
|
|
echo -e "\tChrootDirectory %h" | sudo tee -a /etc/ssh/sshd_config
|
|
echo -e "\tForceCommand internal-sftp" | sudo tee -a /etc/ssh/sshd_config
|
|
echo -e "\tAllowTcpForwarding no" | sudo tee -a /etc/ssh/sshd_config
|
|
echo -e "\tX11Forwarding no" | sudo tee -a /etc/ssh/sshd_config
|
|
sudo systemctl restart sshd
|
|
sudo touch /etc/ssh/sftponly_ready
|
|
fi
|
|
}
|
|
|
|
|
|
function delBuildUser() {
|
|
local USER=$1
|
|
|
|
sudo userdel -f -r ${USER}
|
|
}
|
|
|
|
|
|
function doBuild() {
|
|
local DIST=$1
|
|
local SRC=$2
|
|
local LINE=
|
|
local DATA=()
|
|
local CFILES=()
|
|
local OFILES=
|
|
local FILE=
|
|
local EXTENSION=
|
|
local LOG=
|
|
local TARGET=
|
|
local GSTARGET=
|
|
local LIB=
|
|
local O=
|
|
local DISK=
|
|
|
|
pushd "${SRC}"
|
|
|
|
# Are there old reults to clean up?
|
|
if [[ -f build.finished ]]; then
|
|
rm build.finished
|
|
fi
|
|
if [[ -d results ]]; then
|
|
rm -rf results
|
|
fi
|
|
mkdir -p results
|
|
BUILD_RESULTS=${SRC}/results
|
|
|
|
# Read project information.
|
|
BUILD_PLATFORMS="["
|
|
BUILD_PROJECT=
|
|
while IFS= read -r LINE; do
|
|
if [[ -z ${BUILD_PROJECT} ]]; then
|
|
BUILD_PROJECT=${LINE}
|
|
# Generate a list of non-source files.
|
|
for FILE in $(ls -1); do
|
|
if [[ "${FILE}" != "build.start" && "${FILE}" != "build.temp" && "${FILE}" != "build.tar.bz2" && "${FILE}" != "results" ]]; then
|
|
EXTENSION="${FILE##*.}"
|
|
if [[ "${EXTENSION}" != "c" && "${EXTENSION}" != "h" && "${EXTENSION}" != "asm" && "${EXTENSION}" != "macro" && "${EXTENSION}" != "inc" ]]; then
|
|
DATA+=(${FILE})
|
|
fi
|
|
fi
|
|
done
|
|
# Generate a list of C files to compile.
|
|
CFILES=($(ls -1 *.c))
|
|
else
|
|
BUILD_PLATFORMS="${BUILD_PLATFORMS}${LINE,,} "
|
|
case ${LINE,,} in
|
|
iigs)
|
|
setCompiler gsos 816
|
|
TARGET="${GOLDEN_GATE}/out/build"
|
|
GSTARGET="31:/out/build"
|
|
;;
|
|
|
|
linux32)
|
|
setCompiler linux i386
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
linux64)
|
|
setCompiler linux x86_64
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
macosx32)
|
|
setCompiler macos i386
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
macosx64)
|
|
setCompiler macos x86_64
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
macosa64)
|
|
setCompiler macos arm
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
win32)
|
|
setCompiler windows i386
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
win64)
|
|
setCompiler windows x86_64
|
|
TARGET="${SRC}/temp"
|
|
;;
|
|
|
|
esac
|
|
|
|
LOG="${BUILD_RESULTS}/build.${LINE,,}"
|
|
LIB="${DIST}/${NAME}-${ARCH}"
|
|
|
|
[[ -d "${TARGET}" ]] && rm -rf "${TARGET}"
|
|
mkdir -p "${TARGET}"
|
|
|
|
# Make sure we have the official JoeyLib header.
|
|
cp -f "${DIST}/joey.h" "${TARGET}/."
|
|
|
|
case ${BACKEND} in
|
|
orca)
|
|
# Compile C files and generate object list.
|
|
OFILES=""
|
|
for FILE in "${CFILES[@]}"; do
|
|
O=${FILE%.*}
|
|
OFILES="${OFILES} ${GSTARGET}/${O}"
|
|
iix compile ${FILE} keep=${GSTARGET}/${O}
|
|
done
|
|
# We need a local copy of JoeyLib to link.
|
|
cp -f "${LIB}/jIIgsc.a#b10000" "${TARGET}/jIIgsc.a"
|
|
cp -f "${LIB}/jIIgsc.root#b10000" "${TARGET}/jIIgsc.root"
|
|
cp -f "${LIB}/jIIgsasm.a#b10000" "${TARGET}/jIIgsasm.a"
|
|
cp -f "${LIB}/jIIgsasm.root#b10000" "${TARGET}/jIIgsasm.root"
|
|
cp -f "${LIB}/joey.a#b10000" "${TARGET}/joey.a"
|
|
iix chtyp -t obj ${GSTARGET}/jIIgsc.a
|
|
iix chtyp -t obj ${GSTARGET}/jIIgsc.root
|
|
iix chtyp -t obj ${GSTARGET}/jIIgsasm.a
|
|
iix chtyp -t obj ${GSTARGET}/jIIgsasm.root
|
|
iix chtyp -t obj ${GSTARGET}/joey.a
|
|
# Add our library files to OFILES
|
|
OFILES="${GSTARGET}/jIIgsc ${GSTARGET}/joey ${GSTARGET}/jIIgsasm ${OFILES}"
|
|
# Link.
|
|
iix -DKeepType=S16 link ${OFILES} keep=${GSTARGET}/${BUILD_PROJECT}#b3db03
|
|
# Create disk image, setting known file types
|
|
DISK=${BUILD_RESULTS}/${LINE,,}/build.po
|
|
${CADIUS} createvolume ${DISK} ${BUILD_PROJECT} 32MB > /dev/null
|
|
${CADIUS} createfolder ${DISK} ${BUILD_PROJECT}/data > /dev/null
|
|
${CADIUS} addfile ${DISK} ${BUILD_PROJECT} ${TARGET}/${BUILD_PROJECT}#b3db03 > /dev/null
|
|
${CADIUS} addfile ${DISK} ${BUILD_PROJECT}/data ${LIB}/Tool222#ba0000 > /dev/null
|
|
for FILE in "${DATA[@]}"; do
|
|
#***TODO*** Data conversion here!
|
|
O=`basename ${FILE}`#060000
|
|
cp -f ${FILE} ${O}
|
|
${CADIUS} addfile ${DISK} ${BUILD_PROJECT}/data ${O} > /dev/null
|
|
rm ${O}
|
|
done
|
|
;;
|
|
|
|
SDL2)
|
|
;;
|
|
esac
|
|
fi
|
|
done < build.start
|
|
|
|
BUILD_PLATFORMS="${BUILD_PLATFORMS}]"
|
|
|
|
popd
|
|
}
|
|
|
|
|
|
function doInstall() {
|
|
local GGUSER=$1
|
|
local GGPASS=$2
|
|
|
|
updateSystem
|
|
configureSFTP
|
|
|
|
buildIIgsSDK "Golden Gate.msi" "Opus ][ The Software.iso" id_rsa id_rsa.pub "${GGUSER}" "${GGPASS}"
|
|
buildMacOSSDK MacOSX10.13.sdk.tar.xz macos-intel
|
|
buildMacOSSDK MacOSX11.3.sdk.tar.xz macos-apple
|
|
|
|
setCompiler gsos 816
|
|
buildJoeyLib
|
|
|
|
setCompiler linux i386
|
|
buildSDL2 ${SDL2_NEW}
|
|
buildJoeyLib
|
|
|
|
setCompiler linux x86_64
|
|
buildSDL2 ${SDL2_NEW}
|
|
buildJoeyLib
|
|
|
|
setCompiler macos i386
|
|
buildSDL2 ${SDL2_OLD}
|
|
buildJoeyLib
|
|
|
|
setCompiler macos x86_64
|
|
buildSDL2 ${SDL2_OLD}
|
|
buildJoeyLib
|
|
|
|
setCompiler macos arm
|
|
buildSDL2 ${SDL2_NEW}
|
|
buildJoeyLib
|
|
|
|
setCompiler windows i386
|
|
buildSDL2 ${SDL2_NEW}
|
|
buildJoeyLib
|
|
|
|
setCompiler windows x86_64
|
|
buildSDL2 ${SDL2_NEW}
|
|
buildJoeyLib
|
|
}
|
|
|
|
|
|
function download() {
|
|
local URL=$1
|
|
local FILE=
|
|
|
|
trim 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 setCompiler() {
|
|
local OS=$1
|
|
local CPU=$2
|
|
|
|
case ${OS} in
|
|
gsos)
|
|
case ${CPU} in
|
|
816)
|
|
NAME="gsos-wdc"
|
|
ARCH=816
|
|
;;
|
|
|
|
esac
|
|
BACKEND=orca
|
|
export PATH=${OLD_PATH}:${IIGS}
|
|
"${IIGS}/mountORCA.sh"
|
|
;;
|
|
|
|
linux)
|
|
case ${CPU} in
|
|
i386)
|
|
NAME="linux-intel"
|
|
ARCH=i386
|
|
TRIPLE="x86_64-linux-gnu"
|
|
export CFLAGS="-m32"
|
|
;;
|
|
|
|
x86_64)
|
|
NAME="linux-intel"
|
|
ARCH=x86_64
|
|
TRIPLE="${ARCH}-linux-gnu"
|
|
export CFLAGS=
|
|
;;
|
|
|
|
esac
|
|
BACKEND=SDL2
|
|
export PATH=${OLD_PATH}
|
|
export LD_LIBRARY_PATH=
|
|
export CC=${TRIPLE}-gcc
|
|
export AR=${TRIPLE}-ar
|
|
;;
|
|
|
|
macos)
|
|
case ${CPU} in
|
|
i386)
|
|
NAME="macos-intel"
|
|
ARCH=i386
|
|
TRIPLE="${ARCH}-apple-darwin17"
|
|
;;
|
|
|
|
x86_64)
|
|
NAME="macos-intel"
|
|
ARCH=x86_64
|
|
TRIPLE="${ARCH}-apple-darwin17"
|
|
;;
|
|
|
|
arm)
|
|
NAME="macos-apple"
|
|
ARCH=aarch64
|
|
TRIPLE="${ARCH}-apple-darwin20.4"
|
|
;;
|
|
|
|
esac
|
|
BACKEND=SDL2
|
|
export CFLAGS=
|
|
export PATH=${HOME}/cross/${NAME}/bin:${OLD_PATH}
|
|
export LD_LIBRARY_PATH=${HOME}/cross/${NAME}/lib
|
|
export CC=${TRIPLE}-clang
|
|
export AR=${TRIPLE}-ar
|
|
sudo rm -f /usr/lib/llvm-10/lib/clang/10.0.0/lib/darwin && true
|
|
sudo ln -s ${HOME}/cross/${NAME}/darwin /usr/lib/llvm-10/lib/clang/10.0.0/lib/.
|
|
;;
|
|
|
|
windows)
|
|
case ${CPU} in
|
|
i386)
|
|
NAME="windows-intel"
|
|
ARCH=i686
|
|
TRIPLE="${ARCH}-w64-mingw32"
|
|
;;
|
|
|
|
x86_64)
|
|
NAME="windows-intel"
|
|
ARCH=x86_64
|
|
TRIPLE="${ARCH}-w64-mingw32"
|
|
;;
|
|
|
|
esac
|
|
BACKEND=SDL2
|
|
export PATH=${OLD_PATH}
|
|
export LD_LIBRARY_PATH=
|
|
export CFLAGS="-static-libgcc"
|
|
export CC=${TRIPLE}-gcc
|
|
export AR=${TRIPLE}-ar
|
|
;;
|
|
|
|
esac
|
|
|
|
INSTALLED=${HOME}/installed/${NAME}-${ARCH}
|
|
mkdir -p ${INSTALLED}
|
|
}
|
|
|
|
|
|
function scriptIsDownloaded() {
|
|
local ACTION=$1
|
|
|
|
case ${ACTION} in
|
|
add)
|
|
addBuildUser "${2}" "${3}"
|
|
;;
|
|
|
|
build)
|
|
doBuild "${2}" "${3}"
|
|
;;
|
|
|
|
del)
|
|
delBuildUser "${2}"
|
|
;;
|
|
|
|
install)
|
|
doInstall "${2}" "${3}"
|
|
;;
|
|
|
|
server)
|
|
startBuildServer "${2}"
|
|
;;
|
|
|
|
*)
|
|
echo "${0} add USER PASS"
|
|
echo "${0} build DIST SRC"
|
|
echo "${0} del USER"
|
|
echo "${0} install GGUSER GGPASS"
|
|
echo "${0} server DIST"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
|
|
function startBuildServer() {
|
|
local DIST=$1
|
|
local LOG=/opt/joey/${0}.log
|
|
local USERNAME=
|
|
local FILE=
|
|
|
|
# Log startup.
|
|
echo "$(date) - Startup ${0}" >> ${LOG}
|
|
|
|
cd /home
|
|
|
|
while true; do
|
|
|
|
# Find users with a "build.start" file.
|
|
for USERNAME in $(ls -1); do
|
|
|
|
mkdir -p "${USERNAME}/build"
|
|
chown -r ${USERNAME}:${USERNAME} "${USERNAME}/build"
|
|
chmod u+rwX "${USERNAME}/build"
|
|
chmod go-rwx "${USERNAME}/build"
|
|
|
|
if [[ -f "${USERNAME}/build/build.start" ]]; then
|
|
|
|
doBuild "${DIST}" "${USERNAME}/build"
|
|
|
|
pushd "${USERNAME}/build" &> /dev/null
|
|
|
|
# Compress the results.
|
|
tar cJf build.temp results
|
|
chown ${USERNAME}:${USERNAME} build.temp
|
|
|
|
# Erase everything except the temp file.
|
|
rm -rf "${BUILD_RESULTS}"
|
|
for FILE in $(ls -1); do
|
|
if [[ ${FILE} != "build.temp" ]]; then
|
|
rm ${FILE}
|
|
fi
|
|
done
|
|
|
|
# Signal JoeyDev we're done.
|
|
mv build.temp build.tar.bz2
|
|
|
|
# Log it.
|
|
echo "$(date) - Compiled ${BUILD_PROJECT} for ${USERNAME} on ${BUILD_PLATFORMS}" >> ${LOG}
|
|
|
|
popd &> /dev/null
|
|
fi
|
|
done
|
|
|
|
sleep 1
|
|
|
|
done
|
|
}
|
|
|
|
|
|
function trim() {
|
|
local __RESULT=$1
|
|
local __VAR="${*:2}"
|
|
|
|
# remove leading whitespace characters
|
|
__VAR="${__VAR#"${__VAR%%[![:space:]]*}"}"
|
|
# remove trailing whitespace characters
|
|
__VAR="${__VAR%"${__VAR##*[![:space:]]}"}"
|
|
|
|
eval $__RESULT=\${__VAR}
|
|
}
|
|
|
|
|
|
function updateSystem() {
|
|
sudo apt update
|
|
sudo apt -y upgrade
|
|
sudo apt -y dist-upgrade
|
|
sudo dpkg --add-architecture i386
|
|
sudo apt -y install \
|
|
autoconf \
|
|
build-essential \
|
|
bzip2 \
|
|
clang \
|
|
cmake \
|
|
cpio \
|
|
gcc-multilib \
|
|
gzip \
|
|
libbz2-dev \
|
|
liblzma-dev \
|
|
libssl-dev \
|
|
libxml2-dev \
|
|
llvm \
|
|
mingw-w64 \
|
|
patch \
|
|
php-cli \
|
|
sed \
|
|
uuid-dev \
|
|
xz-utils \
|
|
zlib1g-dev
|
|
# ORCA / GoldenGate Stuff
|
|
sudo apt -y install \
|
|
genisoimage \
|
|
jfsutils \
|
|
msitools \
|
|
ragel
|
|
}
|
|
|
|
|
|
scriptIsDownloaded "$1" "$2" "$3"
|