#!/bin/sh # VexelRay preflight installer for Linux - generated by vexelray-installer. Do not edit by hand; regenerate it. # # curl -fsSL https://raw.githubusercontent.com/sibarum/vexelray-dist/main/preflight/install.sh | sh # # Installs every application in the suite, each as an install of its own: its own folder, its own # updater and uninstaller. This script installs nothing itself. For each application it fetches the # published install manifest, downloads that application's own install.sh, checks it against the # SHA-256 the manifest records, and runs it. # # Options, as environment variables for the sh that runs this (curl -fsSL | INSTALL_ONLY=a,b sh): # INSTALL_ONLY=a,b install only these applications (text-editor, pix, mainframe, calculator, inspector); an optional one is # installed only when named here, or kept up to date once installed # INSTALL_NO_SHORTCUTS=1 passed on to every application's installer # INSTALL_NO_PATH=1 " # INSTALL_NO_ASSOCIATIONS=1 " # INSTALL_FORCE=1 " # INSTALL_SKIP_CHECKS=1 " # INSTALL_EVERYTHING=1 the optional applications too, like the rest # Or as arguments: curl -fsSL | sh -s -- --install-everything # INSTALL_VERSION and INSTALL_DIR name one application's version and folder, so they are not passed # on: run that application's own installer to use them. An application this script pins to a version # (a preflight of snapshot builds) is installed at that version, and reinstalled even when it is current. VI_SUITE='VexelRay preflight' # vi_member ID NAME MANIFEST-URL PINNED-VERSION OPTIONAL HAS-LINUX REGISTRY-DIR, in install order vi_members() { vi_member 'vexplore' 'Vexplore' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/vexplore/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 0 '-' vi_member 'text-editor' 'Vex' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/text-editor/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 1 '$XDG_DATA_HOME/vexelray-installer/installs' vi_member 'pix' 'Pix' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/pix/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 1 '$XDG_DATA_HOME/vexelray-installer/installs' vi_member 'mainframe' 'MainFrame' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/mainframe/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 1 '$XDG_DATA_HOME/vexelray-installer/installs' vi_member 'calculator' 'Calculator' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/calculator/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 1 '$XDG_DATA_HOME/vexelray-installer/installs' vi_member 'fluid-sim' 'Fluid Sim' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/fluid-sim/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 0 '-' vi_member 'rigid-sim' 'Rigid Sim' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/rigid-sim/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 0 '-' vi_member 'maistro' 'Maistro' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/maistro/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 0 '-' vi_member 'inspector' 'VexelRay Inspector' 'https://raw.githubusercontent.com/sibarum/vexelray-dist/main/apps/inspector/manifest.linux.txt' '0.1.2-SNAPSHOT' 0 1 '$XDG_DATA_HOME/vexelray-installer/installs' } set -u vi_tab=$(printf '\t') vi_tmp= vi_say() { printf '%s\n' "$*"; } vi_warn() { printf 'Warning: %s\n' "$*" >&2; } vi_die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; } vi_member() { (IFS="$vi_tab"; printf '%s\n' "$*") >> "$vi_tmp/members"; } vi_expand() { printf '%s\n' "$1" | awk '{ s = $0; out = "" if (s == "~" || substr(s, 1, 2) == "~/") { out = ENVIRON["HOME"]; s = substr(s, 2) } while (match(s, /\$\{[A-Za-z_][A-Za-z0-9_]*\}|\$[A-Za-z_][A-Za-z0-9_]*/)) { v = substr(s, RSTART, RLENGTH); gsub(/[${}]/, "", v) out = out substr(s, 1, RSTART - 1) ENVIRON[v]; s = substr(s, RSTART + RLENGTH) } print out s }' } vi_sha() { if command -v sha256sum >/dev/null 2>&1; then sha256sum < "$1" | cut -d' ' -f1 else shasum -a 256 < "$1" | cut -d' ' -f1; fi } vi_get() { if command -v curl >/dev/null 2>&1; then curl -fsSL --retry 3 --connect-timeout 30 -o "$2" "$1" else wget -q --tries=3 -O "$2" "$1"; fi } vi_main() { vi_everything=${INSTALL_EVERYTHING:-0} while [ $# -gt 0 ]; do case $1 in --install-everything) vi_everything=1 ;; --do-not-prompt-me|--quiet|-Quiet) ;; *) vi_warn "Ignoring unknown argument: $1" ;; esac shift done if [ "$(uname -s 2>/dev/null)" != Linux ] && [ "${INSTALL_ANY_OS:-0}" = 0 ]; then vi_die "This is the Linux installer of $VI_SUITE. On Windows, run the PowerShell command from the same page." fi [ -n "${HOME:-}" ] || vi_die "HOME is not set." command -v curl >/dev/null 2>&1 || command -v wget >/dev/null 2>&1 || vi_die "Neither curl nor wget is installed; install one of them." export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" vi_tmp=$(mktemp -d "${TMPDIR:-/tmp}/vi-suite.XXXXXX") || vi_die "Cannot create a temporary folder." trap 'rm -rf -- "$vi_tmp"' EXIT trap 'exit 1' INT TERM HUP : > "$vi_tmp/members" vi_members vi_only=$(printf '%s' "${INSTALL_ONLY:-}" | tr 'A-Z,; ' 'a-z\n\n\n' | awk 'NF') if [ -n "$vi_only" ]; then vi_unknown=$(printf '%s\n' "$vi_only" | awk -F'\t' 'FNR == NR { known[$1] = 1; next } !($1 in known)' "$vi_tmp/members" -) [ -z "$vi_unknown" ] || vi_die "INSTALL_ONLY names $(printf '%s\n' "$vi_unknown" | awk '{ printf "%s%s", s, $0; s = ", " }'), which the suite does not have. It has: $(awk -F'\t' '{ printf "%s%s", s, $1; s = ", " }' "$vi_tmp/members")" fi for vi_n in INSTALL_VERSION INSTALL_DIR; do eval "vi_set=\${$vi_n:-}" [ -n "$vi_set" ] && vi_warn "$vi_n names one application's version or folder, so it is not passed on; run that application's own installer to use it." done vi_done=; vi_failed=; vi_missing= while IFS="$vi_tab" read -r vi_id vi_name vi_url vi_pin vi_opt vi_lin vi_reg; do vi_named=0 if [ -n "$vi_only" ] && printf '%s\n' "$vi_only" | grep -qx "$vi_id"; then vi_named=1; fi if [ "$vi_lin" = 0 ]; then [ "$vi_named" = 1 ] && vi_say "$vi_name has no Linux version yet; skipped." continue fi vi_regdir=${INSTALL_REGISTRY_DIR:-} [ -n "$vi_regdir" ] || vi_regdir=$(vi_expand "$vi_reg") vi_installed=0 [ -f "$vi_regdir/$vi_id.state" ] && vi_installed=1 if [ -n "$vi_only" ]; then [ "$vi_named" = 1 ] || continue elif [ "$vi_opt" = 1 ] && [ "$vi_installed" = 0 ] && [ "$vi_everything" = 0 ]; then vi_say "$vi_name is optional and not installed; name it in INSTALL_ONLY, or pass --install-everything, to install it." continue fi vi_say "" vi_say "=== $vi_name" vi_mf="$vi_tmp/$vi_id.txt" if ! vi_get "$vi_url" "$vi_mf" || [ "$(head -n 1 "$vi_mf")" != "vexelray-installer-linux${vi_tab}1" ]; then vi_warn "$vi_name has not been published for Linux yet; skipped." vi_missing="$vi_missing${vi_missing:+, }$vi_name" continue fi if [ "$vi_pin" != - ] && ! awk -F'\t' -v v="$vi_pin" '$1 == "version" && $2 == v { f = 1 } END { exit !f }' "$vi_mf"; then vi_warn "$vi_name $vi_pin has not been published yet; skipped." vi_missing="$vi_missing${vi_missing:+, }$vi_name $vi_pin" continue fi vi_t=$(awk -F'\t' '$1 == "tool" && $2 == "install.sh"' "$vi_mf") IFS="$vi_tab" read -r _ _ vi_tsha vi_turl <