Initial commit

This commit is contained in:
Scott Duensing 2022-12-30 19:06:33 -06:00
commit 418d561995
6 changed files with 661 additions and 0 deletions

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
packages/
stuff/
towel/
temp/
old/
*~
automated.install
updateVM.sh

18
automated.install.sample Normal file
View file

@ -0,0 +1,18 @@
# Required for All.
AUTOMATED_SUDO=
# Required for IIgs.
AUTOMATED_OPUS_SOFTWARE_ISO="Opus ][ The Software.iso"
AUTOMATED_GOLDEN_GATE_MSI="Golden Gate.msi"
AUTOMATED_GOLDEN_GATE_PRIVATE_KEY=id_rsa
AUTOMATED_GOLDEN_GATE_PUBLIC_KEY=id_rsa.pub
AUTOMATED_GOLDEN_GATE_USER_NAME=
AUTOMATED_GOLDEN_GATE_PASSWORD=
# Required for MacOS. Fill in either the SDK or XCODE entries.
# Using SDK archives takes much longer.
# (But will generate XCODE archives for you for next time!)
AUTOMATED_MACOS_SDK_10_13=MacOSX10.13.sdk.tar.xz
AUTOMATED_MACOS_SDK_11_3=MacOSX11.3.sdk.tar.xz
AUTOMATED_XCODE_9_4_1_XIP=Xcode_9.4.1.xip
AUTOMATED_XCODE_12_5_1_XIP=Xcode_12.5.1.xip

320
joeybuild.sh Executable file
View file

