Extensive loadup scripts revamp (#2111)
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.
This commit is contained in:
1
scripts/loadup
Symbolic link
1
scripts/loadup
Symbolic link
@@ -0,0 +1 @@
|
||||
loadups/loadup-all.sh
|
||||
@@ -1,146 +0,0 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
main() {
|
||||
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}/loadup-setup.sh"
|
||||
|
||||
# look thru args looking to see if -apps, --apps, or -a was specified in args
|
||||
apps=""
|
||||
j=1
|
||||
jmax=$#
|
||||
while [ "$j" -le "$jmax" ]
|
||||
do
|
||||
if [ "$(eval "printf %s \${${j}}")" = "-a" ] || \
|
||||
[ "$(eval "printf %s \${${j}}")" = "-apps" ] || \
|
||||
[ "$(eval "printf %s \${${j}}")" = "--apps" ]
|
||||
then
|
||||
apps="-apps"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Do loadup components
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-init.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-mid-from-init.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-lisp-from-mid.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-full-from-lisp.sh" \
|
||||
&& { \
|
||||
if [ -n "${apps}" ]; \
|
||||
then \
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-apps-from-full.sh"; \
|
||||
fi; \
|
||||
} \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-aux.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/copy-all.sh" "${apps}"
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "+++++ loadup-all.sh: SUCCESS +++++"
|
||||
else
|
||||
echo "----- loadup-all.sh: FAILURE -----"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# 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 "$@"
|
||||
1
scripts/loadup-all.sh
Symbolic link
1
scripts/loadup-all.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
loadups/loadup-all.sh
|
||||
@@ -1,123 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
main () {
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}/loadup-setup.sh"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-db-from-full.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/copy-db.sh"
|
||||
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -eq 0 ];
|
||||
then
|
||||
echo "+++++ loadup-db.sh: SUCCESS +++++"
|
||||
else
|
||||
echo "----- loadup-db.sh: FAILURE -----"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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 "$@"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1
scripts/loadup-db.sh
Symbolic link
1
scripts/loadup-db.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
loadups/loadup-db.sh
|
||||
@@ -1,121 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
main() {
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}/loadup-setup.sh"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-init.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-mid-from-init.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-lisp-from-mid.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/loadup-full-from-lisp.sh" \
|
||||
&& /bin/sh "${LOADUP_SCRIPTDIR}/copy-full.sh" ;
|
||||
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -eq 0 ];
|
||||
then
|
||||
echo "+++++ loadup-full.sh: SUCCESS +++++"
|
||||
else
|
||||
echo "----- loadup-full.sh: FAILURE -----"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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 "$@"
|
||||
1
scripts/loadup-full.sh
Symbolic link
1
scripts/loadup-full.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
loadups/loadup-full.sh
|
||||
@@ -1,191 +0,0 @@
|
||||
#!to_be_sourced_only
|
||||
# shellcheck shell=sh
|
||||
|
||||
MEDLEYDIR=$(cd "${LOADUP_SCRIPTDIR}/.."; pwd)
|
||||
export MEDLEYDIR
|
||||
|
||||
if [ -z "${LOADUP_WORKDIR}" ]
|
||||
then
|
||||
LOADUP_WORKDIR=/tmp/loadups-$$
|
||||
export LOADUP_WORKDIR
|
||||
fi
|
||||
|
||||
if [ -z "${LOADUP_SOURCEDIR}" ]
|
||||
then
|
||||
LOADUP_SOURCEDIR="${MEDLEYDIR}/internal/loadups"
|
||||
export LOADUP_SOURCEDIR
|
||||
fi
|
||||
|
||||
if [ -z "${LOADUP_OUTDIR}" ]
|
||||
then
|
||||
LOADUP_OUTDIR="${MEDLEYDIR}/loadups"
|
||||
export LOADUP_OUTDIR
|
||||
fi
|
||||
|
||||
if [ -z "${LOADUP_LOGINDIR}" ]
|
||||
then
|
||||
LOADUP_LOGINDIR="${LOADUP_WORKDIR}/logindir"
|
||||
export LOADUP_LOGINDIR
|
||||
fi
|
||||
|
||||
if [ ! -d "${LOADUP_OUTDIR}" ];
|
||||
then
|
||||
if [ ! -e "${LOADUP_OUTDIR}" ];
|
||||
then
|
||||
mkdir -p "${LOADUP_OUTDIR}"
|
||||
else
|
||||
echo "Error: ${LOADUP_OUTDIR} exists but is not a directory. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d "${LOADUP_WORKDIR}" ];
|
||||
then
|
||||
if [ ! -e "${LOADUP_WORKDIR}" ];
|
||||
then
|
||||
mkdir -p "${LOADUP_WORKDIR}"
|
||||
else
|
||||
echo "Error: ${LOADUP_WORKDIR} exists but is not a directory. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
HAS_GIT= [ -f $(command -v git) ] && [ -x $(command -v git) ]
|
||||
export HAS_GIT
|
||||
|
||||
is_git_dir () {
|
||||
if ${HAS_GIT}
|
||||
then
|
||||
return $(git -C "$1" rev-parse >/dev/null 2>/dev/null; echo $?)
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
git_commit_ID () {
|
||||
if ${HAS_GIT}
|
||||
then
|
||||
if is_git_dir "$1"
|
||||
then
|
||||
# This does NOT indicate if there are any modified files!
|
||||
COMMIT_ID=$(git -C "$1" rev-parse --short HEAD)
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
git_commit_ID "${LOADUP_SOURCEDIR}"
|
||||
LOADUP_COMMIT_ID="${COMMIT_ID}"
|
||||
export LOADUP_COMMIT_ID
|
||||
|
||||
scr="-sc 1024x768 -g 1042x790"
|
||||
geometry=1024x768
|
||||
|
||||
touch "${LOADUP_WORKDIR}"/loadup.timestamp
|
||||
|
||||
script_name=$(basename "$0" ".sh")
|
||||
cmfile="${LOADUP_WORKDIR}/${script_name}.cm"
|
||||
initfile="${LOADUP_WORKDIR}/${script_name}.init"
|
||||
|
||||
# look thru args looking to see if oldschool was specified in args
|
||||
j=1
|
||||
jmax=$#
|
||||
while [ "$j" -le "$jmax" ]
|
||||
do
|
||||
if [ "$(eval "printf %s \${${j}}")" = "-os" ] || [ "$(eval "printf %s \${${j}}")" = "--oldschool" ]
|
||||
then
|
||||
LOADUP_OLDSCHOOL=true
|
||||
export LOADUP_OLDSCHOOL
|
||||
break
|
||||
else
|
||||
j=$(( j + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
######################################################################
|
||||
|
||||
loadup_start () {
|
||||
echo ">>>>> START ${script_name}"
|
||||
if [ -d "${MEDLEYDIR}/tmp" ];
|
||||
then
|
||||
TMP_PRE_EXISTS="true"
|
||||
if [ -d "${MEDLEYDIR}/tmp/logindir" ];
|
||||
then
|
||||
LOGINDIR_PRE_EXISTS="true"
|
||||
else
|
||||
LOGINDIR_PRE_EXISTS="false"
|
||||
fi
|
||||
else
|
||||
LOGINDIR_PRE_EXISTS="false"
|
||||
TMP_PRE_EXISTS="false"
|
||||
fi
|
||||
}
|
||||
|
||||
loadup_finish () {
|
||||
rm -f "${cmfile}"
|
||||
# 2024-05-05 FGH
|
||||
# Can't use exit code for now since on MacOS exit codes appear to be inverted
|
||||
# Will restore once MacOS exit code are figured out
|
||||
# if [ "${exit_code}" -ne 0 ] || [ ! -f "${LOADUP_WORKDIR}/$1" ]
|
||||
if [ ! -f "${LOADUP_WORKDIR}/$1" ]
|
||||
then
|
||||
echo "----- FAILURE -----"
|
||||
exit_code=1
|
||||
else
|
||||
echo "+++++ SUCCESS +++++"
|
||||
exit_code=0
|
||||
fi
|
||||
echo "..... files created ....."
|
||||
if [ -f "${LOADUP_WORKDIR}/$1" ]
|
||||
then
|
||||
shift;
|
||||
for f in "$@"
|
||||
do
|
||||
# shellcheck disable=SC2045,SC2086
|
||||
for ff in $(ls -1 "${LOADUP_WORKDIR}"/$f);
|
||||
do
|
||||
# shellcheck disable=SC2010
|
||||
ls -l "${ff}" 2>/dev/null | grep -v "^.*~[0-9]\+~$"
|
||||
done
|
||||
done
|
||||
fi
|
||||
if [ "${TMP_PRE_EXISTS}" = "false" ];
|
||||
then
|
||||
rm -rf "${MEDLEYDIR}/tmp"
|
||||
else
|
||||
if [ "${LOGINDIR_PRE_EXISTS}" = "false" ];
|
||||
then
|
||||
rm -rf "${MEDLEYDIR}/tmp/logindir"
|
||||
fi
|
||||
fi
|
||||
echo "<<<<< END ${script_name}"
|
||||
echo ""
|
||||
exit ${exit_code}
|
||||
}
|
||||
|
||||
run_medley () {
|
||||
if [ ! "${LOADUP_OLDSCHOOL}" = true ]
|
||||
then
|
||||
/bin/sh "${MEDLEYDIR}/scripts/medley/medley.command" \
|
||||
--config - \
|
||||
--id loadup_+ \
|
||||
--geometry "${geometry}" \
|
||||
--noscroll \
|
||||
--logindir "${LOADUP_LOGINDIR}" \
|
||||
--rem.cm "${cmfile}" \
|
||||
--greet "${initfile}" \
|
||||
--sysout "$1" \
|
||||
"$2" "$3" "$4" "$5" "$6" "$7" ;
|
||||
exit_code=$?
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
"${MEDLEYDIR}/run-medley" ${scr} $2 $3 $4 $5 $6 $7 -loadup "${cmfile}" "$1"
|
||||
exit_code=$?
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
######################################################################
|
||||
|
||||
|
||||
487
scripts/loadups/loadup
Executable file
487
scripts/loadups/loadup
Executable file
@@ -0,0 +1,487 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
main() {
|
||||
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}/loadup-setup.sh"
|
||||
|
||||
# process args
|
||||
start=""
|
||||
start_s=""
|
||||
start_sysout=""
|
||||
end=""
|
||||
end_s=""
|
||||
db=""
|
||||
aux=""
|
||||
nocopy=false
|
||||
thinw=false
|
||||
thinl=false
|
||||
while [ "$#" -ne 0 ];
|
||||
do
|
||||
case "$1" in
|
||||
-t | -target | --target)
|
||||
case "$2" in
|
||||
a | apps | 5)
|
||||
end=5
|
||||
end_s=apps
|
||||
aux=true
|
||||
;;
|
||||
a- | apps- | 5-)
|
||||
end=5
|
||||
end_s=apps
|
||||
;;
|
||||
f | full | 4)
|
||||
end=4
|
||||
end_s=full
|
||||
;;
|
||||
l | lisp | 3)
|
||||
end=3
|
||||
end_s=lisp
|
||||
;;
|
||||
m | mid | 2)
|
||||
end=2
|
||||
end_s=mid
|
||||
;;
|
||||
i | init |1)
|
||||
end=1
|
||||
end_s=init
|
||||
;;
|
||||
*)
|
||||
output_error_msg "Error: unknown parameter to --start (-s) flag: $2${EOL}Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
;;
|
||||
-s | -start | --start)
|
||||
case "$2" in
|
||||
s | scratch | 0)
|
||||
start=0
|
||||
start_s=scratch
|
||||
start_sysout=starter.sysout
|
||||
;;
|
||||
i | init | 1)
|
||||
start=1
|
||||
start_s=init
|
||||
start_sysout=init.dlinit
|
||||
;;
|
||||
m | mid | 2)
|
||||
start=2
|
||||
start_s=mid
|
||||
start_sysout=init-mid.sysout
|
||||
;;
|
||||
l | lisp | 3)
|
||||
start=3
|
||||
start_s=lisp
|
||||
start_sysout=lisp.sysout
|
||||
;;
|
||||
f | full | 4)
|
||||
start=4
|
||||
start_s=full
|
||||
start_sysout=full.sysout
|
||||
;;
|
||||
*)
|
||||
output_error_msg "Error: unknown parameter to --start (-s) flag: $2${EOL}Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
;;
|
||||
-x | -aux | --aux)
|
||||
aux=true
|
||||
;;
|
||||
-b | -db | --db)
|
||||
db=true
|
||||
;;
|
||||
-a | -apps | --apps | -5)
|
||||
end=5
|
||||
end_s=apps
|
||||
aux=true
|
||||
;;
|
||||
-a- | -apps- | --apps- | -5-)
|
||||
end=5
|
||||
end_s=apps
|
||||
;;
|
||||
-f | -full | --full | -4)
|
||||
end=4
|
||||
end_s=full
|
||||
;;
|
||||
-l | -lisp | --lisp | -3)
|
||||
end=3
|
||||
end_s=lisp
|
||||
;;
|
||||
-m | -mid | --mid | -2)
|
||||
end=2
|
||||
end_s=mid
|
||||
;;
|
||||
-i | -init | --init | -1)
|
||||
end=1
|
||||
end_s=init
|
||||
;;
|
||||
-nc | -nocopy | --nocopy)
|
||||
nocopy=true
|
||||
;;
|
||||
-tw | -thinw | --thinw)
|
||||
thinw=true
|
||||
;;
|
||||
-tl | -thinl | --thinl)
|
||||
thinl=true
|
||||
;;
|
||||
-d | -maikodir | --maikodir)
|
||||
if [ -n "$2" ]
|
||||
then
|
||||
maikodir=$(cd "$2" 2>/dev/null && pwd)
|
||||
if [ -z "${maikodir}" ] || [ ! -d "${maikodir}" ]
|
||||
then
|
||||
output_error_msg "Error: In --maikodir (-d) command line argument, \"$2\" is not an existing directory.${EOL}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
output_error_msg "Error: Missing value for the --maikodir (-d) command line argument.${EOL}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
export MAIKODIR="${maikodir}"
|
||||
shift
|
||||
;;
|
||||
--noendmsg)
|
||||
noendmsg=true
|
||||
;;
|
||||
-z | -man | --man )
|
||||
if [ "$(uname)" = "Darwin" ]
|
||||
then
|
||||
/usr/bin/man "${LOADUP_SOURCEDIR}/man-page/loadup.1.gz"
|
||||
else
|
||||
/usr/bin/man -l "${LOADUP_SOURCEDIR}/man-page/loadup.1.gz"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
output_error_msg "Error: unknown flag: $1${EOL}Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
#
|
||||
#
|
||||
# check arguments
|
||||
#
|
||||
#
|
||||
|
||||
no_loadups=false
|
||||
|
||||
#
|
||||
# check for no args or only maikodir arg and set defaults appropriately
|
||||
#
|
||||
if [ -z "${start}" ] && [ -z "${end}" ] && [ -z "${aux}" ] && [ -z "${db}" ]
|
||||
then
|
||||
end=4
|
||||
end_s=full
|
||||
start=0
|
||||
start_s=scratch
|
||||
start_sysout=starter.sysout
|
||||
aux=true
|
||||
db=false
|
||||
if [ "${thinw}" = true ] || [ "${thinl}" = true ]
|
||||
then
|
||||
no_loadups=true
|
||||
nocopy=true
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# defaults for aux and db
|
||||
#
|
||||
if [ -z "${aux}" ]
|
||||
then
|
||||
aux=false
|
||||
fi
|
||||
if [ -z "${db}" ]
|
||||
then
|
||||
db=false
|
||||
fi
|
||||
|
||||
#
|
||||
# if no start and no end specified, then signal no stages
|
||||
# otherwise if start or end is not specified, set defaults
|
||||
#
|
||||
if [ -z "${start}" ] && [ -z "${end}" ]
|
||||
then
|
||||
start=4
|
||||
start_s=full
|
||||
start_sysout=full.sysout
|
||||
end=-1
|
||||
else
|
||||
if [ -z "${end}" ]
|
||||
then
|
||||
end=4
|
||||
end_s=full
|
||||
fi
|
||||
if [ -z "${start}" ]
|
||||
then
|
||||
start=0
|
||||
start_s=scratch
|
||||
start_sysout=starter.sysout
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# if aux and/or db is set and there is an end, the end must be full (4) or later
|
||||
#
|
||||
if { [ "${aux}" = true ] || [ "${db}" = true ] ; } && [ "${end}" -gt 0 ] && [ "${end}" -lt 4 ]
|
||||
then
|
||||
output_error_msg "Error: either -aux or -db was specified, but the ending sysout specified was \"before\" full (4)${EOL}}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# End has to be greater than start unless $end is -1
|
||||
#
|
||||
if [ $end -ne -1 ] && [ $end -le $start ]
|
||||
then
|
||||
output_error_msg "Error: The final stage ($end_s) comes before or is the same as the start stage ($start_s)${EOL}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# End of args checks
|
||||
#
|
||||
|
||||
|
||||
# check and set the run_lock
|
||||
check_run_lock
|
||||
|
||||
# if requested, thin the loadups and workdirs by eliminating all versioned (*.~[0-9]*~) files
|
||||
# from these directories
|
||||
if [ "${thinw}" = true ]
|
||||
then
|
||||
"${LOADUP_SCRIPTDIR}"/thin_loadups.sh w
|
||||
fi
|
||||
if [ "${thinl}" = true ]
|
||||
then
|
||||
"${LOADUP_SCRIPTDIR}"/thin_loadups.sh l
|
||||
fi
|
||||
|
||||
# find and place starting sysout
|
||||
if [ $start -gt 0 ]
|
||||
then
|
||||
if [ ! -f "${LOADUP_WORKDIR}"/"${start_sysout}" ]
|
||||
then
|
||||
if [ -f "${LOADUP_OUTDIR}"/"${start_sysout}" ]
|
||||
then
|
||||
cp -p "${LOADUP_OUTDIR}"/"${start_sysout}" "${LOADUP_WORKDIR}"/"${start_sysout}"
|
||||
else
|
||||
output_error_msg "Error: Cannot find starting sysout (${start_sysout}) in either ${LOADUP_OUTDIR} or ${LOADUP_WORKDIR}${EOL}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Do individual loadups as requested
|
||||
#
|
||||
|
||||
if [ "${no_loadups}" = false ]
|
||||
then
|
||||
if [ $start -lt 1 ] && [ $end -ge 1 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-init.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
|
||||
if [ $start -lt 2 ] && [ $end -ge 2 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-mid-from-init.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
|
||||
if [ $start -lt 3 ] && [ $end -ge 3 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-lisp-from-mid.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
|
||||
if [ $start -lt 4 ] && [ $end -ge 4 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-full-from-lisp.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
|
||||
if [ $start -lt 5 ] && [ $end -ge 5 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-apps-from-full.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
|
||||
if [ "${aux}" = true ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-aux.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
|
||||
if [ "${db}" = true ]
|
||||
then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-db-from-full.sh"
|
||||
exit_if_failure $? "${noendmsg}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Done with loadups, successfully. Now copy files into loadups dir from workdir
|
||||
#
|
||||
|
||||
if [ "${nocopy}" = false ]
|
||||
then
|
||||
|
||||
if [ $start -eq 0 ] && [ $end -ge 1 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/RDSYS "${MEDLEYDIR}/library" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/RDSYS.LCOM "${MEDLEYDIR}/library" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ $start -le 2 ] && [ $end -ge 3 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/lisp.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ $start -le 3 ] && [ $end -ge 4 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/full.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ $start -le 4 ] && [ $end -ge 5 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/apps.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ "${aux}" = true ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/whereis.hash "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/exports.all "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ "${db}" = true ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.database "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
echo "+++++ loadup: SUCCESS +++++"
|
||||
remove_run_lock
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
|
||||
# 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 "$@"
|
||||
1
scripts/loadups/loadup-all.sh
Symbolic link
1
scripts/loadups/loadup-all.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
loadup
|
||||
@@ -32,39 +32,43 @@ main() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git_commit_ID "${NOTECARDSDIR}"
|
||||
NOTECARDS_COMMIT_ID="${COMMIT_ID}"
|
||||
export NOTECARDS_COMMIT_ID
|
||||
git_commit_ID "${NOTECARDSDIR}"
|
||||
NOTECARDS_COMMIT_ID="${COMMIT_ID}"
|
||||
export NOTECARDS_COMMIT_ID
|
||||
|
||||
initfile="-"
|
||||
cat >"${cmfile}" <<-"EOF"
|
||||
cat >"${cmfile}" <<-EOF
|
||||
"
|
||||
|
||||
(PROGN
|
||||
(IL:MEDLEY-INIT-VARS 'IL:GREET)
|
||||
(IL:DRIBBLE (IL:CONCAT (QUOTE {DSK})(IL:UNIX-GETENV (QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /apps.dribble))))
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE ROOMSDIR))(QUOTE /ROOMS)) 'IL:SYSLOAD)
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE NOTECARDSDIR))(QUOTE |/system/NOTECARDS.LCOM|)) 'IL:SYSLOAD)
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE CLOSDIR))(QUOTE /DEFSYS.DFASL)) 'IL:SYSLOAD)
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE MEDLEYDIR))(QUOTE |lispusers/BUTTONS.LCOM|)) 'IL:SYSLOAD)
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_SOURCEDIR)) (QUOTE /LOADUP-APPS.LCOM)) 'IL:SYSLOAD)
|
||||
(IL:PRINT (IL:UNIX-GETENV (QUOTE NOTECARDS_COMMIT_ID)))
|
||||
(IL:PUTASSOC (QUOTE IL:MEDLEY) (LIST (IL:UNIX-GETENV (QUOTE LOADUP_COMMIT_ID))) IL:SYSOUTCOMMITS)
|
||||
(IL:PUTASSOC (QUOTE IL:NOTECARDS) (LIST (IL:UNIX-GETENV (QUOTE NOTECARDS_COMMIT_ID))) IL:SYSOUTCOMMITS)
|
||||
(IL:PRINT IL:SYSOUTCOMMITS)
|
||||
(IL:HARDRESET)
|
||||
(SETQ IL:LOADUP-SUCCESS
|
||||
(${NL_ER_SETQ}
|
||||
(PROGN
|
||||
(SETQ IL:HELPFLAG ${HELPFLAG})
|
||||
(IL:MEDLEY-INIT-VARS 'IL:GREET)
|
||||
(IL:DRIBBLE
|
||||
(IL:CONCAT (QUOTE {DSK})(IL:UNIX-GETENV (QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /apps.dribble)))
|
||||
)
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_SOURCEDIR))(QUOTE /LOADUP-CLOS.LCOM)))
|
||||
(IL:LOADUP-CLOS)
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_SOURCEDIR))(QUOTE /LOADUP-APPS.LCOM)))
|
||||
(IL:LOADUP-APPS)
|
||||
(IL:DRIBBLE)
|
||||
)
|
||||
)
|
||||
)
|
||||
SHH
|
||||
(PROGN
|
||||
(IL:ENDLOADUP)
|
||||
(CLOS::LOAD-CLOS)
|
||||
(IL:|Apps.LOADUP|)
|
||||
(IL:DRIBBLE)
|
||||
(IL:MAKESYS
|
||||
(IL:CONCAT (QUOTE {DSK})(IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /apps.sysout)))
|
||||
:APPS)
|
||||
(COND
|
||||
(IL:LOADUP-SUCCESS
|
||||
(IL:ENDLOADUP)
|
||||
(SETQ IL:HELPFLAG T)
|
||||
(SETQ IL:LOADUP-SUCCESS (QUOTE NOBIND))
|
||||
(IL:MAKESYS
|
||||
(IL:CONCAT (QUOTE {DSK})(IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR)) (IL:L-CASE (QUOTE /apps.sysout)))
|
||||
:APPS
|
||||
)
|
||||
(IL:LOGOUT T 0)
|
||||
)
|
||||
)
|
||||
(IL:LOGOUT T)
|
||||
(IL:LOGOUT T 1)
|
||||
|
||||
"
|
||||
EOF
|
||||
@@ -72,6 +76,7 @@ main() {
|
||||
run_medley "${LOADUP_WORKDIR}/full.sysout"
|
||||
|
||||
loadup_finish "apps.sysout" "apps.*"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,22 +11,25 @@ main() {
|
||||
initfile="-"
|
||||
cat >"${cmfile}" <<-"EOF"
|
||||
"
|
||||
|
||||
(SETQ IL:HELPFLAG ${HELPFLAG})
|
||||
(PROG
|
||||
((WORKDIR (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_WORKDIR)) (QUOTE /))))
|
||||
(IL:MEDLEY-INIT-VARS)
|
||||
(IL:LOAD(QUOTE MEDLEY-UTILS))
|
||||
(DRIBBLE (QUOTE {DSK}<TMP>FOOBAR))
|
||||
(IL:LOAD (QUOTE MEDLEY-UTILS))
|
||||
(IL:DRIBBLE (IL:CONCAT WORKDIR (IL:L-CASE (QUOTE exports.dribble))))
|
||||
(IL:MAKE-EXPORTS-ALL (IL:CONCAT WORKDIR (IL:L-CASE (QUOTE exports.all))))
|
||||
(DRIBBLE)
|
||||
(IL:DRIBBLE)
|
||||
(IL:PUTASSOC (QUOTE IL:MEDLEY) (LIST (IL:UNIX-GETENV (QUOTE LOADUP_COMMIT_ID))) IL:SYSOUTCOMMITS)
|
||||
(IL:MAKE-WHEREIS-HASH
|
||||
(IL:CONCAT WORKDIR (IL:L-CASE (QUOTE whereis.dribble)))
|
||||
(IL:CONCAT WORKDIR (IL:L-CASE (QUOTE whereis.hash-tmp)))
|
||||
(IL:CONCAT WORKDIR (IL:L-CASE (QUOTE whereis.hash)))
|
||||
NIL NIL
|
||||
)
|
||||
(IL:LOGOUT T)
|
||||
(IL:LOGOUT T 0)
|
||||
)
|
||||
(IL:LOGOUT T 1)
|
||||
|
||||
"
|
||||
EOF
|
||||
|
||||
@@ -9,7 +9,7 @@ main() {
|
||||
SYSOUT="${MEDLEYDIR}/loadups/full.sysout"
|
||||
if [ ! -f "${SYSOUT}" ];
|
||||
then
|
||||
echo "Error: cannot find ${SYSOUT}. Exiting."
|
||||
output_error_msg "Error: cannot find ${SYSOUT}.${EOL}Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -17,6 +17,7 @@ main() {
|
||||
cat >"${cmfile}" <<-"EOF"
|
||||
"
|
||||
|
||||
(SETQ IL:HELPFLAG ${HELPFLAG})
|
||||
(PROG
|
||||
((WORKDIR (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_WORKDIR)) (QUOTE /))))
|
||||
(SETQ IL:SYSOUTCOMMITS (LIST (LIST (QUOTE IL:MEDLEY) (IL:UNIX-GETENV (QUOTE LOADUP_COMMIT_ID)))))
|
||||
@@ -28,8 +29,9 @@ main() {
|
||||
(IL:CONCAT WORKDIR (IL:L-CASE (QUOTE fuller.database)))
|
||||
(IL:CONCAT WORKDIR (IL:L-CASE (QUOTE fuller.sysout)))
|
||||
)
|
||||
(IL:LOGOUT T)
|
||||
(IL:LOGOUT T 0)
|
||||
)
|
||||
(IL:LOGOUT T 1)
|
||||
|
||||
"
|
||||
EOF
|
||||
110
scripts/loadups/loadup-db.sh
Executable file
110
scripts/loadups/loadup-db.sh
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/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 "$@"
|
||||
@@ -7,21 +7,32 @@ main() {
|
||||
loadup_start
|
||||
|
||||
initfile="-"
|
||||
cat >"${cmfile}" <<-"EOF"
|
||||
cat >"${cmfile}" <<-EOF
|
||||
"
|
||||
|
||||
(PROGN
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_SOURCEDIR))(QUOTE /LOADUP-FULL.LCOM)))
|
||||
(IL:LOADUP-FULL (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /full.dribble))))
|
||||
(IL:PUTASSOC (QUOTE IL:MEDLEY) (LIST (IL:UNIX-GETENV (QUOTE LOADUP_COMMIT_ID))) IL:SYSOUTCOMMITS)
|
||||
(IL:HARDRESET)
|
||||
)
|
||||
SHH
|
||||
(PROGN
|
||||
(IL:ENDLOADUP)
|
||||
(IL:MAKESYS (IL:CONCAT (QUOTE {DSK})(IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /full.sysout))) :FULL))
|
||||
(IL:LOGOUT T)
|
||||
(SETQ IL:LOADUP-SUCCESS
|
||||
(${NL_ER_SETQ}
|
||||
(PROGN
|
||||
(SETQ IL:HELPFLAG ${HELPFLAG})
|
||||
(IL:LOAD (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_SOURCEDIR))(QUOTE /LOADUP-FULL.LCOM)))
|
||||
(IL:LOADUP-FULL (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /full.dribble))))
|
||||
(IL:PUTASSOC (QUOTE IL:MEDLEY) (LIST (IL:UNIX-GETENV (QUOTE LOADUP_COMMIT_ID))) IL:SYSOUTCOMMITS)
|
||||
)
|
||||
)
|
||||
)
|
||||
(COND
|
||||
(IL:LOADUP-SUCCESS
|
||||
(IL:ENDLOADUP)
|
||||
(SETQ IL:HELPFLAG T)
|
||||
(SETQ IL:LOADUP-SUCCESS (QUOTE NOBIND))
|
||||
(IL:MAKESYS
|
||||
(IL:CONCAT (QUOTE {DSK})(IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR))(IL:L-CASE (QUOTE /full.sysout)))
|
||||
:FULL
|
||||
)
|
||||
(IL:LOGOUT T 0)
|
||||
)
|
||||
)
|
||||
(IL:LOGOUT T 1)
|
||||
|
||||
"
|
||||
EOF
|
||||
110
scripts/loadups/loadup-full.sh
Executable file
110
scripts/loadups/loadup-full.sh
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Redirect loadup-full.sh to omnibus loadup script
|
||||
#
|
||||
main() {
|
||||
|
||||
"${LOADUP_SCRIPTDIR}"/loadup -target full
|
||||
|
||||
}
|
||||
|
||||
# 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 "$@"
|
||||
@@ -30,7 +30,7 @@ main() {
|
||||
(LOADUP-SOURCE-DIR (CONCAT "{DSK}" (UNIX-GETENV "LOADUP_SOURCEDIR") "/"))
|
||||
)
|
||||
(SETQ DIRECTORIES (CONS LOADUP-SOURCE-DIR DIRECTORIES))
|
||||
(PRINT (DATE))
|
||||
(PRINT (DATE))
|
||||
(PRINT (SETQ SYSOUTCOMMITS (LIST (LIST (QUOTE MEDLEY) (UNIX-GETENV (QUOTE LOADUP_COMMIT_ID))))))
|
||||
(RESETLST (RESETSAVE OK.TO.MODIFY.FNS T)
|
||||
(MAKEINITGREET (CONCAT WORKDIR "init.sysout") (CONCAT WORKDIR "init.dlinit"))
|
||||
@@ -7,23 +7,30 @@ main() {
|
||||
loadup_start
|
||||
|
||||
initfile="-"
|
||||
cat >"${cmfile}" <<-"EOF"
|
||||
cat >"${cmfile}" <<-EOF
|
||||
"
|
||||
|
||||
(PROGN
|
||||
(SETQ LOADUP-SUCCESS NIL)
|
||||
(LOAD (CONCAT (QUOTE {DSK}) (UNIX-GETENV (QUOTE MEDLEYDIR)) (QUOTE /sources/MEDLEYDIR.LCOM)))
|
||||
(MEDLEY-INIT-VARS)
|
||||
(LOAD (CONCAT (QUOTE {DSK}) (UNIX-GETENV (QUOTE LOADUP_SOURCEDIR)) (QUOTE /LOADUP-LISP.LCOM)))
|
||||
(LOADUP-LISP (CONCAT (QUOTE {DSK}) (UNIX-GETENV (QUOTE LOADUP_WORKDIR)) (QUOTE /lisp.dribble)))
|
||||
(PUTASSOC (QUOTE MEDLEY) (LIST (UNIX-GETENV (QUOTE LOADUP_COMMIT_ID))) SYSOUTCOMMITS)
|
||||
(HARDRESET)
|
||||
)
|
||||
SHH
|
||||
(PROGN
|
||||
(IL:ENDLOADUP)
|
||||
(IL:MAKESYS (IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV(QUOTE LOADUP_WORKDIR)) (IL:L-CASE (QUOTE /lisp.sysout))) :LISP)
|
||||
(IL:LOGOUT T)
|
||||
)
|
||||
(SETQ LOADUP-SUCCESS T)
|
||||
(HARDRESET)
|
||||
)
|
||||
(COND
|
||||
(IL:LOADUP-SUCCESS
|
||||
(IL:ENDLOADUP)
|
||||
(SETQ IL:HELPFLAG T)
|
||||
(SETQ IL:LOADUP-SUCCESS (QUOTE NOBIND))
|
||||
(IL:MAKESYS
|
||||
(IL:CONCAT (QUOTE {DSK}) (IL:UNIX-GETENV (QUOTE LOADUP_WORKDIR)) (IL:L-CASE (QUOTE /lisp.sysout)))
|
||||
:LISP)
|
||||
(IL:LOGOUT T 0)
|
||||
)
|
||||
)
|
||||
(IL:LOGOUT T 1)
|
||||
|
||||
"
|
||||
EOF
|
||||
271
scripts/loadups/loadup-setup.sh
Normal file
271
scripts/loadups/loadup-setup.sh
Normal file
@@ -0,0 +1,271 @@
|
||||
#!to_be_sourced_only
|
||||
# shellcheck shell=sh
|
||||
|
||||
MEDLEYDIR=$(cd "${LOADUP_SCRIPTDIR}/../.." || exit; pwd)
|
||||
export MEDLEYDIR
|
||||
|
||||
export LOADUP_CPV="${MEDLEYDIR}/scripts/cpv"
|
||||
|
||||
if [ -z "${LOADUP_SOURCEDIR}" ]
|
||||
then
|
||||
LOADUP_SOURCEDIR="${MEDLEYDIR}/internal/loadups"
|
||||
export LOADUP_SOURCEDIR
|
||||
fi
|
||||
|
||||
if [ -z "${LOADUP_OUTDIR}" ]
|
||||
then
|
||||
LOADUP_OUTDIR="${MEDLEYDIR}/loadups"
|
||||
export LOADUP_OUTDIR
|
||||
fi
|
||||
|
||||
if [ ! -d "${LOADUP_OUTDIR}" ];
|
||||
then
|
||||
if [ ! -e "${LOADUP_OUTDIR}" ];
|
||||
then
|
||||
mkdir -p "${LOADUP_OUTDIR}"
|
||||
else
|
||||
echo "Error: ${LOADUP_OUTDIR} exists but is not a directory. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${LOADUP_WORKDIR}" ]
|
||||
then
|
||||
LOADUP_WORKDIR="${LOADUP_OUTDIR}/build"
|
||||
export LOADUP_WORKDIR
|
||||
fi
|
||||
|
||||
if [ ! -d "${LOADUP_WORKDIR}" ];
|
||||
then
|
||||
if [ ! -e "${LOADUP_WORKDIR}" ];
|
||||
then
|
||||
mkdir -p "${LOADUP_WORKDIR}"
|
||||
else
|
||||
echo "Error: ${LOADUP_WORKDIR} exists but is not a directory. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${LOADUP_LOGINDIR}" ]
|
||||
then
|
||||
LOADUP_LOGINDIR="${LOADUP_WORKDIR}/logindir"
|
||||
export LOADUP_LOGINDIR
|
||||
fi
|
||||
|
||||
if [ ! -d "${LOADUP_LOGINDIR}" ];
|
||||
then
|
||||
if [ ! -e "${LOADUP_LOGINDIR}" ];
|
||||
then
|
||||
mkdir -p "${LOADUP_LOGINDIR}"
|
||||
else
|
||||
echo "Error: ${LOADUP_LOGINDIR} exists but is not a directory. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "$(command -v git)" ] && [ -x "$(command -v git)" ]
|
||||
then
|
||||
export HAS_GIT=true
|
||||
else
|
||||
export HAS_GIT=false
|
||||
fi
|
||||
|
||||
is_git_dir () {
|
||||
if [ "${HAS_GIT}" = true ]
|
||||
then
|
||||
return "$(git -C "$1" rev-parse >/dev/null 2>/dev/null; echo $?)"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
git_commit_ID () {
|
||||
if [ "${HAS_GIT}" = true ]
|
||||
then
|
||||
if is_git_dir "$1"
|
||||
then
|
||||
# This does NOT indicate if there are any modified files!
|
||||
COMMIT_ID="$(git -C "$1" rev-parse --short HEAD)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
git_commit_ID "${LOADUP_SOURCEDIR}"
|
||||
LOADUP_COMMIT_ID="${COMMIT_ID}"
|
||||
export LOADUP_COMMIT_ID
|
||||
|
||||
# obsolete? scr="-sc 1024x768 -g 1042x790"
|
||||
geometry=1024x768
|
||||
|
||||
touch "${LOADUP_WORKDIR}"/loadup.timestamp
|
||||
|
||||
script_name=$(basename "$0" ".sh")
|
||||
cmfile="${LOADUP_WORKDIR}/${script_name}.cm"
|
||||
initfile="${LOADUP_WORKDIR}/${script_name}.init"
|
||||
|
||||
|
||||
# Select whether we use NLSETQ or ERSETQ to wrap the loadup
|
||||
# cm files depending on whether we want to allow breaks or not.
|
||||
# shellcheck disable=SC2034
|
||||
if [ -n "${LOADUP_NOBREAK}" ]
|
||||
then
|
||||
HELPFLAG=NIL
|
||||
NL_ER_SETQ=IL:NLSETQ
|
||||
else
|
||||
HELPFLAG="(QUOTE IL:BREAK!)"
|
||||
NL_ER_SETQ=IL:ERSETQ
|
||||
fi
|
||||
|
||||
######################################################################
|
||||
|
||||
loadup_start () {
|
||||
touch "${LOADUP_WORKDIR}"/timestamp
|
||||
sleep 1
|
||||
echo ">>>>> START ${script_name}"
|
||||
}
|
||||
|
||||
loadup_finish () {
|
||||
|
||||
if [ ! "${cmfile}" = "-" ]; then rm -f "${cmfile}"; fi
|
||||
if [ ! "${initfile}" = "-" ]; then rm -f "${initfile}"; fi
|
||||
|
||||
if [ "${exit_code}" -ne 0 ] || [ ! -f "${LOADUP_WORKDIR}/$1" ] \
|
||||
|| [ ! "$( find "${LOADUP_WORKDIR}/$1" -newer "${LOADUP_WORKDIR}"/timestamp )" ]
|
||||
then
|
||||
output_error_msg "----- FAILURE ${script_name}-----"
|
||||
exit_code=1
|
||||
else
|
||||
echo "+++++ SUCCESS +++++"
|
||||
exit_code=0
|
||||
fi
|
||||
echo "..... files created ....."
|
||||
if [ -f "${LOADUP_WORKDIR}/$1" ]
|
||||
then
|
||||
shift;
|
||||
for f in "$@"
|
||||
do
|
||||
# shellcheck disable=SC2045,SC2086
|
||||
for ff in $(ls -1 "${LOADUP_WORKDIR}"/$f);
|
||||
do
|
||||
# shellcheck disable=SC2010
|
||||
if [ "$( find "${ff}" -newer "${LOADUP_WORKDIR}"/timestamp )" ]
|
||||
then
|
||||
ls -l "${ff}" 2>/dev/null | grep -v "^.*~[0-9]\+~$"
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
echo "<<<<< END ${script_name}"
|
||||
echo ""
|
||||
|
||||
exit ${exit_code}
|
||||
}
|
||||
|
||||
run_medley () {
|
||||
/bin/sh "${MEDLEYDIR}/scripts/medley/medley.command" \
|
||||
--config - \
|
||||
--id loadup_+ \
|
||||
--geometry "${geometry}" \
|
||||
--noscroll \
|
||||
--logindir "${LOADUP_LOGINDIR}" \
|
||||
--rem.cm "${cmfile}" \
|
||||
--greet "${initfile}" \
|
||||
--sysout "$1" \
|
||||
"$2" "$3" "$4" "$5" "$6" "$7" ;
|
||||
exit_code=$?
|
||||
}
|
||||
|
||||
is_tput="$(command -v tput)"
|
||||
if [ -z "${is_tput}" ]
|
||||
then
|
||||
is_tput="$(command -v true)"
|
||||
fi
|
||||
|
||||
|
||||
EOL="
|
||||
"
|
||||
output_error_msg() {
|
||||
local_oem_file="${TMPDIR:-/tmp}"/oem_$$
|
||||
echo "$1" >"${local_oem_file}"
|
||||
while read -r line
|
||||
do
|
||||
echo "$(${is_tput} setab 1)$(${is_tput} setaf 7)${line}$(${is_tput} sgr0)"
|
||||
done <"${local_oem_file}"
|
||||
rm -f "${local_oem_file}"
|
||||
}
|
||||
|
||||
output_warn_msg() {
|
||||
local_oem_file="${TMPDIR:-/tmp}"/oem_$$
|
||||
echo "$1" >"${local_oem_file}"
|
||||
while read -r line
|
||||
do
|
||||
echo "$(${is_tput} setab 3)$(${is_tput} setaf 4)${line}$(${is_tput} sgr0)"
|
||||
done <"${local_oem_file}"
|
||||
rm -f "${local_oem_file}"
|
||||
}
|
||||
|
||||
exit_if_failure() {
|
||||
if [ "$1" -ne 0 ]
|
||||
then
|
||||
if [ ! "$2" = "true" ]
|
||||
then
|
||||
output_error_msg "----- ${script_name}: FAILURE -----${EOL}"
|
||||
fi
|
||||
remove_run_lock
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
process_maikodir() {
|
||||
# process --maikodir argument. Only use when --maikodir is only possible argument
|
||||
while [ "$#" -ne 0 ];
|
||||
do
|
||||
case "$1" in
|
||||
-d | -maikodir | --maikodir)
|
||||
if [ -n "$2" ]
|
||||
then
|
||||
maikodir=$(cd "$2" 2>/dev/null && pwd)
|
||||
if [ -z "${maikodir}" ] || [ ! -d "${maikodir}" ]
|
||||
then
|
||||
output_error_msg "Error: In --maikodir (-d) command line argument, \"$2\" is not an existing directory.${EOL}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
output_error_msg "Error: Missing value for the --maikodir (-d) command line argument.${EOL}Exiting"
|
||||
exit 1
|
||||
fi
|
||||
export MAIKODIR="${maikodir}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
output_error_msg "Error: unknown flag: $1${EOL}Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
export LOADUP_LOCKFILE="${LOADUP_WORKDIR}"/lock
|
||||
|
||||
check_run_lock() {
|
||||
if [ -e "${LOADUP_LOCKFILE}" ]
|
||||
then
|
||||
output_error_msg "Error: Another loadup is already running with PID $(cat "${LOADUP_LOCKFILE}")${EOL}Exiting."
|
||||
exit 1
|
||||
fi
|
||||
echo "$$" > "${LOADUP_LOCKFILE}"
|
||||
LOADUP_LOCK="$$"
|
||||
}
|
||||
|
||||
remove_run_lock() {
|
||||
if [ -n "${LOADUP_LOCK}" ]
|
||||
then
|
||||
rm -f "${LOADUP_LOCKFILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2086
|
||||
|
||||
main() {
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
@@ -6,45 +7,59 @@ main() {
|
||||
|
||||
echo ">>>>> START ${script_name}"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/full.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/lisp.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
|
||||
if [ "${1}" = "-apps" ]; then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/apps.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
aux="$1"
|
||||
db="$2"
|
||||
no_stages="$3"
|
||||
start="$4"
|
||||
end="$5"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/whereis.hash "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/exports.all "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
if [ $start -eq 0 ] && [ $end -ge 1 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/RDSYS "${MEDLEYDIR}/library" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/RDSYS.LCOM "${MEDLEYDIR}/library" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/init.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/lisp.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/full.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/whereis.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
if [ $start -le 2 ] && [ $end -ge 3 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/lisp.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ "${1}" = "-apps" ]; then
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/apps.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
if [ $start -le 3 ] && [ $end -ge 4 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/full.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ $start -le 3 ] && [ $end -ge 5 ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/apps.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/RDSYS "${MEDLEYDIR}"/library \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/RDSYS.LCOM "${MEDLEYDIR}"/library \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
if [ "${aux}" = true ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/whereis.hash "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/exports.all "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
if [ "${db}" = true ]
|
||||
then
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.database "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
fi
|
||||
|
||||
echo "<<<<< END ${script_name}"
|
||||
echo ""
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ main() {
|
||||
|
||||
echo ">>>>> START ${script_name}"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/fuller.database "${LOADUP_OUTDIR}"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/fuller.dribble "${LOADUP_OUTDIR}"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.database "${LOADUP_OUTDIR}"
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/fuller.dribble "${LOADUP_OUTDIR}"
|
||||
|
||||
echo "<<<<< END ${script_name}"
|
||||
echo ""
|
||||
@@ -6,16 +6,16 @@ main() {
|
||||
|
||||
echo ">>>>> START ${script_name}"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/full.sysout "${LOADUP_OUTDIR}" \
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/full.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/lisp.sysout "${LOADUP_OUTDIR}" \
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/lisp.sysout "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/init.dribble "${LOADUP_OUTDIR}" \
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/init.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/lisp.dribble "${LOADUP_OUTDIR}" \
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/lisp.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/full.dribble "${LOADUP_OUTDIR}" \
|
||||
/bin/sh "${LOADUP_CPV}" "${LOADUP_WORKDIR}"/full.dribble "${LOADUP_OUTDIR}" \
|
||||
| sed -e "s#${MEDLEYDIR}/##g"
|
||||
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/cpv" "${LOADUP_WORKDIR}"/RDSYS "${MEDLEYDIR}"/library \
|
||||
126
scripts/loadups/obsolete/loadup-db.sh
Executable file
126
scripts/loadups/obsolete/loadup-db.sh
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/bin/sh
|
||||
|
||||
main () {
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}/loadup-setup.sh"
|
||||
|
||||
check_run_lock
|
||||
|
||||
process_maikodir "$@"
|
||||
|
||||
# do the loadup
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-db-from-full.sh"
|
||||
exit_if_failure $?
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/copy-db.sh"
|
||||
exit_if_failure $?
|
||||
|
||||
echo "+++++ loadup-db.sh: SUCCESS +++++"
|
||||
remove_run_lock
|
||||
exit 0
|
||||
}
|
||||
|
||||
# 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 "$@"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
120
scripts/loadups/obsolete/loadup-full.sh
Executable file
120
scripts/loadups/obsolete/loadup-full.sh
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/bin/sh
|
||||
|
||||
main() {
|
||||
# shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}/loadup-setup.sh"
|
||||
|
||||
process_maikodir "$@"
|
||||
|
||||
# do the loadup
|
||||
/bin/sh "${LOADUP_SCRIPTDIR}/loadup-all.sh" --full --noendmsg
|
||||
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -eq 0 ];
|
||||
then
|
||||
echo "+++++ ${script_name}: SUCCESS +++++"
|
||||
else
|
||||
output_error_msg "----- ${script_name}: FAILURE -----${EOL}"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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 "$@"
|
||||
126
scripts/loadups/thin_loadups.sh
Executable file
126
scripts/loadups/thin_loadups.sh
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Thin the Medley loadups and loadups/build directories by deleting all but the latest version.
|
||||
#
|
||||
# 2025-04-18 Frank Halasz
|
||||
#
|
||||
|
||||
main() {
|
||||
|
||||
#shellcheck source=./loadup-setup.sh
|
||||
. "${LOADUP_SCRIPTDIR}"/loadup-setup.sh
|
||||
|
||||
if [ "$1" = "w" ] || [ "$1" = "lw" ] || [ "$1" = "wl" ]
|
||||
then
|
||||
find "${LOADUP_WORKDIR}" -name "*.~[0-9]*~" -delete
|
||||
fi
|
||||
if [ "$1" = "l" ] || [ "$1" = "lw" ] || [ "$1" = "wl" ]
|
||||
then
|
||||
find "${LOADUP_OUTDIR}" -name "*.~[0-9]*~" -delete
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 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 "$@"
|
||||
|
||||
@@ -159,7 +159,7 @@ SCRIPTDIR="$(get_script_dir "$0")"
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
is_tput="$(which tput)"
|
||||
is_tput="$(command -v tput)"
|
||||
|
||||
output_error_msg() {
|
||||
local_oem_file="${TMPDIR:-/tmp}"/oem_$$
|
||||
@@ -170,7 +170,7 @@ output_error_msg() {
|
||||
then
|
||||
echo "$(${is_tput} setab 1)$(${is_tput} setaf 7)${line}$(${is_tput} sgr0)"
|
||||
else
|
||||
echo "$1"
|
||||
echo "${line}"
|
||||
fi
|
||||
done <"${local_oem_file}"
|
||||
rm -f "${local_oem_file}"
|
||||
@@ -620,8 +620,8 @@ sysout_stage=""
|
||||
title=""
|
||||
use_vnc=false
|
||||
windows=false
|
||||
maikodir_arg=""
|
||||
maikodir_stage=""
|
||||
maikodir_arg="${MAIKODIR}"
|
||||
maikodir_stage="MAIKODIR env variable"
|
||||
maikoprog_arg=""
|
||||
greet_arg=""
|
||||
noscroll=false
|
||||
@@ -931,10 +931,16 @@ do
|
||||
;;
|
||||
--maikodir)
|
||||
# for use in loadups
|
||||
check_for_dash_or_end "$1" "$2"
|
||||
check_dir_exists "$1" "2"
|
||||
maikodir_arg="$2"
|
||||
maikodir_stage="${args_stage}"
|
||||
if [ "$2" = "-" ] || [ "$2" == "--" ]
|
||||
then
|
||||
maikodir_arg=""
|
||||
maikodir_stage=""
|
||||
else
|
||||
check_for_dash_or_end "$1" "$2"
|
||||
check_dir_exists "$1" "2"
|
||||
maikodir_arg="$2"
|
||||
maikodir_stage="${args_stage}"
|
||||
fi
|
||||
shift;
|
||||
;;
|
||||
-prog | --maikoprog)
|
||||
@@ -1365,7 +1371,8 @@ then
|
||||
then
|
||||
err_msg="ERROR: Cannot find the Maiko directory at either
|
||||
\"${MEDLEYDIR}/maiko\" or \"${MEDLEYDIR}/../maiko\".
|
||||
You can use the --maikodir argument to specify the Maiko directory.
|
||||
You can use the --maikodir argument or the MAIKODIR env variable
|
||||
to specify the Maiko directory.
|
||||
Exiting."
|
||||
output_error_msg "${err_msg}"
|
||||
exit 53
|
||||
@@ -1380,8 +1387,8 @@ Exiting."
|
||||
elif ! check_if_maiko_dir "${maikodir_arg}" || ! check_for_maiko_exe "${maikodir_arg}"
|
||||
then
|
||||
err_msg="In ${maikodir_stage}:
|
||||
ERROR: The value of the --maikodir argument is not in fact a directory containing
|
||||
the Maiko emulator (${maiko_exe_subdir}/${maikoprog_arg}).
|
||||
ERROR: The value provided by \$MAIKODIR or by the --maikodir argument ("${maikodir_arg}") is not
|
||||
in fact a directory containing the Maiko emulator (${maiko_exe_subdir}/${maikoprog_arg}).
|
||||
Exiting."
|
||||
output_error_msg "${err_msg}"
|
||||
exit 53
|
||||
|
||||
@@ -30,8 +30,8 @@ sysout_stage=""
|
||||
title=""
|
||||
use_vnc=false
|
||||
windows=false
|
||||
maikodir_arg=""
|
||||
maikodir_stage=""
|
||||
maikodir_arg="${MAIKODIR}"
|
||||
maikodir_stage="MAIKODIR env variable"
|
||||
maikoprog_arg=""
|
||||
greet_arg=""
|
||||
noscroll=false
|
||||
@@ -341,10 +341,16 @@ do
|
||||
;;
|
||||
--maikodir)
|
||||
# for use in loadups
|
||||
check_for_dash_or_end "$1" "$2"
|
||||
check_dir_exists "$1" "2"
|
||||
maikodir_arg="$2"
|
||||
maikodir_stage="${args_stage}"
|
||||
if [ "$2" = "-" ] || [ "$2" == "--" ]
|
||||
then
|
||||
maikodir_arg=""
|
||||
maikodir_stage=""
|
||||
else
|
||||
check_for_dash_or_end "$1" "$2"
|
||||
check_dir_exists "$1" "2"
|
||||
maikodir_arg="$2"
|
||||
maikodir_stage="${args_stage}"
|
||||
fi
|
||||
shift;
|
||||
;;
|
||||
-prog | --maikoprog)
|
||||
|
||||
@@ -246,7 +246,8 @@ then
|
||||
then
|
||||
err_msg="ERROR: Cannot find the Maiko directory at either
|
||||
\"${MEDLEYDIR}/maiko\" or \"${MEDLEYDIR}/../maiko\".
|
||||
You can use the --maikodir argument to specify the Maiko directory.
|
||||
You can use the --maikodir argument or the MAIKODIR env variable
|
||||
to specify the Maiko directory.
|
||||
Exiting."
|
||||
output_error_msg "${err_msg}"
|
||||
exit 53
|
||||
@@ -261,8 +262,8 @@ Exiting."
|
||||
elif ! check_if_maiko_dir "${maikodir_arg}" || ! check_for_maiko_exe "${maikodir_arg}"
|
||||
then
|
||||
err_msg="In ${maikodir_stage}:
|
||||
ERROR: The value of the --maikodir argument is not in fact a directory containing
|
||||
the Maiko emulator (${maiko_exe_subdir}/${maikoprog_arg}).
|
||||
ERROR: The value provided by \$MAIKODIR or by the --maikodir argument ("${maikodir_arg}") is not
|
||||
in fact a directory containing the Maiko emulator (${maiko_exe_subdir}/${maikoprog_arg}).
|
||||
Exiting."
|
||||
output_error_msg "${err_msg}"
|
||||
exit 53
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
is_tput="$(which tput)"
|
||||
is_tput="$(command -v tput)"
|
||||
|
||||
output_error_msg() {
|
||||
local_oem_file="${TMPDIR:-/tmp}"/oem_$$
|
||||
@@ -24,7 +24,7 @@ output_error_msg() {
|
||||
then
|
||||
echo "$(${is_tput} setab 1)$(${is_tput} setaf 7)${line}$(${is_tput} sgr0)"
|
||||
else
|
||||
echo "$1"
|
||||
echo "${line}"
|
||||
fi
|
||||
done <"${local_oem_file}"
|
||||
rm -f "${local_oem_file}"
|
||||
|
||||
Reference in New Issue
Block a user