1
0
mirror of synced 2026-03-22 17:18:10 +00:00

Compare commits

..

2 Commits

4 changed files with 345 additions and 21 deletions

135
scripts/loadup-app-setup.sh Normal file
View File

@@ -0,0 +1,135 @@
#!to_be_sourced_only
# shellcheck shell=sh
MEDLEY_SCRIPTDIR="$(cd "${MEDLEYDIR}/scripts" && pwd)"
if [ -z "${APP_DIR}" ]
then
export APP_DIR="$(cd "${LOADUP_SCRIPTDIR}/../" && pwd)"
fi
if [ ! -d "${APP_DIR}" ]
then
echo "Error: Cannot find the ${APP_NAME} directory: ${APP_DIR}"
exit 1
fi
if [ -z "${APP_LOADUPSDIR}" ]
then
export APP_LOADUPSDIR="${APP_DIR}/loadups"
fi
if [ ! -d "${APP_LOADUPSDIR}" ]
then
if [ -e "${APP_LOADUPSDIR}" ]
then
echo "Error: the ${APP_NAME} loadups dir (${APP_LOADUPSDIR}) exists, but it is not a directory."
echo "Exiting."
exit 1
else
mkdir -p "${APP_LOADUPSDIR}"
fi
fi
if [ -z "${APP_WORKDIR}" ]
then
export APP_WORKDIR="${APP_LOADUPSDIR}/build"
fi
if [ ! -d "${APP_WORKDIR}" ]
then
if [ -e "${APP_WORKDIR}" ]
then
echo "Error: the ${APP_NAME} loadups work dir (${APP_WORKDIR}) exists, but it is not a directory."
echo "Exiting."
exit 1
else
mkdir -p "${APP_WORKDIR}"
fi
fi
HAS_GIT= [ -f $(which git) ] && [ -x $(which git) ]
export HAS_GIT
git_commit_ID () {
if ${HAS_GIT};
then
# This does NOT indicate if there are any modified files!
COMMIT_ID=$(git -C "$1" rev-parse --short HEAD 2>/dev/null)
fi
}
git_commit_ID "${MEDLEYDIR}"
MEDLEY_COMMIT_ID="${COMMIT_ID}"
export MEDLEY_COMMIT_ID
git_commit_ID "${APP_DIR}"
APP_COMMIT_ID="${COMMIT_ID}"
export APP_COMMIT_ID
scr="-sc 1024x768 -g 1042x790"
geometry=1024x768
touch "${APP_WORKDIR}"/loadup.timestamp
script_name=$(basename "$0" ".sh")
cmfile="${APP_WORKDIR}/${script_name}.cm"
######################################################################
loadup_start () {
echo ">>>>> START ${script_name}"
}
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 [ "${APP_WORKDIR}/$1" -nt "${APP_WORKDIR}"/loadup.timestamp ]
then
echo
echo "..... files copied into loadups ....."
for f in "$@"
do
# shellcheck disable=SC2045,SC2086
for ff in $(ls -1 "${APP_WORKDIR}"/$f);
do
/bin/sh "${MEDLEY_SCRIPTDIR}/cpv" "${ff}" "${APP_LOADUPSDIR}" \
| sed -e "s#${APP_DIR}/##g"
done
done
echo "....................................."
echo
echo "+++++ SUCCESS +++++"
exit_code=0
else
echo "----- FAILURE -----"
exit_code=1
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 "${APP_WORKDIR}" \
--greet "${cmfile}" \
--sysout "$1" \
"$2" "$3" "$4" "$5" "$6" "$7" ;
exit_code=$?
}
######################################################################

190
scripts/loadup-lfg.sh Executable file
View File

