joeylib2/installer/components/wing.sh

62 lines
2.2 KiB
Bash

# shellcheck shell=bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# Microsoft WinG 1.0, the fast DIB-to-screen blitter for Windows 3.1 that
# the win16 port uses when it is installed (src/hosted/win16): its runtime
# (WING.DLL, WINGDE.DLL, WINGDIB.DRV, WINGPAL.WND, and the DVA.386 virtual
# device) taken out of the WinG SDK, WING10.EXE, into toolchains/opt/wing;
# scripts/lib/win16Gate.sh installs it in each run's Windows as WinG's own
# setup would. The SDK's license lets you use it to develop and test
# software, and lets a program ship those runtime files only as part of
# itself (its LICENSE.TXT, kept beside them); it is not JoeyLib's to hand
# out, so it is a private file: ./install.sh import WING10.EXE. Microsoft
# no longer offers it; archive.org keeps a copy (archive.org/details/WING10).
# Optional (the port draws through GDI without it), so no group installs it:
# ./install.sh install wing.
compDescription="win16: Microsoft WinG 1.0 runtime for its Windows (optional; private: import WING10.EXE)"
compGroups="optional"
compRequires="win311"
compHostDeps="python3 unzip"
compPrivateFile="toolchains/firmware/win16/WING10.EXE"
compPin="$(privateSha1For "$compPrivateFile")"
wingRuntime="WING.DLL WINGDE.DLL WINGDIB.DRV WINGPAL.WND DVA.386"
compInstall() {
local tmp
local file
privateEnsure "$compPrivateFile"
tmp="$(mktemp -d)"
unzip -qq -o "$JOEY_REPO/$compPrivateFile" -d "$tmp" || { rm -rf "$tmp"; die "WING10.EXE did not unpack"; }
rm -rf "$compDir"
mkdir -p "$compDir"
# The SDK's compressed names end in _ where the last letter was.
for file in $wingRuntime; do
python3 "$JOEY_REPO/tools/szddExpand.py" "$tmp/${file%?}_" "$compDir/$file" || { rm -rf "$tmp"; die "$file did not expand"; }
done
cp "$tmp/LICENSE.TXT" "$compDir/LICENSE.TXT"
rm -rf "$tmp"
}
compInstalled() {
[ -s "$compDir/WING.DLL" ] && [ -s "$compDir/DVA.386" ]
}
compVerify() {
local file
for file in $wingRuntime; do
[ "$(head -c 2 "$compDir/$file")" = "MZ" ] || return 1
done
LC_ALL=C grep -q -a 'WINGDE' "$compDir/WING.DLL"
}
compEnv() {
envVar WING_DIR "$compDir"
}