<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.6" authoringToolBuild="549" minSpecVersion="1.0">
    <options rootVolumeOnly="true" customize="never"/>
    <volume-check script="volume_check()"/>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1"/>
        <line choice="installer_choice_2"/>
    </choices-outline>
    <choice id="installer_choice_1" title="SamsungPortableSSDDriverT" description="">
        <pkg-ref id="com.samsung.portablessd.driverpkg"/>
    </choice>
    <choice id="installer_choice_2" start_visible="installer_choice_2_requirement(true,false)" start_enabled="installer_choice_2_requirement(false,true)" start_selected="installer_choice_2_requirement(false,false)" title="SamsungPortableSSDDriverX" description="">
        <pkg-ref id="com.samsung.portablessd.driverXpkg"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="com.samsung.portablessd.driverXpkg" version="1.5.09" auth="Root" installKBytes="87" onConclusion="RequireRestart">#SamsungPortableSSDDriverX.pkg</pkg-ref>
    <pkg-ref id="com.samsung.portablessd.driverpkg" version="1.5.03" auth="Root" installKBytes="104" onConclusion="RequireRestart">#SamsungPortableSSDDriverT.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

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

	function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inMaximumVersion,inDistributionType)
	{
		var tOSVersion=undefined;
		
		/* Check Version Constraints */
		
		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);
			}
			
			if (inMustBeInstalled==false)
			{
				return false;
			}
		}
		else
		{
			tOSVersion=system.version.ProductVersion;
		}
		
		if (system.compareVersions(tOSVersion,inMinimumVersion)==-1)
			return false;
			
		if (inMaximumVersion!=undefined &amp;&amp;
			system.compareVersions(tOSVersion,inMaximumVersion)==1)
			return false;
		
		/* Check Distribution Type */
		
		if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY)
		{
			var tIsServer;
			
			if (system.compareVersions(tOSVersion,'10.8.0')==-1)
			{
				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');
				}
			}
			else
			{
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/Applications/Server.app');
				}
				else
				{
					tIsServer=system.files.fileExistsAtPath('/Applications/Server.app');
				}
			}
			
			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 volume_check()
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.7',undefined,IC_OS_DISTRIBUTION_TYPE_ANY);

		if (tResult==false)
		{
			my.result.type = 'Fatal';
		}

		return tResult;
	}

	function installer_choice_2_requirement(inCheckVisibilityOnly,inShowFailedToolTip)
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.12',undefined,IC_OS_DISTRIBUTION_TYPE_ANY);


		return tResult;
	}

    </script>
</installer-gui-script>