@@ -0,0 +1,190 @@
#!/bin/sh
main() {
export APP_DIR="${LFG_DIR}"
export APP_LOADUPSDIR="${LFG_LOADUPSDIR}"
export APP_WORKDIR="${LFG_WORKDIR}"
get_medleydir "$@"
loadup_start
cat >"${cmfile}" <<-"EOF"
"
(PROGN
(IL:MEDLEY-INIT-VARS 'IL:GREET)
(IL:DRIBBLE (IL:PACKFILENAME 'HOST '{DSK} 'DIRECTORY (IL:UNIX-GETENV 'APP_WORKDIR) 'NAME 'lfg.dribble))
(IL:DOFILESLOAD
'((SYSLOAD)
(FROM VALUEOF (IL:PACKFILENAME 'HOST '{DSK} 'DIRECTORY (IL:UNIX-GETENV 'APP_DIR)))
LFG-LOADUP
)
)
(IL:LOADUP-LFG)
(IL:PUTASSOC 'IL:LFG
(LIST (IL:UNIX-GETENV 'MEDLEY_COMMIT_ID))
(CADR (ASSOC 'IL:MEDLEY IL:SYSOUTCOMMITS)))
(IL:PUTASSOC 'IL:LFG (LIST (IL:UNIX-GETENV 'APP_COMMIT_ID)) IL:SYSOUTCOMMITS)
(IL:ENDLOADUP)
(IL:DRIBBLE)
(IL:MAKESYS
(IL:PACKFILENAME 'HOST '{DSK} 'DIRECTORY (IL:UNIX-GETENV 'APP_WORKDIR) 'NAME 'lfg.sysout)
:LFG
)
)
(IL:LOGOUT T)
"
EOF
run_medley "${full_sysout}"
loadup_finish "lfg.sysout" "lfg.dribble"
}
get_medleydir() {
while [ $# -gt 0 ]
do
case "$1" in
-m | -medley | --medley)
export MEDLEYDIR="$2"
if [ -z "$2" ]
then
echo "Error: The -m (-medley, --medley) flag requires a path to a full.sysout file as an argument"
echo "Exiting"
exit 1
fi
shift
;;
*)
echo "Warning unknown argument: $1. Ignored"
;;
esac
shift
done
if [ -z "${MEDLEYDIR}" ]
then
echo "Error: MEDLEYDIR not specified either thru environment variable or thru command line argument"
echo "Exiting"
exit 1
fi
full_sysout="${MEDLEYDIR}/loadups/full.sysout"
if [ ! -f "${full_sysout}" ]
then
echo "Error: cannot find the Medley full.sysout file (${full_sysout})"
echo "It either doesn't exist or is a directory"
echo "Exiting"
exit 1
fi
. "${MEDLEYDIR}/scripts/loadup-app-setup.sh"
}
# 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 "$@"

View File

