Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ room-specific graphics profiles and managed runtime overrides. Live rooms wait
until their running programs finish. No component or Windows-version selection
is exposed in the normal interface. Concurrent starts share preparation; failed
preparation never produces a ready marker and can be retried.
After an engine update, a room whose required files and components are complete
receives the engine/registry/graphics refresh without rerunning its installers.
A failed refresh keeps the previous completion marker so the next launch retries.
EXE, MSI and LNK imports share this launch path, including Finder's Open With.
Portable applications retain their working directory and must keep their complete
folder. Installers are tracked with their child processes, and newly installed
Expand Down Expand Up @@ -352,6 +355,15 @@ the new engine on their next launch. If `~/WinMac_Virtual` is an unmodified git
scripts are updated with `git pull --ff-only` as well. The check can be turned off
in the settings; without a window: `"Virtual.app/Contents/MacOS/Virtual" --update`.

Release packaging checks the installed Mac driver's foreground-clearing API
import. Candidate builds install the completed Wine build into staging and copy
all rebuilt artifacts into the isolated runtime, preserving additional graphics
and media libraries. The bundle gate also compares packaged setup scripts and
baseline manifests with the source checkout, so preparation fixes require a
matching engine. The symbol check covers the known stale-driver regression.
App-switch and desktop-lifecycle acceptance checks remain part of runtime testing
in [the foreground probe instructions](winrt/tests/README-foreground-desktop-probe.md).

Publish a new version (requires the GitHub CLI `gh`):

