diff --git a/.github/workflows/buildReleaseInclDocker.yml b/.github/workflows/buildReleaseInclDocker.yml index 652103ec..9948a52a 100644 --- a/.github/workflows/buildReleaseInclDocker.yml +++ b/.github/workflows/buildReleaseInclDocker.yml @@ -110,6 +110,16 @@ jobs: force: ${{ needs.inputs.outputs.force }} secrets: inherit +###################################################################################### + + # Run HCFILES and push to files.interlisp.org + do_HCFILES: + needs: [inputs, do_release] + uses: ./.github/workflows/doHCFILES.yml + with: + draft: ${{ needs.inputs.outputs.draft }} + secrets: inherit + ###################################################################################### # Kickoff workflow in online repo to build and deploy Medley docker image to oio diff --git a/.github/workflows/doHCFILES.yml b/.github/workflows/doHCFILES.yml new file mode 100644 index 00000000..629e4f0d --- /dev/null +++ b/.github/workflows/doHCFILES.yml @@ -0,0 +1,139 @@ +#******************************************************************************* +# doHCFILES.yml +# +# Interlisp workflow to run HCFILES. HCFILES prints out PDF files for all of the +# files in the Medley directory and posts them on files.interlisp.org. +# +# This workflow is designed to be kickjed off by the buildReleaseInclDocker +# workflow running in the Medley repo, once the release has been completed successfully +# +# Copyright 2024 by Interlisp.org +# +# ****************************************************************************** + +name: Run HCFILES + +# Run this workflow on ... +on: + workflow_dispatch: + inputs: + draft: + description: "Mark this as a draft release" + type: choice + options: + - 'false' + - 'true' + + workflow_call: + inputs: + draft: + description: "Mark this as a draft release" + required: false + type: string + default: 'false' + secrets: + OIO_SSH_KEY: + required: true + MU_TOKEN: + required: true + +defaults: + run: + shell: bash + +jobs: + + run_HCFILES: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout Medley repo + uses: actions/checkout@v4 + + - name: Checkout notecards + uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/notecards + path: ./notecards + + - name: Checkout loops + uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/loops + path: ./loops + + - name: Checkout test + uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/test + path: ./test + + - name: Cleanup .git for notecards, loops, test + run: rm -rf ./notecards/.git ./loops/.git ./test/.git + + - name: Download Maiko + run: | + gh release download --output /tmp/maiko.tgz \ + --repo ${{ github.repository_owner }}/maiko \ + --pattern '*-linux.x86_64.tgz' + tar -xzf /tmp/maiko.tgz + env: + GH_TOKEN: ${{ secrets.MU_TOKEN }} + + - name: Install vnc & ghostscript (ps2pdf) + run: | + sudo apt-get update + sudo apt-get install -y tightvncserver + sudo apt-get install -y ghostscript + + - name: Build apps.sysout + run: | + Xvnc -geometry 1280x720 :0 & + export DISPLAY=":0" + scripts/loadup-all.sh -apps + + - name: Run HCFILES + run: | + export DISPLAY=":0" + scripts/do_hcfiles.sh + + - name: Push Medley files (including created pdf files) to files.interlisp.org + run: | + # create a tar file of all of the directories to be pushed + tarfile=/tmp/source-$$.tgz + tar -c -z -f ${tarfile} --exclude=.git . + # set up ssh identity + eval $(ssh-agent) + ssh-add - <<< "${SSH_KEY}" + # set destination directory on files.interlisp.org + if [ "${{ inputs.draft }}" = "true" ] + then + dest=/srv/oio/files/development/medley + else + dest=/srv/oio/files/production/medley + fi + # Push tar file up to files.interlisp.org + batchfile=/tmp/batch-$$ + echo "-put ${tarfile} ${dest}.tgz" > ${batchfile} + sftp -o StrictHostKeyChecking=no -b ${batchfile} ubuntu@files.interlisp.org + # now tar is up, untar it and juggle backups + scriptfile=/tmp/script-$$ + # create script file to do the work + cat > ${scriptfile} <larry>il>medley>internal>MEDLEY-UTILS.;2 28720 +(FILECREATED "14-Jul-2024 12:51:12" {DSK}frank>il>medley>internal>MEDLEY-UTILS.;16 30093 - :EDIT-BY "lmm" + :CHANGES-TO (FNS MAKE-INDEX-HTMLS) - :CHANGES-TO (FNS HCFILES) - - :PREVIOUS-DATE "29-Apr-2024 16:25:20" {DSK}larry>il>medley>internal>MEDLEY-UTILS.;1) + :PREVIOUS-DATE "13-Jul-2024 23:39:43" {DSK}frank>il>medley>internal>MEDLEY-UTILS.;14) (PRETTYCOMPRINT MEDLEY-UTILSCOMS) @@ -126,13 +124,16 @@ "Welcome to Fuller sysout"]) (MAKE-INDEX-HTMLS - [LAMBDA (BASE TOP) (* ; "Edited 29-Apr-2024 14:18 by lmm") + [LAMBDA (BASE TOP LEVEL) (* ; "Edited 29-Apr-2024 14:18 by lmm") (* ; "Edited 26-Apr-2024 16:15 by lmm") (* ; "Edited 20-Apr-2024 12:34 by lmm") (* ; "Edited 13-Apr-2024 21:18 by lmm") [OR BASE (SETQ BASE (PSEUDOFILENAME (MEDLEYDIR] (OR (DIRECTORYNAMEP BASE) (ERROR BASE "not a directory name")) + (OR (AND (NUMBERP LEVEL) + (IGREATERP LEVEL 0)) + (SETQ LEVEL 1)) (LET* ((SUBDIRS NIL) (DEST (PACKFILENAME 'NAME "index" 'EXTENSION "html" 'VERSION NIL 'BODY BASE)) (PSEUDOHOST (EQ (NTHCHAR BASE (CL:1- 0)) @@ -140,9 +141,20 @@ SLASHED SHORTNAME) (CL:WITH-OPEN-FILE (S DEST :DIRECTION :OUTPUT :IF-EXISTS :NEW-VERSION :IF-DOES-NOT-EXIST :CREATE) - (CL:FORMAT S "Index page for ~a~%%" (SETQ SLASHED - (SLASHIT BASE))) + (CL:FORMAT S "~%%~%%") + (CL:FORMAT S "Index page for ~a~%%" (SETQ SLASHED (SLASHIT BASE))) + (CL:FORMAT S "~%%") + (CL:FORMAT S "~%%") (CL:FORMAT S "