@@ -1,12 +1,12 @@
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "XCL" BASE 10)
(FILECREATED "14-Jan-2025 13:20:25" |{DSK}<home>matt>Interlisp>medley>sources>HIST.;2| 152217
(FILECREATED "19-Apr-2023 18:58:13" |{DSK}<home>larry>il>medley>sources>HIST.;6| 152088
:EDIT-BY "matt"
:EDIT-BY "lmm"
:CHANGES-TO (FNS GREET0)
:PREVIOUS-DATE "19-Apr-2023 18:58:13" |{DSK}<home>matt>Interlisp>medley>sources>HIST.;1|)
:PREVIOUS-DATE "19-Mar-2023 10:09:08" |{DSK}<home>larry>il>medley>sources>HIST.;1|)
(PRETTYCOMPRINT HISTCOMS)
@@ -2754,8 +2754,7 @@ this sysout is initialized for user " T)
(printout t "error during GREET..." t))))
(GREET0
(LAMBDA NIL (* \; "Edited 14-Jan-2025 13:19 by matt")
(* \; "Edited 19-Apr-2023 18:55 by lmm")
(LAMBDA NIL (* \; "Edited 19-Apr-2023 18:55 by lmm")
(* \; "Edited 19-Mar-2023 09:58 by lmm")
(* |lmm| "28-DEC-82 08:49")
(COND
@@ -2764,7 +2763,7 @@ this sysout is initialized for user " T)
(CL:GET-DECODED-TIME)
(OR (AND (EVENP (LRSH SECONDS 1))
(CDR (SASSOC (CL:FORMAT NIL "~2D-~A" DAY
(CL:NTH (SUB1 MONTH)
(CL:NTH MONTH
'("JAN" "FEB" "MAR" "APR" "MAY"
"JUN" "JUL" "AUG" "SEP"
"OCT" "NOV" "DEC")))
@@ -3039,19 +3038,19 @@ this sysout is initialized for user " T)
(ADDTOVAR LAMA )
)
(DECLARE\: DONTCOPY
(FILEMAP (NIL (14257 21002 (PRINTHISTORY 14267 . 16057) (ENTRY# 16059 . 16394) (PRINTHISTORY1 16396 .
19565) (PRINTHISTORY2 19567 . 21000)) (21003 129433 (EVALQT 21013 . 21813) (ENTEREVALQT 21815 . 22370)
(USEREXEC 22372 . 23007) (LISPXREAD 23009 . 24812) (LISPXREADBUF 24814 . 27040) (LISPXREADP 27042 .
27591) (LISPXUNREAD 27593 . 27886) (LISPX 27888 . 63583) (LISPX/ 63585 . 65039) (LISPX/1 65041 . 70327
) (LISPXEVAL 70329 . 70953) (LISPXSTOREVALUE 70955 . 71209) (HISTORYSAVE 71211 . 78495) (LISPXFIND
78497 . 85932) (LISPXGETINPUT 85934 . 86147) (REMEMBER 86149 . 86343) (GETEXPRESSIONFROMEVENTSPEC
86345 . 88455) (LISPXFIND0 88457 . 92731) (LISPXFIND1 92733 . 93161) (HISTORYFIND 93163 . 98737) (
HISTORYFIND1 98739 . 102184) (HISTORYMATCH 102186 . 102261) (VALUEOF 102263 . 103288) (VALUOF 103290
. 104180) (VALUOF-EVENT 104182 . 104587) (LISPXUSE 104589 . 111008) (LISPXUSE0 111010 . 113736) (
LISPXUSE1 113738 . 115363) (LISPXSUBST 115365 . 115785) (LISPXUSEC 115787 . 124028) (LISPXFIX 124030
. 124880) (CHANGESLICE 124882 . 126729) (LISPXSTATE 126731 . 127825) (LISPXTYPEAHEAD 127827 . 129431)
) (137485 140819 (GREET 137495 . 138636) (GREET0 138638 . 140817)) (142421 149597 (LISPXPRINT 142431
. 142995) (LISPXPRIN1 142997 . 143881) (LISPXPRIN2 143883 . 144825) (LISPXPRINTDEF 144827 . 145381) (
LISPXPRINTDEF0 145383 . 145746) (LISPXSPACES 145748 . 146434) (LISPXTERPRI 146436 . 147061) (LISPXTAB
147063 . 147621) (USERLISPXPRINT 147623 . 149023) (LISPXPUT 149025 . 149595)))))
(FILEMAP (NIL (14244 20989 (PRINTHISTORY 14254 . 16044) (ENTRY# 16046 . 16381) (PRINTHISTORY1 16383 .
19552) (PRINTHISTORY2 19554 . 20987)) (20990 129420 (EVALQT 21000 . 21800) (ENTEREVALQT 21802 . 22357)
(USEREXEC 22359 . 22994) (LISPXREAD 22996 . 24799) (LISPXREADBUF 24801 . 27027) (LISPXREADP 27029 .
27578) (LISPXUNREAD 27580 . 27873) (LISPX 27875 . 63570) (LISPX/ 63572 . 65026) (LISPX/1 65028 . 70314
) (LISPXEVAL 70316 . 70940) (LISPXSTOREVALUE 70942 . 71196) (HISTORYSAVE 71198 . 78482) (LISPXFIND
78484 . 85919) (LISPXGETINPUT 85921 . 86134) (REMEMBER 86136 . 86330) (GETEXPRESSIONFROMEVENTSPEC
86332 . 88442) (LISPXFIND0 88444 . 92718) (LISPXFIND1 92720 . 93148) (HISTORYFIND 93150 . 98724) (
HISTORYFIND1 98726 . 102171) (HISTORYMATCH 102173 . 102248) (VALUEOF 102250 . 103275) (VALUOF 103277
. 104167) (VALUOF-EVENT 104169 . 104574) (LISPXUSE 104576 . 110995) (LISPXUSE0 110997 . 113723) (
LISPXUSE1 113725 . 115350) (LISPXSUBST 115352 . 115772) (LISPXUSEC 115774 . 124015) (LISPXFIX 124017
. 124867) (CHANGESLICE 124869 . 126716) (LISPXSTATE 126718 . 127812) (LISPXTYPEAHEAD 127814 . 129418)
) (137472 140690 (GREET 137482 . 138623) (GREET0 138625 . 140688)) (142292 149468 (LISPXPRINT 142302
. 142866) (LISPXPRIN1 142868 . 143752) (LISPXPRIN2 143754 . 144696) (LISPXPRINTDEF 144698 . 145252) (
LISPXPRINTDEF0 145254 . 145617) (LISPXSPACES 145619 . 146305) (LISPXTERPRI 146307 . 146932) (LISPXTAB
146934 . 147492) (USERLISPXPRINT 147494 . 148894) (LISPXPUT 148896 . 149466)))))
STOP

Binary file not shown.