This PR is an extensive revamp of the loadup scripts including the following changes: New omnibus script scripts/loadup which is meant to be the single interface to the loadup system. The man page for this script can be found here: https://online.interlisp.org/downloads/man_loadup.html The new loadup script allows you to restart the loadup process from any particular stage - init, mid, lisp, full, etc. For example, you can start the loadup from an existing init-mid.sysout and have it run thru creating the full.sysout. The call for this would be: ./scripts/loadup --target full --start mid. (See man page for all options to the loadup script as well as examples of their use.) In order to facilitate this target/start feature, the loadup workdir has been moved to a single location per MEDLEYDIR, specifically to MEDLEDIR/loadups/build. (Previously, it was different for every invocation in /tmp/loadups-$$) When restarting the loadup from, say, lisp.sysout, the script will look for the lisp.sysout to start from first in MEDLEYDIR/loadups and then in MEDLEYDIR/loadups/build. If the starting sysout is found in loadups, it will be copied (non-versioned) into the workdir before doing the loadup, overwriting whatever is already there. There is now a lock (MEDLEYDIR/loadups/build/lock) that prevents concurrent loadups from running (and very occassionally needs to be manually removed). At successful completion of a loadup run, the created .sysouts and other files are moved into the loadups directory as before (unless the --nocopy option is specified). BUT the build files - including the dribble files - are left in the working directory (i.e., in loadups/build) The loadup script now supersedes the former loadup-all.sh, loadup-full.sh and loadup-db.sh scripts. But I have left in their place scripts that call the new loadup script with the right options. loadup-all.sh is now just a link to the single loadup script, who's options are (hopefully) a superset of loadup-all.sh. All of the worker scripts (e.g., loadup-full-from-lisp.sh) have been updated to use better mechanisms to catch and report errors, including the new (LOGOUT T EXITCODE) feature. The main script has been updated to better catch errors in these worker scripts when they do happen. You can now specify a MAIKODIR for the loadup, either using the MAIKODIR env variable or thru the --maikodir command line option. All of the loadup scripts have been moved down one level into scripts/loadups. But there are links from the scripts/ directory into the scripts/loadups directory for all of the top-level legacy scripts - loadup-all.sh, loadup-db.sh, loadup-full.sh so that you do not have to change your own scripts unless you need to use some of the new features. More importantly, none of the github workflows need to change right now. The SYSOUTCOMMITS mechanism had to be changed since there is no guarantee that e.g., lisp.sysout and full.sysout are built on the same commit. So (ASSOC 'MEDLEY SYSOUTCOMMITS) now returns an assoc list of sysouts, e.g., ((INIT "aaa")(LISP "bbb")(FULL "ccc")(APPS "ddd")), showing the commits for the various layers of the loadup. The new loadup scheme allows different sysouts to be created from different commits, so there is an issue with RDSYS (and RDSYS.LCOM) being out of sync with one or more of the sysout in loadups. RDSYS(.LCOM) are copied into library when ever a loadup of the Init stage completes successfully (unless the -nocopy option is specified). The only way to solve this issue when it arises is to do a complete loadup from starter.sysout to full.sysout (or apps.sysout) to ensure evrything is built on the same commit.
111 lines
3.7 KiB
Bash
Executable File
111 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Redirect loadup-db.sh to omnibus loadup script
|
|
#
|
|
main() {
|
|
|
|
"${LOADUP_SCRIPTDIR}"/loadup -db
|
|
|
|
}
|
|
|
|
# shellcheck disable=SC2164,SC2034
|
|
if [ -z "${LOADUP_SCRIPTDIR}" ]
|
|
then
|
|
#
|
|
#
|
|
# Some functions to determine what directory this script is being executed from
|
|
#
|
|
#
|
|
get_abs_filename() {
|
|
# $1 : relative filename
|
|
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
|
}
|
|
|
|
# This function taken from
|
|
# https://stackoverflow.com/questions/29832037/how-to-get-script-directory-in-posix-sh
|
|
rreadlink() (
|
|
|
|
# Execute this function in a *subshell* to localize variables and the effect of `cd`.
|
|
|
|
target=$1
|
|
fname=
|
|
targetDir=
|
|
CDPATH=
|
|
|
|
# Try to make the execution environment as predictable as possible:
|
|
# All commands below are invoked via `command`, so we must make sure that `command`
|
|
# itself is not redefined as an alias or shell function.
|
|
# (Note that command is too inconsistent across shells, so we don't use it.)
|
|
# `command` is a *builtin* in bash, dash, ksh, zsh, and some platforms do not even have
|
|
# an external utility version of it (e.g, Ubuntu).
|
|
# `command` bypasses aliases and shell functions and also finds builtins
|
|
# in bash, dash, and ksh. In zsh, option POSIX_BUILTINS must be turned on for that
|
|
# to happen.
|
|
{ \unalias command; \unset -f command; } >/dev/null 2>&1
|
|
[ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on # make zsh find *builtins* with `command` too.
|
|
|
|
while :; do # Resolve potential symlinks until the ultimate target is found.
|
|
[ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; }
|
|
command cd "$(command dirname -- "$target")" # Change to target dir; necessary for correct resolution of target path.
|
|
fname=$(command basename -- "$target") # Extract filename.
|
|
[ "$fname" = '/' ] && fname='' # !! curiously, `basename /` returns '/'
|
|
if [ -L "$fname" ]; then
|
|
# Extract [next] target path, which may be defined
|
|
# *relative* to the symlink's own directory.
|
|
# Note: We parse `ls -l` output to find the symlink target
|
|
# which is the only POSIX-compliant, albeit somewhat fragile, way.
|
|
target=$(command ls -l "$fname")
|
|
target=${target#* -> }
|
|
continue # Resolve [next] symlink target.
|
|
fi
|
|
break # Ultimate target reached.
|
|
done
|
|
targetDir=$(command pwd -P) # Get canonical dir. path
|
|
# Output the ultimate target's canonical path.
|
|
# Note that we manually resolve paths ending in /. and /.. to make sure we have a normalized path.
|
|
if [ "$fname" = '.' ]; then
|
|
command printf '%s\n' "${targetDir%/}"
|
|
elif [ "$fname" = '..' ]; then
|
|
# Caveat: something like /var/.. will resolve to /private (assuming /var@ -> /private/var), i.e. the '..' is applied
|
|
# AFTER canonicalization.
|
|
command printf '%s\n' "$(command dirname -- "${targetDir}")"
|
|
else
|
|
command printf '%s\n' "${targetDir%/}/$fname"
|
|
fi
|
|
)
|
|
|
|
get_script_dir() {
|
|
|
|
# call this with $0 (from main script) as its (only) parameter
|
|
# if you need to preserve cwd, run this is a subshell since
|
|
# it can change cwd
|
|
|
|
# set -x
|
|
|
|
local_SCRIPT_PATH="$( get_abs_filename "$1" )";
|
|
|
|
while [ -h "$local_SCRIPT_PATH" ];
|
|
do
|
|
cd "$( dirname -- "$local_SCRIPT_PATH"; )";
|
|
local_SCRIPT_PATH="$( rreadlink "$local_SCRIPT_PATH" )";
|
|
done
|
|
|
|
cd "$( dirname -- "$local_SCRIPT_PATH"; )" > '/dev/null';
|
|
local_SCRIPT_PATH="$( pwd; )";
|
|
|
|
# set +x
|
|
|
|
echo "${local_SCRIPT_PATH}"
|
|
}
|
|
|
|
# end of script directory functions
|
|
###############################################################################
|
|
|
|
# figure out the script dir
|
|
LOADUP_SCRIPTDIR="$(get_script_dir "$0")"
|
|
export LOADUP_SCRIPTDIR
|
|
|
|
fi
|
|
|
|
main "$@"
|