diff --git a/joeybuild.sh b/joeybuild.sh index 3e17a07..d2e4369 100755 --- a/joeybuild.sh +++ b/joeybuild.sh @@ -27,16 +27,16 @@ # -G_HTTP_PORT=6502 # Port to use for HTTP server. Must be > 1024. -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. -G_TARGET= # Current target. -G_BUILD_PROJECT= -G_BUILD_PLATFORMS= -G_BUILD_RESULTS= +G_HTTP_PORT=6502 # Port to use for HTTP server. Must be > 1024. +G_TITLE="JoeyBuild" # Title of application. +G_ORIGINAL_PATH=${PATH} # Original system path. +G_EHOME= # Home for this user. +G_SRC= # Location of JoeyLib source. +G_TEMP= # Directory to store temporary data. +G_TARGET= # Current target. +G_BUILD_PROJECT= # Used by build. +G_BUILD_PLATFORMS= # Used by build. +G_BUILD_RESULTS= # Used by build. function addBuildUser() { @@ -251,8 +251,11 @@ function doInstall() { # Start build server on reboot. if [[ ! -f /etc/rc.local ]]; then echo "#!/bin/bash" | tSudo tee /etc/rc.local > /dev/null - echo "sudo -i -u $(logname) ${BASH_SOURCE[0]} server &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null + #echo "sudo -iHu ${USER} ${BASH_SOURCE[0]} server &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null + echo "cd /home/${USER}" | tSudo tee -a /etc/rc.local > /dev/null + echo "${BASH_SOURCE[0]} server ${USER} &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null echo "exit 0" | tSudo tee -a /etc/rc.local > /dev/null + tSudo chmod +x /etc/rc.local fi } @@ -270,7 +273,7 @@ function rebuildJoeyLib() { mkdir -p dist cp -f ${G_SRC}/joey.h dist/. mkdir -p dist/3rdparty/memwatch - cp -f ${G_SRC}/3rdparty/memwatch/* dist/3rdparty/memwatch/. + cp -f ${G_SRC}/3rdparty/memwatch/memwatch.h dist/3rdparty/memwatch/. } @@ -279,12 +282,28 @@ function startup() { local ACTION=$1 local NAME="$(basename $0)" + # Don't allow anything other than "server" to run as root. + if [[ ${EUID} -eq 0 ]]; then + if [[ "${ACTION}" != "server" ]]; then + echo "Do not run this script as root." + exit 1 + fi + # We're running as root, so use specified G_EHOME. + G_EHOME="$(getent passwd ${2} | cut -d: -f6)" + else + # Not root, use standard G_EHOME. + G_EHOME="$(getent passwd ${USER} | cut -d: -f6)" + fi + + G_SRC="${G_EHOME}/joeylib/joeylib/src" + G_TEMP="${G_EHOME}/temp" + # 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. + # This should be the only use of non-Towel sudo. sudo apt-get -y install git fi echo "Downloading towel.sh support library..." @@ -297,12 +316,6 @@ function startup() { # 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 - # Do we have a config file? if [[ ! -f "${G_EHOME}/joeybuild.config" ]]; then tBoldBox tRED "Cannot find joeybuild.config file!" @@ -311,9 +324,6 @@ function startup() { source "${G_EHOME}/joeybuild.config" tSudoSetPassword "${CONFIG_SUDO}" - # Be sure we can silently sudo. (for mountORCA) - tSudo - case ${ACTION} in add) addBuildUser "${2}" "${3}" @@ -347,7 +357,7 @@ function startup() { echo "${NAME} del USER" echo "${NAME} install" echo "${NAME} rebuild" - echo "${NAME} server" + echo "${NAME} server USER" #set -x ;; esac @@ -361,11 +371,14 @@ function startBuildServer() { local ARCHS= local DESCRIPTION= local USERNAME= + local LOG=${G_EHOME}/joeybuild.log + + # NOTE: This function is run as root! cd ${G_EHOME} # Log startup. - echo "$(date) - Startup ${0}" >> joeybuild.log + echo "$(date) - Startup ${0}" >> ${LOG} # Build supported project types and target details for JoeyDev. echo "1.0" > dist/joeydev.info @@ -383,7 +396,7 @@ function startBuildServer() { done # Start the PHP web server if it's not already running. - php -S 0.0.0.0:${G_HTTP_PORT} -t dist >> joeybuild.log 2>&1 & + php -S 0.0.0.0:${G_HTTP_PORT} -t dist >> ${LOG} 2>&1 & # Start the actual build server. cd /home @@ -400,7 +413,7 @@ function startBuildServer() { # Handle building JoeyLib Applications. if [[ -f "${USERNAME}/build/build.start" ]]; then - # Are there old reults to clean up? + # Are there old results to clean up? if [[ -f build.tar.bz2 ]]; then rm build.tar.bz2 fi @@ -408,7 +421,7 @@ function startBuildServer() { doBuild ${USERNAME} # Log it. - echo "$(date) - Compiled ${G_BUILD_PROJECT} for ${USERNAME} on ${G_BUILD_PLATFORMS}" >> joeybuild.log + echo "$(date) - Compiled ${G_BUILD_PROJECT} for ${USERNAME} on ${G_BUILD_PLATFORMS}" >> ${LOG} fi done diff --git a/targets/IIgs.target b/targets/IIgs.target index 3f36bbb..40fae41 100644 --- a/targets/IIgs.target +++ b/targets/IIgs.target @@ -368,11 +368,15 @@ function package() { function setCompiler() { export PATH=${G_ORIGINAL_PATH}:${M_IIGS} + # Be sure we can silently sudo. (Not tSudo - for mountORCA) + tSudo "${M_IIGS}/mountORCA.sh" &> /dev/null } function unSetCompiler() { + # Be sure we can silently sudo. (Not tSudo - for unmountORCA) + tSudo "${M_IIGS}/unmountORCA.sh" &> /dev/null export PATH=${G_ORIGINAL_PATH} } diff --git a/targets/MacOS.target b/targets/MacOS.target index 181313f..644d443 100644 --- a/targets/MacOS.target +++ b/targets/MacOS.target @@ -129,14 +129,16 @@ function install() { local PASS=$2 # Debug is the first pass, so build our toolchains then. - if [[ "${PASS}" == "debug" ]]; then - if [[ "${ARCH}" == "aarch64" ]]; then + if [[ "${ARCH}" == "aarch64" ]]; then + if [[ "${PASS}" == "debug" ]]; then buildMacOSXToolchain "${CONFIG_MACOS_SDK_11_3}" "${CONFIG_XCODE_12_5_1_XIP}" macos-apple - SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57 - else - buildMacOSXToolchain "${CONFIG_MACOS_SDK_10_13}" "${CONFIG_XCODE_9_4_1_XIP}" macos-intel - SDL2_TAG=25f9ed87ff6947d9576fc9d79dee0784e638ac58 fi + SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57 + else + if [[ "${PASS}" == "debug" ]]; then + buildMacOSXToolchain "${CONFIG_MACOS_SDK_10_13}" "${CONFIG_XCODE_9_4_1_XIP}" macos-intel + fi + SDL2_TAG=25f9ed87ff6947d9576fc9d79dee0784e638ac58 fi setCompiler ${ARCH} ${PASS}