<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>trailSailServer</title>
    <organization>co.uk.yard8</organization>
    <domains enable_localSystem="true"/>
    <options customize="never" require-scripts="true" rootVolumeOnly="true" hostArchitectures="arm64"/>
    <welcome file="welcome.txt" mime-type="text/plain"/>
    <license file="license.txt" mime-type="text/plain"/>
    <conclusion file="conclusion.txt" mime-type="text/plain"/>
    <installation-check script="checkPrereqs()"/>
    <script><![CDATA[
    function checkPrereqs() {
      if (system.compareVersions(system.version.ProductVersion, '14.0') < 0) {
        my.result.title = 'macOS 14 or later is required';
        my.result.message = 'trailSailServer runs Splash and llama.cpp, which need macOS 14 on Apple Silicon.';
        my.result.type = 'Fatal';
        return false;
      }
      if (!system.files.fileExistsAtPath('/Applications/Tailscale.app') &&
          !system.files.fileExistsAtPath('/opt/homebrew/bin/tailscale') &&
          !system.files.fileExistsAtPath('/usr/local/bin/tailscale')) {
        my.result.title = 'Tailscale is not installed';
        my.result.message = 'Install Tailscale from tailscale.com/download/mac, sign in to your tailnet, then run this installer again. TrailSail reaches this Mac only through Tailscale.';
        my.result.type = 'Fatal';
        return false;
      }
      if (!system.files.fileExistsAtPath('/opt/homebrew/bin/brew') &&
          !system.files.fileExistsAtPath('/usr/local/bin/brew')) {
        my.result.title = 'Homebrew is not installed';
        my.result.message = 'Install Homebrew first (the one-line command at brew.sh), then run this installer again. Splash and llama.cpp are installed with it.';
        my.result.type = 'Fatal';
        return false;
      }
      return true;
    }
  ]]></script>
    <pkg-ref id="co.uk.yard8.trailsailserver">
        <bundle-version/>
    </pkg-ref>
    <choices-outline>
        <line choice="default">
            <line choice="co.uk.yard8.trailsailserver"/>
        </line>
    </choices-outline>
    <choice id="default"/>
    <choice id="co.uk.yard8.trailsailserver" visible="false">
        <pkg-ref id="co.uk.yard8.trailsailserver"/>
    </choice>
    <pkg-ref id="co.uk.yard8.trailsailserver" version="0.4.1" onConclusion="none" installKBytes="215" updateKBytes="0">#trailSailServer-component.pkg</pkg-ref>
</installer-gui-script>