Index page for ~a

~%%" SLASHED) + (CL:UNLESS (EQ LEVEL 1) + (CL:FORMAT S + "
~%%~%%
~%%" + )) (CL:FORMAT S "

This is an index of the files just to link them in.~%%

    ~%%") (FOR FULLNAME IN (DIRECTORY (CONCAT BASE "*.*;")) DO (IF (EQ (NTHCHAR FULLNAME -1) @@ -183,7 +195,8 @@ ELSE (CL:FORMAT S "
  • ~a
  • ~%%" SHORTNAME SHORTNAME))) (CL:FORMAT S "
~%%")) - (NCONC SUBDIRS (FOR D IN SUBDIRS join (MAKE-INDEX-HTMLS D (OR TOP BASE]) + (NCONC SUBDIRS (FOR D IN SUBDIRS join (MAKE-INDEX-HTMLS D (OR TOP BASE) + (ADD1 LEVEL]) (MEDLEY-FIX-LINKS [LAMBDA (UNIXPATH) (* ; "Edited 18-Jan-2021 12:01 by larry") @@ -336,13 +349,16 @@ (PRINTOUT T "DONE" T))]) (MAKE-INDEX-HTMLS - [LAMBDA (BASE TOP) (* ; "Edited 29-Apr-2024 14:18 by lmm") + [LAMBDA (BASE TOP LEVEL) (* ; "Edited 29-Apr-2024 14:18 by lmm") (* ; "Edited 26-Apr-2024 16:15 by lmm") (* ; "Edited 20-Apr-2024 12:34 by lmm") (* ; "Edited 13-Apr-2024 21:18 by lmm") [OR BASE (SETQ BASE (PSEUDOFILENAME (MEDLEYDIR] (OR (DIRECTORYNAMEP BASE) (ERROR BASE "not a directory name")) + (OR (AND (NUMBERP LEVEL) + (IGREATERP LEVEL 0)) + (SETQ LEVEL 1)) (LET* ((SUBDIRS NIL) (DEST (PACKFILENAME 'NAME "index" 'EXTENSION "html" 'VERSION NIL 'BODY BASE)) (PSEUDOHOST (EQ (NTHCHAR BASE (CL:1- 0)) @@ -350,9 +366,20 @@ SLASHED SHORTNAME) (CL:WITH-OPEN-FILE (S DEST :DIRECTION :OUTPUT :IF-EXISTS :NEW-VERSION :IF-DOES-NOT-EXIST :CREATE) - (CL:FORMAT S "Index page for ~a~%%" (SETQ SLASHED - (SLASHIT BASE))) + (CL:FORMAT S "~%%~%%") + (CL:FORMAT S "Index page for ~a~%%" (SETQ SLASHED (SLASHIT BASE))) + (CL:FORMAT S "~%%") + (CL:FORMAT S "~%%") (CL:FORMAT S "

Index page for ~a

~%%" SLASHED) + (CL:UNLESS (EQ LEVEL 1) + (CL:FORMAT S + "
~%%~%%
~%%" + )) (CL:FORMAT S "

