<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
    <domains enable_localSystem="true"/>
    <options rootVolumeOnly="true" customize="never" hostArchitectures="i386">
        <platforms>
            <server arch="i386"/>
            <client arch="i386"/>
        </platforms>
    </options>
    <allowed-os-versions>
        <os-version min="10.6"/>
    </allowed-os-versions>
    <title>DISTRIBUTION_TITLE</title>
    <background file="background.tiff" alignment="topleft" scaling="none"/>
    <choices-outline>
        <line choice="default"/>
        <!-- not shown to user -->
    </choices-outline>
    <choice id="default" title="VMware OVF Tool" description="">
        <pkg-ref id="com.vmware.ovftool.application"/>
    </choice>
    <welcome file="Welcome.rtf"/>
    <license file="License.rtf"/>
    <installation-check script="installation_check()"/>
    <volume-check script="volume_check()"/>
    <pkg-ref id="com.vmware.ovftool.application" version="4.4" installKBytes="80935">#files.pkg</pkg-ref>
    <script>
      const IC_DISK_TYPE_DESTINATION  = 0;
      const IC_DISK_TYPE_STARTUP_DISK = 1;

      function installation_check()
      {
         var tResult = IC_CheckOS(IC_DISK_TYPE_STARTUP_DISK, true, '10.6');
         if (!tResult) {
            my.result.title = system.localizedStandardStringWithFormat('InstallationCheckError', system.localizedString('DISTRIBUTION_TITLE'));
            my.result.message = ' ';
            my.result.type = 'Fatal';
         } else {
            tResult = IC_CheckCPU();
            if (!tResult) {
               my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK');
               my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK');
               my.result.type = 'Fatal';
            }
         }

         return tResult;
      }


      function volume_check()
      {
         var tResult = IC_CheckOS(IC_DISK_TYPE_DESTINATION, true, '10.6');

         if (!tResult) {
            my.result.message = system.localizedString('REQUIREMENT_FAILED_MESSAGE_VOLUME_CHECK');
            my.result.type = 'Fatal';
         }

         return tResult;
      }

      function IC_CheckOS(inDiskType,
                          inMustBeInstalled,
                          inMinimumVersion)
      {
         var tOSVersion = undefined;

         /* Check Minimum Version */

         if (inDiskType == IC_DISK_TYPE_DESTINATION) {
            if (my.target.systemVersion != undefined) {
               tOSVersion = my.target.systemVersion.ProductVersion;
            }

            /* Check if no OS is installed on the potential target */

            if (tOSVersion == undefined) {
               return (inMustBeInstalled == false);
            }
         } else {
            tOSVersion = system.version.ProductVersion;
         }

         if (system.compareVersions(tOSVersion, inMinimumVersion) == -1) {
            return false;
         }

         return true;
      }

      const IC_CPU_ARCHITECTURE_INTEL = 7;

      function IC_CheckCPU()
      {
         if (system.sysctl('hw.cputype') != IC_CPU_ARCHITECTURE_INTEL) {
            return false;
         }

         return true;
      }

   </script>
    <pkg-ref id="com.vmware.ovftool.application">
        <bundle-version/>
    </pkg-ref>
    <product id="com.vmware.ovftool.application" version="4.4"/>
</installer-gui-script>