1
0
mirror of synced 2026-01-23 11:17:40 +00:00
Frank Halasz 4b95a8b5d3
Windows installer and medley script for running Medley in Docker on Windows (#1077)
* Update docker file build to use new deb linux installers;  move Dockefile to .github/workflows since its really only useable from the buildDocker.yml workflow

* Fix typo in dockerfile location

* remove extraneous " in >>GITHUB_ENV statements

* Fix handling of TARGETPLATFORM in Dockerfile

* Trying with just one platform

* Fix issues with missing man-db in docker build workflow; added man-db to depends in deb builds for linux

* Sicthed docker from tightvnc to tigervnc to match oio.  This getting the apt package name right.

* Going back to single platform to debug this thing

* Trying with just arm64

* Removing arm/v7 from docker images.  Takes too long to build and just wastes our github actions minutes.  This is assuming its a never used feature since docker is not big on raspberry pis and their ilk.

* Fix typo in control-linux; update build_deb so that files in /usr/local installed by deb are owned by root; add ubuntu user and nano in docker file for dbebugging;  when in draft only create for x86_64 platform

* Fix typo in buildDocker.yml

* Add sudo to docker image; in docker image ensure that all /usr/local/interlisp files are owned by root

* Add securityTypes none to docker entrypoint

* Updated docker base to Ubuntu 22.10 to get fixed xrdp; add xrdp to the docker image; updated user permission in docker image;

* In Dockerfile make xrdp install noninteractive

* Update medley.sh scripts to handle docker case

* Fix a couple of typos

* BuildDcoker: added pulling latest draft release (if any) when this is a draft docker build; removed checkout of medley code cause its not used

* BuildDocker: added medley checkout backin - turns pout its needed by a bunch of actions even though I dont really think they use it

* BuildDocker: moved download assets to use gh instaed of a marketplace action becauase that action could not handle draft releases.

* Tweaking medley.sh and associated tweaks to work Windows via wsl medley and docker

* adding first pass at powershell script for windows docker and wsl

* Tuning how Xvnc, medley, and vncviewer handle the various ways of exiting - eg logout vs closing viewer window.

* Tuning vncviewer launch to make sure that tty works as expected when medley.sh runs in background

* Minor typo fixes and added extra check to use of /run/shm in medley_vnc.sh

* Added SSH_KEY secret to buildReleaseIncDocker workflow

* Gertting the add SSH_KEY secret into orkflows right this time, hopefully

* Adding TERM env variable and setting USER to medley in docker image

* Debugging medley.ps1 and adding a couple of arguments

* Typo in Dockerfile medley

* Synchronizing flag processing and usage for medley.ps1 and medley.sh; refactored medley_args.sh and medley_usage.sh code.

* Adding first pass at windows installer

* Adding first pass an inno setup script for Windows installation

* Update buildLoadup workflow and downloads page for windows installer

* Fix typo in buildLoadup

* BuildLoadup make sure windows runner uses powershell

* Another typo in buildLoadup

* Another typo in buildLoadup; damn those double quotes

* Updating handling of windows installer in buildLoadup, added vncviewer to medley.iss install

* Unknown syntax error in buildLoadup

* Another damn typo from double quotes

* buildLoadup: fixed loadup job outputs

* buidLoadup: fixed bug with COMBINED_RELEASE_TAG; fixed Upload script in windows job to be compatible with actions.script v6.

* buidLoadup: upload win installer adapted to find draft releases as well as full releases

* BuildLoadup: fixing up javascript in actions in windows job to use / instead of \ in pathname

* BuildLoadup: changing win installer update to same action used for other release assets

* Fix windows installer file name; in BuildLoadup move update downl;oad page to the Windows runner because uploading the window-installer changes the release download url, so updating the downloads page must be done after the windows installer upload.; General buildLoadup cleanup

* Run md2html to update downloads page

* Fix typo in build_deb.sh

* Removing some leftover crud in medley_usage.sh

* Fixing up windows installer a bit, mostly cosmetic

* Adding support for WSL1; mostly forcing --vnc and changing how to find open ports and displays since WSL1 networking is different tha WSL2

* Update manual page for new Windows Medley script

* First pass done for man page that incorporates new Windows medley script.  Add Xvnc wait before calling run-medley in case of docker to prevent occasonal missing X windows server error.

* Change buildLoadup to update man page to a draft if this is a draft run.
2023-02-18 06:19:57 -08:00

159 lines
5.2 KiB
Bash
Executable File

#!/bin/bash
###############################################################################
#
# build_deb.sh: build .deb files for installing Medley Interlisp on Linux
# and WSL
#
# 2023-01-10 Frank Halasz
#
# Copyright 2023 by Interlisp.org
#
###############################################################################
# set -x
# mess with file desscriptors so we get only one line on stdout
# so we can communicate only what we want back to any githib runner
# stash fd 1 in fd 3
exec 3>&1
# make fd 1 (stdout) be the same as stdout
# so none of the std output from this file will be captured by
# $() but it will still be written out to the tty (via stderr)
exec 1>&2
tarball_dir=tmp/tarballs
# Make sure we are in the right directory
if [ ! -f ./control-linux ];
then
echo "Can't find ./control file."
echo "Incorrect cwd?"
echo "Should be in medley/installers/deb"
echo "Exiting"
exit 1
fi
# If running as a github action or -t arg, then skip downloading the tarballs
if ! [[ -n "${GITHUB_WORKSPACE}" || "$1" = "-t" ]];
then
# First, make sure gh is available and we are logged in to github
if [ -z "$(which gh)" ];
then
echo "Can't find gh"
echo "Exiting."
exit 2
fi
gh auth status 2>&1 | grep --quiet --no-messages "Logged in to github.com"
if [ $? -ne 0 ];
then
echo "Not logged into github."
echo "Exiting."
exit 3
fi
# then clear out the ./tmp directory
rm -rf ./tmp
mkdir ./tmp
# then download the maiko and medley tarballs
mkdir -p ${tarball_dir}
echo "Fetching maiko and medley release tarballs"
gh release download --repo interlisp/maiko --dir ${tarball_dir} --pattern "*.tgz"
TAG=$(gh release list --repo interlisp/medley | head -n 1 | awk "{print \$1 }")
gh release download ${TAG} --repo interlisp/medley --dir ${tarball_dir} --pattern "*.tgz"
gh repo clone interlisp/notecards notecards -- --depth 1
(cd notecards; git archive --format=tgz --output=../notecards.tgz --prefix=notecards/ main)
mv notecards.tgz ${tarball_dir}
rm -rf notecards
fi
# Figure out release tags from tarball names
pushd ${tarball_dir} >/dev/null 2>/dev/null
medley_release=$(echo medley-*-loadups.tgz | sed "s/medley-\(.*\)-loadups.tgz/\1/")
maiko_release=$(echo maiko-*-linux.x86_64.tgz | sed "s/maiko-\(.*\)-linux.x86_64.tgz/\1/")
debs_filename_base="medley-full-${medley_release}_${maiko_release}"
popd >/dev/null 2>/dev/null
# For linux and wsl create packages for each arch
for wslp in linux wsl
do
# For each arch create a deb file
for arch_base in x86_64^amd64 armv7l^armhf aarch64^arm64
do
if [[ ${wslp} = wsl && ${arch_base} = armv7l^armhf ]];
then
continue
fi
arch=${arch_base%^*}
debian_arch=${arch_base#*^}
pkg_dir=tmp/pkg/${wslp}-${arch}
#
# Set up the pkg directories for this arch using the release tarballs
#
# Copy in the right control file, modifying as needed
rm -rf ${pkg_dir}
mkdir -p ${pkg_dir}
mkdir -p ${pkg_dir}/DEBIAN
sed \
-e "s/--ARCH--/${debian_arch}/" \
-e "s/--RELEASE--/${medley_release}_${maiko_release}/" \
<control-${wslp} >${pkg_dir}/DEBIAN/control
#
il_dir=${pkg_dir}/usr/local/interlisp
MEDLEYDIR=${il_dir#${pkg_dir}}/medley
# Maiko and Medley files to il_dir (/usr/local/interlisp)
mkdir -p ${il_dir}
tar -x -z -C ${il_dir} \
-f "${tarball_dir}/maiko-${maiko_release}-linux.${arch}.tgz"
tar -x -z -C ${il_dir} \
-f "${tarball_dir}/medley-${medley_release}-runtime.tgz"
tar -x -z -C ${il_dir} \
-f "${tarball_dir}/medley-${medley_release}-loadups.tgz"
tar -x -z -C ${il_dir} \
-f "${tarball_dir}/notecards.tgz"
# Copy the medley man page into place
man_dir="${pkg_dir}/usr/local/man/man1"
mkdir -p "${man_dir}"
cp -p "${il_dir}/medley/docs/man-page/medley.1.gz" "${man_dir}"
# Configure postinst and postrm scripts and put in place in DEBIAN dir
sed -e "s>--MEDLEYDIR-->${MEDLEYDIR}>g" <postinst >${pkg_dir}/DEBIAN/postinst
chmod +x ${pkg_dir}/DEBIAN/postinst
sed -e "s>--MEDLEYDIR-->${MEDLEYDIR}>g" <postrm >${pkg_dir}/DEBIAN/postrm
chmod +x ${pkg_dir}/DEBIAN/postrm
# For wsl scripts, include the vncviewer.exe
if [[ ${wslp} = wsl && ${arch} = x86_64 ]];
then
pushd ./tmp >/dev/null
rm -rf vncviewer64-1.12.0.exe
wget -q https://sourceforge.net/projects/tigervnc/files/stable/1.12.0/vncviewer64-1.12.0.exe
popd >/dev/null
mkdir -p ${il_dir}/wsl
cp -p tmp/vncviewer64-1.12.0.exe ${il_dir}/wsl/vncviewer64-1.12.0.exe
fi
#
# Make sure all files are owned by root
#
sudo su <<< "chown --recursive root:root ${il_dir}"
#
# Create tar file for this arch
#
filename="${debs_filename_base}-${wslp}-${arch}"
mkdir -p tars
echo "Creating tar file tars/${filename}.tgz"
tar -C ${il_dir} -czf tars/${filename}.tgz .
#
# Create the deb file for this arch
#
mkdir -p debs
deb_filepath="debs/${filename}.deb"
rm -rf "${deb_filepath}"
dpkg-deb --build -Zxz "${pkg_dir}" "${deb_filepath}"
#
done
done
# send just one line back to github $() construct
# do this by restoring fd 1 to what it was orginally
exec 1>&3
echo "${debs_filename_base}"