<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<installer-script authoringTool="Packages" authoringToolVersion="1.1" authoringToolBuild="2B57" minSpecVersion="1.0">
    <options rootVolumeOnly="true" customize="always"/>
    <installation-check script="installation_check()"/>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <background file="background" scaling="none" alignment="bottomleft"/>
    <welcome file="welcome.txt"/>
    <license file="license.txt"/>
    <conclusion file="conclusion.rtf"/>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1"/>
        <line choice="installer_choice_2"/>
	<line choice="start_gestures"/>
    </choices-outline>
    <choice id="installer_choice_1" start_enabled="false" start_selected="true" title="INSTALLER_CHOICE_1_TITLE" description="INSTALLER_CHOICE_1_DESCRIPTION">
        <pkg-ref id="com.touch-base.pkg.updd"/>
    </choice>
    <choice id="installer_choice_2" title="UPDD Gestures" description="INSTALLER_CHOICE_2_DESCRIPTION">
        <pkg-ref id="com.touch-base.pkg.upddgestures"/>
    </choice>
    <choice id="start_gestures" selected="choices.installer_choice_2.selected" visible="false">
	<pkg-ref id="com.smarttech.upddLaunchAgent.pkg"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="com.touch-base.pkg.updd" version="5.0.2" auth="Root" installKBytes="114548">#UPDD.pkg</pkg-ref>
    <pkg-ref id="com.touch-base.pkg.upddgestures" version="5.0.2" auth="Root" installKBytes="69902">#UPDD_Gestures.pkg</pkg-ref>
    <pkg-ref id="com.smarttech.upddLaunchAgent.pkg" version="1.0.0" auth="Root" installKBytes="1">#upddLaunchAgent.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

	const __IC_FLAT_DISTRIBUTION__=true;
	const IC_DISK_TYPE_DESTINATION=0;
	const IC_DISK_TYPE_STARTUP_DISK=1;
	const IC_OS_DISTRIBUTION_TYPE_ANY=0;
	const IC_OS_DISTRIBUTION_TYPE_CLIENT=1;
	const IC_OS_DISTRIBUTION_TYPE_SERVER=2;

	function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inDistributionType)
	{
		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;
		}
		
		/* Check Distribution Type */
		
		if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY)
		{
			var tIsServer;
			
			if (inDiskType==IC_DISK_TYPE_DESTINATION)
			{
				tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/System/Library/CoreServices/ServerVersion.plist');
			}
			else
			{
				tIsServer=system.files.fileExistsAtPath('/System/Library/CoreServices/ServerVersion.plist');
			}
			
			if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_CLIENT &amp;&amp; tIsServer==true)
			{
				return false;
			}
			
			if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_SERVER &amp;&amp; tIsServer==false)
			{
				return false;
			}
		}
		
		return true;
	}

	function installation_check()
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_STARTUP_DISK,true,'10.6',IC_OS_DISTRIBUTION_TYPE_ANY);

		if (tResult==false)
		{
			my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_1');
			my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_1');
			my.result.type = 'Fatal';
		}

		return tResult;
	}

    </script>
</installer-script>