This is an index of the files just to link them in.~%%

    ~%%") (FOR FULLNAME IN (DIRECTORY (CONCAT BASE "*.*;")) DO (IF (EQ (NTHCHAR FULLNAME -1) @@ -393,7 +420,8 @@ ELSE (CL:FORMAT S "
  • ~a
  • ~%%" SHORTNAME SHORTNAME))) (CL:FORMAT S "
~%%")) - (NCONC SUBDIRS (FOR D IN SUBDIRS join (MAKE-INDEX-HTMLS D (OR TOP BASE]) + (NCONC SUBDIRS (FOR D IN SUBDIRS join (MAKE-INDEX-HTMLS D (OR TOP BASE) + (ADD1 LEVEL]) ) (PUTPROPS MEDLEY-UTILS FILETYPE :COMPILE-FILE) @@ -500,9 +528,9 @@ (ADDTOVAR LAMA ) ) (DECLARE%: DONTCOPY - (FILEMAP (NIL (1099 11665 (GATHER-INFO 1109 . 6491) (MAKE-FULLER-DB 6493 . 7270) (MAKE-INDEX-HTMLS -7272 . 11034) (MEDLEY-FIX-LINKS 11036 . 11429) (MEDLEY-FIX-DATES 11431 . 11663)) (12844 15632 ( -MAKE-EXPORTS-ALL 12854 . 13913) (MAKE-WHEREIS-HASH 13915 . 15104) (MAKE-WHEREIS-LOOPS 15106 . 15630)) -(15633 23672 (HCFILES 15643 . 19906) (MAKE-INDEX-HTMLS 19908 . 23670)) (23922 28534 (RECOMPILE-ONE -23932 . 25829) (RECMPL 25831 . 26434) (COMPILE-SETUP 26436 . 27060) (REMAKEFILES 27062 . 28532))))) + (FILEMAP (NIL (1086 12345 (GATHER-INFO 1096 . 6478) (MAKE-FULLER-DB 6480 . 7257) (MAKE-INDEX-HTMLS +7259 . 11714) (MEDLEY-FIX-LINKS 11716 . 12109) (MEDLEY-FIX-DATES 12111 . 12343)) (13524 16312 ( +MAKE-EXPORTS-ALL 13534 . 14593) (MAKE-WHEREIS-HASH 14595 . 15784) (MAKE-WHEREIS-LOOPS 15786 . 16310)) +(16313 25045 (HCFILES 16323 . 20586) (MAKE-INDEX-HTMLS 20588 . 25043)) (25295 29907 (RECOMPILE-ONE +25305 . 27202) (RECMPL 27204 . 27807) (COMPILE-SETUP 27809 . 28433) (REMAKEFILES 28435 . 29905))))) STOP diff --git a/internal/MEDLEY-UTILS.DFASL b/internal/MEDLEY-UTILS.DFASL index 317ed2c7..aacd382b 100644 Binary files a/internal/MEDLEY-UTILS.DFASL and b/internal/MEDLEY-UTILS.DFASL differ diff --git a/scripts/do_hcfiles.sh b/scripts/do_hcfiles.sh new file mode 100755 index 00000000..6f074580 --- /dev/null +++ b/scripts/do_hcfiles.sh @@ -0,0 +1,141 @@ +#!/bin/sh + +main() { + MEDLEYDIR=$(cd "${SCRIPTDIR}/.." && pwd) + export MEDLEYDIR + logindir=/tmp/hcfiles-$$ + mkdir -p "${logindir}" + cmfile=${logindir}/hcfiles.cm + + cat >"${cmfile}" <<-"EOF" + " + + (PROGN + (IL:MEDLEY-INIT-VARS 'IL:GREET) + (IL:FILESLOAD MEDLEY-UTILS PDFSTREAM GITFNS)) + (IL:DRIBBLE '{DSK}${logindir}/hcfiles.dribble) + (IL:SETQ IL:*UPPER-CASE-FILE-NAMES* NIL) + (IL:SETQ IL:NO-HELP NIL) + (IL:ADVISE 'IL:UNSAFE.TO.MODIFY :BEFORE '(RETURN NIL)) + (IL:ADVISE 'IL:HELP :BEFORE '(IL:COND (IL:NO-HELP (IL:ERROR IL:MESS1 IL:MESS2 T)))) + (IL:LET ((IL:NO-HELP T)) (DECLARE (SPECIAL IL:NO-HELP)) (IL:HCFILES)) + (IL:MAKE-INDEX-HTMLS) + (IL:DRIBBLE) + (IL:LOGOUT T) + ) + + " + EOF + + + /bin/sh "${MEDLEYDIR}/scripts/medley/medley.command" \ + --config - \ + --id hcfiles_+ \ + --geometry 1024x768 \ + --noscroll \ + --logindir "${logindir}" \ + --greet "${cmfile}" \ + --apps + +} + +# shellcheck disable=SC2164,SC2034 +if [ -z "${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 + SCRIPTDIR="$(get_script_dir "$0")" + export SCRIPTDIR + +fi + +main "$@"