User management and first pass at IIgs project compiling.
This commit is contained in:
parent
bd1b158a87
commit
9c43a9a247
1 changed files with 311 additions and 45 deletions
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
SRC=${HOME}/joeylib/joeylib/src
|
SRC=${HOME}/joeylib/joeylib/src
|
||||||
IIGS=${HOME}/cross/gsos-wdc-orca
|
IIGS=${HOME}/cross/gsos-wdc-orca
|
||||||
|
CADIUS=${IIGS}/cadius/cadius
|
||||||
SDL2_OLD=25f9ed87ff6947d9576fc9d79dee0784e638ac58
|
SDL2_OLD=25f9ed87ff6947d9576fc9d79dee0784e638ac58
|
||||||
SDL2_NEW=97a5e744497ff7cc93edc5119d67cad3ee86dd57
|
SDL2_NEW=97a5e744497ff7cc93edc5119d67cad3ee86dd57
|
||||||
OLD_PATH=${PATH}
|
OLD_PATH=${PATH}
|
||||||
|
@ -31,6 +32,22 @@ OLD_PATH=${PATH}
|
||||||
export GOLDEN_GATE=${IIGS}/ORCA
|
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() {
|
function buildIIgsSDK() {
|
||||||
local GGATE=$1
|
local GGATE=$1
|
||||||
local ORCA=$2
|
local ORCA=$2
|
||||||
|
@ -168,6 +185,8 @@ function buildIIgsSDK() {
|
||||||
|
|
||||||
|
|
||||||
function buildJoeyLib() {
|
function buildJoeyLib() {
|
||||||
|
local OUT=
|
||||||
|
|
||||||
OLD_CFLAGS=${CFLAGS}
|
OLD_CFLAGS=${CFLAGS}
|
||||||
|
|
||||||
if [[ ! -d joeylib ]]; then
|
if [[ ! -d joeylib ]]; then
|
||||||
|
@ -180,7 +199,7 @@ function buildJoeyLib() {
|
||||||
pushd dist/${NAME}-${ARCH}
|
pushd dist/${NAME}-${ARCH}
|
||||||
case ${BACKEND} in
|
case ${BACKEND} in
|
||||||
orca)
|
orca)
|
||||||
local OUT=${GOLDEN_GATE}/out/joey
|
OUT=${GOLDEN_GATE}/out/joey
|
||||||
rm -rf ${OUT} && true
|
rm -rf ${OUT} && true
|
||||||
mkdir -p ${OUT}/out/joey
|
mkdir -p ${OUT}/out/joey
|
||||||
pushd ${SRC}
|
pushd ${SRC}
|
||||||
|
@ -248,7 +267,8 @@ function buildSDL2() {
|
||||||
git checkout ${TAG}
|
git checkout ${TAG}
|
||||||
popd
|
popd
|
||||||
|
|
||||||
clearBuild
|
rm -rf build && true
|
||||||
|
mkdir -p build
|
||||||
|
|
||||||
pushd build
|
pushd build
|
||||||
../SDL/configure \
|
../SDL/configure \
|
||||||
|
@ -267,21 +287,221 @@ function buildSDL2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function clearBuild() {
|
function configureSFTP() {
|
||||||
rm -rf build && true
|
if [[ ! -f /etc/ssh/sftponly_ready ]]; then
|
||||||
mkdir -p build
|
sudo addgroup sftponly && true
|
||||||
|
sudo sed -i 's/^Subsystem/#Subsystem/g' 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 configureSFTP() {
|
function delBuildUser() {
|
||||||
sudo addgroup sftponly && true
|
local USER=$1
|
||||||
echo "Match Group sftponly" | sudo tee /etc/ssh/sshd_config.d/sftponly.conf
|
|
||||||
echo -e "\tChrootDirectory %h" | sudo tee -a /etc/ssh/sshd_config.d/sftponly.conf
|
sudo userdel -f -r ${USER}
|
||||||
echo -e "\tForceCommand internal-sftp" | sudo tee -a /etc/ssh/sshd_config.d/sftponly.conf
|
}
|
||||||
echo -e "\tAllowTcpForwarding no" | sudo tee -a /etc/ssh/sshd_config.d/sftponly.conf
|
|
||||||
echo -e "\tX11Forwarding no" | sudo tee -a /etc/ssh/sshd_config.d/sftponly.conf
|
|
||||||
sudo systemctl restart sshd
|
function doBuild() {
|
||||||
# Read for user creation: https://askubuntu.com/questions/134425/how-can-i-chroot-sftp-only-ssh-users-into-their-homes
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,46 +643,92 @@ function setCompiler() {
|
||||||
|
|
||||||
|
|
||||||
function scriptIsDownloaded() {
|
function scriptIsDownloaded() {
|
||||||
local GGUSER=$1
|
local ACTION=$1
|
||||||
local GGPASS=$2
|
|
||||||
|
|
||||||
# updateSystem
|
case ${ACTION} in
|
||||||
# configureSFTP
|
add)
|
||||||
|
addBuildUser "${2}" "${3}"
|
||||||
|
;;
|
||||||
|
|
||||||
# buildIIgsSDK "Golden Gate.msi" "Opus ][ The Software.iso" id_rsa id_rsa.pub "${GGUSER}" "${GGPASS}"
|
build)
|
||||||
# buildMacOSSDK MacOSX10.13.sdk.tar.xz macos-intel
|
doBuild "${2}" "${3}"
|
||||||
# buildMacOSSDK MacOSX11.3.sdk.tar.xz macos-apple
|
;;
|
||||||
|
|
||||||
setCompiler gsos 816
|
del)
|
||||||
buildJoeyLib
|
delBuildUser "${2}"
|
||||||
|
;;
|
||||||
|
|
||||||
# setCompiler linux i386
|
install)
|
||||||
# buildSDL2 ${SDL2_NEW}
|
doInstall "${2}" "${3}"
|
||||||
# buildJoeyLib
|
;;
|
||||||
|
|
||||||
# setCompiler linux x86_64
|
server)
|
||||||
# buildSDL2 ${SDL2_NEW}
|
startBuildServer "${2}"
|
||||||
# buildJoeyLib
|
;;
|
||||||
|
|
||||||
# setCompiler macos i386
|
*)
|
||||||
# buildSDL2 ${SDL2_OLD}
|
echo "${0} add USER PASS"
|
||||||
# buildJoeyLib
|
echo "${0} build DIST SRC"
|
||||||
|
echo "${0} del USER"
|
||||||
|
echo "${0} install GGUSER GGPASS"
|
||||||
|
echo "${0} server DIST"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# setCompiler macos x86_64
|
|
||||||
# buildSDL2 ${SDL2_OLD}
|
|
||||||
# buildJoeyLib
|
|
||||||
|
|
||||||
# setCompiler macos arm
|
function startBuildServer() {
|
||||||
# buildSDL2 ${SDL2_NEW}
|
local DIST=$1
|
||||||
# buildJoeyLib
|
local LOG=/opt/joey/${0}.log
|
||||||
|
local USERNAME=
|
||||||
|
local FILE=
|
||||||
|
|
||||||
# setCompiler windows i386
|
# Log startup.
|
||||||
# buildSDL2 ${SDL2_NEW}
|
echo "$(date) - Startup ${0}" >> ${LOG}
|
||||||
# buildJoeyLib
|
|
||||||
|
|
||||||
# setCompiler windows x86_64
|
cd /home
|
||||||
# buildSDL2 ${SDL2_NEW}
|
|
||||||
# buildJoeyLib
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,4 +780,4 @@ function updateSystem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scriptIsDownloaded "$1" "$2"
|
scriptIsDownloaded "$1" "$2" "$3"
|
||||||
|
|
Loading…
Add table
Reference in a new issue