@ -0,0 +1,320 @@
#!/bin/bash -e
#
# JoeyBuild
# Copyright (C) 2018-2023 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.
#
#
# This is intended to be used on a clean install of ubuntu-20.04.x-live-server-amd64.iso
#
G_EHOME="$(getent passwd $(logname) | cut -d: -f6)" # Home for this user.
G_SRC="${G_EHOME}/joeylib/joeylib/src" # Location of JoeyLib source.
G_TEMP="${G_EHOME}/temp" # Directory to store temporary data.
G_TITLE="JoeyBuild" # Title of application.
G_ORIGINAL_PATH=${PATH} # Original system path.
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})
tSudo useradd -m -G sftponly -s /sbin/false -p "${CRYPT}" "${USER}"e
tSudo chown root:root /home/${USER}
tSudo chmod 755 /home/${USER}
tSudo mkdir -p /home/${USER}/build
tSudo chown ${USER}:${USER} /home/${USER}/build
tSudo chmod u+rwX /home/${USER}/build
tSudo chmod go-rwx /home/${USER}/build
}
function call() {
local _RESULT=$1
local _MODULE=$2
local _FUNCTION=$3
local _ARGS=${*:4}
local _VALUE=
_VALUE="$( source ${G_EHOME}/targets/${_MODULE}.target && ${_FUNCTION} ${_ARGS} )"
eval $_RESULT=\${_VALUE}
}
function configureSFTP() {
if [[ ! -f /etc/ssh/sftponly_ready ]]; then
tSudo addgroup sftponly || true
tSudo sed -i 's/^Subsystem/#Subsystem/g' /etc/ssh/sshd_config
echo "Subsystem sftp internal-sftp -f AUTH -l VERBOSE" | tSudo tee -a /etc/ssh/sshd_config
echo "Match Group sftponly" | tSudo tee -a /etc/ssh/sshd_config
echo -e "\tChrootDirectory %h" | tSudo tee -a /etc/ssh/sshd_config
echo -e "\tForceCommand internal-sftp" | tSudo tee -a /etc/ssh/sshd_config
echo -e "\tAllowTcpForwarding no" | tSudo tee -a /etc/ssh/sshd_config
echo -e "\tX11Forwarding no" | tSudo tee -a /etc/ssh/sshd_config
tSudo systemctl restart sshd
tSudo touch /etc/ssh/sftponly_ready
fi
}
function delBuildUser() {
local USER=$1
tSudo userdel -f -r ${USER}
}
function doBuild() {
true
}
function doInstall() {
# Do we have an automation file?
if [[ ! -f "${G_EHOME}/automated.install" ]]; then
tBoldBox tRED "Cannot find automated.install file!"
exit 1
fi
source "${G_EHOME}/automated.install"
tSudoSetPassword "${AUTOMATED_SUDO}"
git config --global user.email "no-reply@kangaroopunch.com"
git config --global user.name "JoeyBuild VM Installer"
updateSystem
configureSFTP
withTargets install
rebuildJoeyLib
# Start build server on reboot.
if [[ ! -f /etc/rc.local ]]; then
echo "#!/bin/bash" | tSudo tee /etc/rc.local > /dev/null
echo "${BASH_SOURCE[0]} server ${G_EHOME}/dist ${G_EHOME}/builds.log &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null
echo "exit 0" | tSudo tee -a /etc/rc.local > /dev/null
fi
}
function rebuildJoeyLib() {
local TARGET=
local RESULT=
local NAME=
local ARCHS=
local ARCH=
local PASS=
# Do we have JoeyLib yet?
if [[ ! -f ${G_EHOME}/joeylib/LICENSE ]]; then
tBoldBox tBLUE "Downloading JoeyLib source..."
git clone https://skunkworks.kangaroopunch.com/skunkworks/joeylib.git ${G_EHOME}/joeylib &> /dev/null
fi
for TARGET in ${G_EHOME}/targets/*.target; do
NAME=$(basename -s .target ${TARGET})
call RESULT ${NAME} enabled
if [[ ${RESULT} -eq 1 ]]; then
call ARCHS ${NAME} architectures
for ARCH in ${ARCHS}; do
rm -rf dist/${NAME}-${ARCH} || true
for PASS in "debug" "release"; do
tBoldBox tPURPLE "Building JoeyLib ${NAME} ${ARCH} (${PASS})..."
mkdir -p dist/${NAME}-${ARCH}/${PASS}
pushd dist/${NAME}-${ARCH}/${PASS}
call RESULT ${NAME} buildJoeyLib ${ARCH} ${PASS}
popd
done
done
fi
done
cp -f ${G_SRC}/joey.h dist/.
mkdir -p dist/3rdparty/memwatch
cp -f ${G_SRC}/3rdparty/memwatch/* dist/3rdparty/memwatch/.
}
function startup() {
local ARGS=$@
local ACTION=$1
local NAME="$(basename $0)"
# Do we have Towel yet?
if [[ ! -f "${G_EHOME}/towel/towel.sh" ]]; then
# Do we have GIT?
if [[ "$(which git || true)" == "" ]]; then
echo "Installing git..."
#***TODO*** This should be the only use of non-Towel sudo.
sudo apt-get -y install git
fi
echo "Downloading towel.sh support library..."
git clone https://skunkworks.kangaroopunch.com/skunkworks/towel.git "${G_EHOME}/towel" &> /dev/null
fi
# Load Towel
source "${G_EHOME}/towel/towel.sh"
# Give Towel a chance to handle arguments.
tArgsHandler ${ARGS}
# Anything after this, don't run as root.
if [[ ${EUID} -eq 0 ]]; then
echo "Do not run this script as root."
exit 1
fi
# Be sure we can silently sudo. (for mountORCA)
tSudo
case ${ACTION} in
add)
addBuildUser "${2}" "${3}"
;;
build)
doBuild "${2}" "${3}"
;;
del)
delBuildUser "${2}"
;;
install)
doInstall "${2}" "${3}"
;;
rebuild)
rebuildJoeyLib
;;
server)
startBuildServer "${2}" "${3}"
;;
*)
#set +x
tBoldBox tGREEN "${G_TITLE} Options"
echo "${NAME} add USER PASS"
echo "${NAME} build DIST SRC"
echo "${NAME} del USER"
echo "${NAME} install"
echo "${NAME} rebuild"
echo "${NAME} server DIST LOG"
#set -x
;;
esac
}
function startBuildServer() {
true
}
function updateSystem() {
local MISSING=
tBoldBox tBLUE "Examining system..."
tSudo apt update
tSudo apt -y upgrade
tSudo apt -y dist-upgrade
#***TODO*** Split this into target modules.
tSudo dpkg --add-architecture i386
tCheckPackages MISSING \
attr \
autoconf \
bison \
build-essential \
bzip2 \
clang \
cmake \
cpio \
flex \
gawk \
gcc-multilib \
git \
gzip \
libbz2-dev \
liblzma-dev \
libssl-dev \
libxml2-dev \
libzstd-dev \
llvm \
mingw-w64 \
mtools \
nasm \
patch \
php-cli \
sed \
unzip \
uuid-dev \
xz-utils \
zlib1g-dev \
genisoimage \
jfsutils \
msitools \
ragel
if [[ "${MISSING}" != "" ]]; then
tSudo apt-get -y install ${MISSING}
fi
}
function withTargets() {
local FUNCTION=$1
local ARGS=${*:2}
local TARGET=
local RESULT=
local NAME=
local ARCHS=
local ARCH=
for TARGET in ${G_EHOME}/targets/*.target; do
NAME=$(basename -s .target ${TARGET})
call RESULT ${NAME} enabled
if [[ ${RESULT} -eq 1 ]]; then
call ARCHS ${NAME} architectures
for ARCH in ${ARCHS}; do
call RESULT ${NAME} ${FUNCTION} ${ARCH} ${ARGS}
done
fi
done
}
# At the very end so we can stream this script from a web server.
startup $@

220
targets/IIgs.target Normal file
View file

@ -0,0 +1,220 @@
#
# JoeyBuild
# Copyright (C) 2018-2023 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.
#
M_IIGS=${G_EHOME}/cross/gsos-wdc-orca
M_CADIUS=${M_IIGS}/cadius/cadius
export GOLDEN_GATE=${M_IIGS}/ORCA
function architectures() {
echo "65816"
}
function buildApplication() {
true
}
function buildJoeyLib() {
local ARCH=$1
local PASS=$2
local OUT=${GOLDEN_GATE}/out/joey
export PATH=${G_ORIGINAL_PATH}:${M_IIGS}
"${M_IIGS}/mountORCA.sh"
rm -rf ${OUT} || true
mkdir -p ${OUT}
pushd ${G_SRC}
if [[ "${PASS}" == "debug" ]]; then
# Add JOEY_DEBUG flag.
cp joey.h joey.h.original
sed -i "1i #define JOEY_DEBUG" joey.h
fi
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
if [[ "${PASS}" == "debug" ]]; then
# Remove JOEY_DEBUG.
rm joey.h
mv joey.h.original joey.h
fi
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 "${M_IIGS}/Tool222#ba0000" .
"${M_IIGS}/unmountORCA.sh"
export PATH=${G_ORIGINAL_PATH}
}
function enabled() {
echo 1
}
function install() {
local ARCH=$1
local RESULT=
local O=
tBoldBox tPURPLE "Installing IIgs ${ARCH}"
mkdir -p "${M_IIGS}/ORCA"
chmod 777 "${M_IIGS}/ORCA"
mkdir -p ${G_EHOME}/.ssh
cp -f "${AUTOMATED_GOLDEN_GATE_PUBLIC_KEY}" ${G_EHOME}/.ssh/id_rsa.pub
cp -f "${AUTOMATED_GOLDEN_GATE_PRIVATE_KEY}" ${G_EHOME}/.ssh/id_rsa
touch ${G_EHOME}/.ssh/authorized_keys
touch ${G_EHOME}/.ssh/known_hosts
touch ${G_EHOME}/.ssh/config
chmod go-w ${G_EHOME}
chmod 700 ${G_EHOME}/.ssh
chmod 600 ${G_EHOME}/.ssh/id_rsa
chmod 644 ${G_EHOME}/.ssh/id_rsa.pub
chmod 644 ${G_EHOME}/.ssh/authorized_keys
chmod 644 ${G_EHOME}/.ssh/known_hosts
chmod 644 ${G_EHOME}/.ssh/config
if [[ ! -e "${M_IIGS}/jfsDrive.img" ]]; then
O=${M_IIGS}/mountORCA.sh
echo "#!/bin/bash" > "${O}"
echo "IIGS=${M_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=${M_IIGS}/unmountORCA.sh
echo "#!/bin/bash" > "${O}"
echo "IIGS=${M_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 "${M_IIGS}/jfsDrive.img"
mkfs.jfs -O -q -L IIgs "${M_IIGS}/jfsDrive.img"
fi
"${M_IIGS}/mountORCA.sh"
tSudo chown $(id -ru):$(id -rg) "${M_IIGS}/ORCA/."
if [[ ! -d GoldenGate ]]; then
ssh-keygen -F gitlab.com || ssh-keyscan gitlab.com > ${G_EHOME}/.ssh/known_hosts
git config --global credential.helper cache
git clone https://${AUTOMATED_GOLDEN_GATE_USER_NAME}:${AUTOMATED_GOLDEN_GATE_PASSWORD}@gitlab.com/GoldenGate/GoldenGate.git
fi
if [[ ! -f "${M_IIGS}/iix" ]]; then
pushd GoldenGate
git submodule init
git submodule update
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/installed ..
make
make install
mkdir -p ${M_IIGS}
cp -f bin/{iix,dumpobj,opus-extractor} "${M_IIGS}/."
cd installed
msiextract "${G_EHOME}/${AUTOMATED_GOLDEN_GATE_MSI}"
find -name ".*" -delete
cp -rf GoldenGate/* "${M_IIGS}/ORCA/."
popd
fi
isoinfo -i "${AUTOMATED_OPUS_SOFTWARE_ISO}" -x /FOR_EMUL/BYTEWORK.S\;1 > BYTEWORKS
"${M_IIGS}/opus-extractor" -v BYTEWORKS "${M_IIGS}/ORCA"
rm BYTEWORKS
tFetchGitHubRelease RESULT byteworksinc ORCA-C 2mg
"${M_IIGS}/opus-extractor" -v -s / ${RESULT} "${M_IIGS}/ORCA"
export PATH=${G_ORIGINAL_PATH}:${M_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=${G_ORIGINAL_PATH}
if [[ ! -d cadius ]]; then
git clone https://skunkworks.kangaroopunch.com/mirrors/cadius.git
pushd cadius
make
mkdir -p "${M_IIGS}/cadius"
cp -f bin/release/cadius "${M_IIGS}/cadius/."
popd
fi
if [[ ! -e "${M_IIGS}/ntpconverter/ntpconverter.php" ]]; then
tDownload http://ninjaforce.com/downloads/ntpsources.zip
unzip ntpsources.zip ntpconverter*
mkdir -p "${M_IIGS}/ntpconverter"
mv -f ntpconverter*.php "${M_IIGS}/ntpconverter/."
fi
if [[ ! -e "${M_IIGS}/Tool222#ba0000" ]]; then
tDownload http://www.ninjaforce.com/downloads/ninjatrackerplus_tool222_v1.4.2mg
"${M_CADIUS}" extractfile ninjatrackerplus_tool222_v1.4.2mg NTP.TOOL222V1.4/SYSTEM/TOOLS/TOOL222 .
cp -f "TOOL222#BA0000" "${M_IIGS}/Tool222#ba0000"
fi
"${M_IIGS}/unmountORCA.sh"
if [[ ! -e "${M_IIGS}/jfsDrive.img.backup.tar.bz2" ]]; then
tar cjf "${M_IIGS}/jfsDrive.img.backup.tar.bz2" "${M_IIGS}/jfsDrive.img"
fi
}

47
targets/MacOS.target Normal file
View file

@ -0,0 +1,47 @@
#
# JoeyBuild
# Copyright (C) 2018-2023 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.
#
function architectures() {
echo "x86 x86_64 M1"
}
function buildApplication() {
true
}
function buildJoeyLib() {
true
}
function enabled() {
echo 1
}
function install() {
local ARCH=$1
tBoldBox tPURPLE "Installing MacOS ${ARCH}"
}

47
targets/Windows.target Normal file
View file

@ -0,0 +1,47 @@
#
# JoeyBuild
# Copyright (C) 2018-2023 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.
#
function architectures() {
echo "x86 x86_64"
}
function buildApplication() {
true
}
function buildJoeyLib() {
true
}
function enabled() {
echo 1
}
function install() {
local ARCH=$1
tBoldBox tPURPLE "Installing Windows ${ARCH}"
}