```bash
Expand Down
19 changes: 5 additions & 14 deletions scripts/build-compat-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,14 @@ fi
echo "==> Kandidat $CANDIDATE (Klon von runtime/)…"
rm -rf "$CANDIDATE"
cp -cR "$ROOT/runtime" "$CANDIDATE"
replaced=0
# Refresh the whole completed build. Deployment-target checks alone cannot
# distinguish a current driver from an older implementation targeting macOS 13.
"$ROOT/scripts/install-candidate-wine.sh" "$COMPAT" "$CANDIDATE" >>"$LOG" 2>&1
while IFS= read -r -d '' f; do
m="$(minos "$f")"; [ -n "$m" ] && newer "$m" || continue
rel="${f#$CANDIDATE/wine-build/}"; name="$(basename "$f")"; src=""
case "$rel" in
lib/wine/x86_64-unix/wine) src="$COMPAT/loader/wine" ;;
lib/wine/x86_64-unix/*.so) src="$(find "$COMPAT/dlls" -maxdepth 2 -name "$name" -type f | head -1)" ;;
bin/wineserver) src="$COMPAT/server/wineserver" ;;
bin/wine) src="$COMPAT/tools/wine/wine" ;;
bin/*) src="$(find "$COMPAT/tools" -maxdepth 2 -name "$name" -type f | head -1)" ;;
case "$(file -b "$f")" in
*Mach-O*) codesign -f -s - "$f" >/dev/null 2>&1 ;;
esac
case "$name" in winemetal.so) continue ;; esac # DXMT (eigener Build, braucht ohnehin macOS 15)
[ -n "$src" ] && [ -f "$src" ] || { echo "Kein neu gebautes Gegenstück für $rel" >&2; exit 1; }
rm -f "$f"; cp "$src" "$f"; codesign -f -s - "$f" >/dev/null 2>&1
replaced=$((replaced + 1))
done < <(find "$CANDIDATE/wine-build" -type f \( -name '*.so' -o -perm -u+x \) -print0)
echo " ersetzt: $replaced Dateien"
# Wie scripts/bundle-gstreamer.sh: winegstreamer.so findet das gebündelte GStreamer unter lib/gst.
GSO="$CANDIDATE/wine-build/lib/wine/x86_64-unix/winegstreamer.so"
if [ -f "$GSO" ] && ! otool -l "$GSO" | grep -q "@loader_path/../../gst"; then
Expand Down
14 changes: 14 additions & 0 deletions scripts/check-bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ def require_bundle(bundle):
return plistlib.load(f)


def require_current_engine_scripts(engine):
# App-only releases can reuse an engine, but a changed preparation script
# must reach users together with the app that was tested against it.
for relative in ('scripts/init-prefix.sh', 'scripts/prepare-room.py',
'scripts/setup-dotnet48.sh', 'scripts/setup-webview2.sh',
'scripts/setup-dependencies.sh', 'scripts/install-dotnet-runtime.py',
'support/runtime-baseline.json', 'support/components.lock.json',
'setup-graphics.sh'):
packaged = engine / relative
if not packaged.is_file() or digest(packaged) != digest(ROOT / relative):
raise ValueError(f'Engine contains stale or missing setup assets: {relative}')


def git(*args):
return subprocess.check_output(['git', '-C', str(ROOT), *args]).decode().strip()

Expand All @@ -90,6 +103,7 @@ def main():
# A failed retry must never leave a stale successful receipt at this path.
receipt.unlink(missing_ok=True)
info = require_bundle(bundle)
require_current_engine_scripts(bundle / 'Contents/Resources/Engine')
subprocess.run(['codesign', '--verify', '--deep', '--strict', str(bundle)], check=True)
before, entries = inventory(bundle)
revision = git('rev-parse', 'HEAD')
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ -z "${DEVELOPER_DIR:-}" ] && [ -d /Applications/Xcode.app/Contents/Develope
fi
(cd app && swift test)
uv run --with pyyaml python -m unittest discover -s scripts/tests -v
python3 -m unittest discover -s scripts -p test_dotnet_cache.py -v
uv run --with pyyaml python -m unittest discover -s scripts -p test_dotnet_cache.py -v
python3 scripts/test-window-levels.py

# Prefer the engine bundled in the local app. WINMAC_HOME can select a candidate.
Expand Down
23 changes: 23 additions & 0 deletions scripts/install-candidate-wine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Install one completed Wine build into an existing isolated runtime candidate.
set -euo pipefail
BUILD="${1:?Wine build directory required}"
CANDIDATE="${2:?Candidate runtime directory required}"
[ -d "$CANDIDATE/wine-build" ] || { echo "Candidate runtime is missing wine-build." >&2; exit 1; }
STAGE="$(mktemp -d "${TMPDIR:-/tmp}/virtual-wine-install.XXXXXX")"
trap 'rm -rf "$STAGE"' EXIT
if [ -f "$CANDIDATE/wine-build/share/wine/wine.inf" ]; then
cp -p "$CANDIDATE/wine-build/share/wine/wine.inf" "$STAGE/previous-wine.inf"
fi
make -C "$BUILD" install DESTDIR="$STAGE"
INSTALLED="$(find "$STAGE" -type d -name wine-build -prune | head -1)"
[ -n "$INSTALLED" ] && [ -x "$INSTALLED/bin/wine" ] || {
echo "Staged Wine install is missing bin/wine." >&2; exit 1;
}
# Copy every rebuilt artifact, including binaries whose deployment target was
# already supported. Keep the candidate's additional graphics/media libraries.
rsync -a -c "$INSTALLED/" "$CANDIDATE/wine-build/"
INF="$CANDIDATE/wine-build/share/wine/wine.inf"
if [ -f "$STAGE/previous-wine.inf" ] && cmp -s "$STAGE/previous-wine.inf" "$INF"; then
touch -r "$STAGE/previous-wine.inf" "$INF"
fi
7 changes: 7 additions & 0 deletions scripts/package-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ DEST="${1:?Destination Engine directory required}"
[ "$(basename "$DEST")" = Engine ] || { echo "Destination must be named Engine." >&2; exit 1; }
RUNTIME="${WINMAC_RUNTIME:-$ROOT/runtime}"
[ -x "$RUNTIME/wine-build/bin/wine" ] || { echo "A source-built Wine engine is required for releases." >&2; exit 1; }
# A build-only Wine run leaves the installed runtime unchanged. Check the driver
# being packaged, since the old foreground path can shut down kiosk desktops.
MAC_DRIVER="$RUNTIME/wine-build/lib/wine/x86_64-unix/winemac.so"
nm -u "$MAC_DRIVER" | awk '$NF == "_NtUserSetForegroundWindow" { found = 1 } END { exit !found }' || {
echo "The installed Mac driver lacks the foreground-clearing API. Rebuild and install Wine before packaging (without WINMAC_BUILD_ONLY=1)." >&2
exit 1
}
[ -f "$RUNTIME/wine-build/share/wine/mono/wine-mono-10.4.1/support/winemono-support.msi" ] || {
echo "Wine Mono is missing; run scripts/setup-managed-runtime.sh first." >&2; exit 1;
}
Expand Down
17 changes: 17 additions & 0 deletions scripts/tests/test_check_bundle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""A passing receipt must identify exact portable bundle bytes."""
import importlib.util
import shutil
from pathlib import Path
import tempfile
import unittest
Expand Down Expand Up @@ -55,6 +56,22 @@ def test_bundle_without_engine_cannot_be_certified(self):
with self.assertRaisesRegex(ValueError, 'Unvollständiges'):
gate.require_bundle(root)

def test_current_engine_scripts_are_accepted_and_stale_preparation_is_rejected(self):
with tempfile.TemporaryDirectory() as temporary:
engine = Path(temporary)
for relative in ('scripts/init-prefix.sh', 'scripts/prepare-room.py',
'scripts/setup-dotnet48.sh', 'scripts/setup-webview2.sh',
'scripts/setup-dependencies.sh', 'scripts/install-dotnet-runtime.py',
'support/runtime-baseline.json', 'support/components.lock.json',
'setup-graphics.sh'):
target = engine / relative
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(gate.ROOT / relative, target)
gate.require_current_engine_scripts(engine)
(engine / 'scripts/prepare-room.py').write_text('old preparation implementation')
with self.assertRaisesRegex(ValueError, 'scripts/prepare-room.py'):
gate.require_current_engine_scripts(engine)

def test_failed_retry_invalidates_previous_success_receipt(self):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
Expand Down
112 changes: 112 additions & 0 deletions scripts/tests/test_engine_packaging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""Exercise candidate installation and the packaged Mac driver's import gate."""
from pathlib import Path
import os
import shutil
import subprocess
import sys
import tempfile
import unittest

ROOT = Path(__file__).resolve().parents[2]


@unittest.skipUnless(shutil.which('make') and shutil.which('rsync'), 'make and rsync required')
class CandidateInstallationTests(unittest.TestCase):
def test_complete_build_replaces_old_artifacts_and_preserves_additional_libraries(self):
with tempfile.TemporaryDirectory(prefix='virtual-candidate-') as temporary:
root = Path(temporary)
build = root / 'build with spaces'
candidate = root / 'candidate runtime'
staged = build / 'artifacts/wine-build'
existing = candidate / 'wine-build'
for base in (staged, existing):
(base / 'bin').mkdir(parents=True)
(base / 'lib/wine/x86_64-unix').mkdir(parents=True)
(base / 'share/wine').mkdir(parents=True)
(base / 'bin/wine').write_text('#!/bin/sh\nexit 0\n')
(base / 'bin/wine').chmod(0o755)
(base / 'share/wine/wine.inf').write_text('unchanged wine.inf')
old = existing / 'lib/wine/x86_64-unix/winemac.so'
fresh = staged / 'lib/wine/x86_64-unix/winemac.so'
old.write_bytes(b'old driver with an already-supported minimum OS')
fresh.write_bytes(b'rebuilt driver with the same supported minimum OS')
extra = existing / 'lib/wine/x86_64-unix/winemetal.so'
extra.write_bytes(b'additional graphics bridge')
inf = existing / 'share/wine/wine.inf'
os.utime(inf, (1600000000, 1600000000))
before_mtime = inf.stat().st_mtime_ns
(build / 'Makefile').write_text(
'install:\n\tmkdir -p "$(DESTDIR)/configured prefix"\n'
'\tcp -R artifacts/wine-build "$(DESTDIR)/configured prefix/"\n')
subprocess.run(['bash', str(ROOT / 'scripts/install-candidate-wine.sh'),
str(build), str(candidate)], check=True, capture_output=True)
self.assertEqual(old.read_bytes(), fresh.read_bytes())
self.assertEqual(extra.read_bytes(), b'additional graphics bridge')
self.assertEqual(inf.stat().st_mtime_ns, before_mtime)

def test_incomplete_staged_install_preserves_candidate(self):
with tempfile.TemporaryDirectory(prefix='virtual-candidate-incomplete-') as temporary:
root = Path(temporary)
build = root / 'build'
existing = root / 'candidate/wine-build'
build.mkdir()
existing.mkdir(parents=True)
sentinel = existing / 'driver'
sentinel.write_bytes(b'previous working runtime')
(build / 'Makefile').write_text('install:\n\tmkdir -p "$(DESTDIR)/configured/wine-build"\n')
result = subprocess.run(['bash', str(ROOT / 'scripts/install-candidate-wine.sh'),
str(build), str(existing.parent)], capture_output=True, text=True)
self.assertNotEqual(result.returncode, 0)
self.assertIn('missing bin/wine', result.stderr)
self.assertEqual(sentinel.read_bytes(), b'previous working runtime')

def test_failed_install_preserves_candidate(self):
with tempfile.TemporaryDirectory(prefix='virtual-candidate-failed-') as temporary:
root = Path(temporary)
build = root / 'build'
existing = root / 'candidate/wine-build'
build.mkdir()
existing.mkdir(parents=True)
sentinel = existing / 'driver'
sentinel.write_bytes(b'previous working runtime')
(build / 'Makefile').write_text('install:\n\texit 23\n')
result = subprocess.run(['bash', str(ROOT / 'scripts/install-candidate-wine.sh'),
str(build), str(existing.parent)], capture_output=True)
self.assertNotEqual(result.returncode, 0)
self.assertEqual(sentinel.read_bytes(), b'previous working runtime')


@unittest.skipUnless(sys.platform == 'darwin' and shutil.which('clang'), 'Mach-O compiler required')
class DriverPackagingTests(unittest.TestCase):
def check_driver(self, symbol):
with tempfile.TemporaryDirectory(prefix='virtual-driver-gate-') as temporary:
root = Path(temporary)
runtime = root / 'runtime'
driver = runtime / 'wine-build/lib/wine/x86_64-unix/winemac.so'
driver.parent.mkdir(parents=True)
wine = runtime / 'wine-build/bin/wine'
wine.parent.mkdir(parents=True)
wine.write_text('#!/bin/sh\nexit 0\n')
wine.chmod(0o755)
source = root / 'driver.c'
source.write_text(f'extern void {symbol}(void);\nvoid deactivate(void) {{ {symbol}(); }}\n')
subprocess.run(['clang', '-dynamiclib', '-Wl,-undefined,dynamic_lookup',
str(source), '-o', str(driver)], check=True, capture_output=True)
return subprocess.run(['bash', str(ROOT / 'scripts/package-engine.sh'), str(root / 'Engine')],
env=dict(os.environ, WINMAC_RUNTIME=str(runtime)),
capture_output=True, text=True)

def test_old_foreground_driver_is_rejected_before_packaging(self):
result = self.check_driver('NtUserCallHwnd')
self.assertNotEqual(result.returncode, 0)
self.assertIn('lacks the foreground-clearing API', result.stderr)

def test_correct_import_passes_driver_gate_and_reaches_dependency_checks(self):
result = self.check_driver('NtUserSetForegroundWindow')
self.assertNotEqual(result.returncode, 0)
self.assertIn('Wine Mono is missing', result.stderr)
self.assertNotIn('lacks the foreground-clearing API', result.stderr)


if __name__ == '__main__':
unittest.main()
25 changes: 25 additions & 0 deletions scripts/tests/test_runtime_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,31 @@ def test_engine_update_migrates_every_existing_room_and_preserves_each_room_data
self.assertEqual((second / 'drive_c/two.txt').read_text(), 'second room')
self.assertTrue(last.health(second))

def test_complete_room_refreshes_after_engine_update_without_running_installers(self):
self.prepare()
before = self.operations()
self.write(self.assets / 'engine-version', 'updated-engine')
self.prepare()
self.assertEqual([op[0] for op in self.operations()[len(before):]], ['init'])
self.assertEqual(len(list((self.root / '.virtual/system-bases').glob('*/ready'))), 1)

def test_failed_refresh_keeps_old_marker_and_can_be_retried(self):
self.prepare()
marker = self.prefix / '.virtual/runtime-baseline'
old = marker.read_text()
self.write(self.assets / 'engine-version', 'updated-engine')
init = self.assets / 'scripts/init-prefix.sh'
original = init.read_text()
self.write(init, '#!/bin/sh\nexit 23\n', executable=True)
with self.assertRaisesRegex(RuntimeError, 'status 23'):
self.prepare()
self.assertEqual(marker.read_text(), old)
self.write(init, original, executable=True)
retry = self.prepare()
self.assertEqual(marker.read_text(), retry.version)
self.assertNotEqual(marker.read_text(), old)
self.assertEqual([op[0] for op in self.operations()], ['init', 'dotnet48', 'components', 'init'])

def test_failed_common_base_cannot_create_a_partially_supported_room(self):
self.write(self.root / 'fail', 'installer failure')
with self.assertRaisesRegex(RuntimeError, 'status 23'):
Expand Down
13 changes: 1 addition & 12 deletions scripts/update-candidate-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,21 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CANDIDATE="$ROOT/${1:-runtime-next}"
BUILD="$ROOT/thirdparty/wine-cx-build"
STAGE="$(mktemp -d "${TMPDIR:-/tmp}/virtual-stage.XXXXXX")"
trap 'rm -rf "$STAGE"' EXIT
export PATH=/opt/homebrew/opt/bison/bin:/opt/homebrew/opt/flex/bin:/opt/homebrew/bin:$PATH

echo "==> Baue $BUILD"
nice -n 10 make -C "$BUILD" -j"$(sysctl -n hw.perflevel0.physicalcpu 2>/dev/null || echo 4)" >"$BUILD/make-candidate.out" 2>&1 ||
{ tail -20 "$BUILD/make-candidate.out"; exit 1; }
make -C "$BUILD" install DESTDIR="$STAGE" >"$BUILD/install-candidate.out" 2>&1
INSTALLED="$(find "$STAGE" -type d -name wine-build -prune | head -1)"
[ -x "$INSTALLED/bin/wine" ] || { echo "make install ohne bin/wine"; exit 1; }

echo "==> Kandidat $CANDIDATE (Klon von runtime/)"
rm -rf "$CANDIDATE"
cp -cR "$ROOT/runtime" "$CANDIDATE"
# Nur geänderte Inhalte übernehmen; zusätzliche Dateien (gst, icu, winemetal) bleiben.
rsync -a -c "$INSTALLED/" "$CANDIDATE/wine-build/" --itemize-changes | { grep -c '^>f' || true; } | sed 's/^/ geänderte Dateien: /'
"$ROOT/scripts/install-candidate-wine.sh" "$BUILD" "$CANDIDATE" >"$BUILD/install-candidate.out" 2>&1
bash "$ROOT/scripts/bundle-gstreamer.sh" "$CANDIDATE/wine-build" >/dev/null
for arch in x86_64 i386; do
[ -f "$ROOT/thirdparty/icu/out/$arch-windows/icu.dll" ] || continue
mkdir -p "$CANDIDATE/wine-build/lib/icu/$arch-windows"
cp "$ROOT/thirdparty/icu/out/$arch-windows/"{icu,icuuc,icuin}.dll "$CANDIDATE/wine-build/lib/icu/$arch-windows/"
done
"$ROOT/scripts/write-runtime-wrappers.sh" "$CANDIDATE"
if cmp -s "$ROOT/runtime/wine-build/share/wine/wine.inf" "$CANDIDATE/wine-build/share/wine/wine.inf"; then
touch -r "$ROOT/runtime/wine-build/share/wine/wine.inf" "$CANDIDATE/wine-build/share/wine/wine.inf"
else
echo " Hinweis: wine.inf hat sich geändert – Räume aktualisieren sich beim nächsten Start."
fi
echo "==> Fertig: $CANDIDATE ($("$CANDIDATE/wine-build/bin/wine" --version))"
Loading
Loading