<?xml version="1.0" encoding="UTF-8"?>
<installer-script authoringTool="Packages" authoringToolVersion="1.1" authoringToolBuild="2B57" minSpecVersion="1.0">
    <options rootVolumeOnly="true" customize="always"/>
    <installation-check script="installation_check()"/>
    <volume-check script="volume_check()"/>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <background file="background" scaling="proportional" alignment="bottomleft"/>
    <readme file="readme.txt"/>
    <license file="license.rtf"/>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1">
            <line choice="installer_choice_1_1"/>
        </line>
        <line choice="installer_choice_2"/>
        <line choice="installer_choice_3"/>
        <line choice="installer_choice_4"/>
        <line choice="installer_choice_5"/>
        <line choice="installer_choice_6"/>
        <line choice="installer_choice_7"/>
        <line choice="installer_choice_8"/>
        <line choice="installer_choice_9"/>
        <line choice="installer_choice_10"/>
        <line choice="installer_choice_11"/>
    </choices-outline>
    <choice id="installer_choice_1_1" start_visible="false" title="chipsounds_Files" description="">
        <pkg-ref id="com.plogue.chipsounds.files.pkg"/>
    </choice>
    <choice id="installer_choice_1" start_visible="false" title="INSTALLER_CHOICE_1_TITLE" description=""/>
    <choice id="installer_choice_2" title="chipsounds_AU" description="">
        <pkg-ref id="com.plogue.chipsounds.chipsoundsau.pkg"/>
    </choice>
    <choice id="installer_choice_3" start_visible="false" title="chipsounds_Plugins" description="">
        <pkg-ref id="com.plogue.chipsounds.chipsoundsplugins.pkg"/>
    </choice>
    <choice id="installer_choice_4" title="chipsounds_RTAS" description="">
        <pkg-ref id="com.plogue.chipsounds.chipsoundsrtas.pkg"/>
    </choice>
    <choice id="installer_choice_5" start_visible="false" title="chipsounds_SA" description="">
        <pkg-ref id="com.plogue.chipsounds.chipsoundssa.pkg"/>
    </choice>
    <choice id="installer_choice_6" title="chipsounds_VST" description="">
        <pkg-ref id="com.plogue.chipsounds.chipsoundsvst.pkg"/>
    </choice>
    <choice id="installer_choice_7" start_visible="false" title="AmbiencePlugin" description="">
        <pkg-ref id="com.Plogue.AriaAmbiencePluginpck"/>
    </choice>
    <choice id="installer_choice_8" start_visible="false" title="BasicConvPluginPack" description="">
        <pkg-ref id="com.Garritan.BasicConvPluginPack"/>
    </choice>
    <choice id="installer_choice_9" start_visible="false" title="MDAPluginsPack" description="">
        <pkg-ref id="com.Plogue.MDAPluginspck"/>
    </choice>
    <choice id="installer_choice_10" start_visible="false" title="AriaMain" description="">
        <pkg-ref id="com.Plogue.AriaMainpck"/>
    </choice>
    <choice id="installer_choice_11" start_visible="false" title="chipsounds_Converters" description="">
        <pkg-ref id="com.plogue.chipsounds.converters.pkg"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="com.Plogue.AriaAmbiencePluginpck" version="1.500" auth="Root" installKBytes="222">#AmbiencePlugin.pkg</pkg-ref>
    <pkg-ref id="com.Garritan.BasicConvPluginPack" version="1504" auth="Root" installKBytes="607">#BasicConvPluginPack.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.chipsoundssa.pkg" version="1625" auth="Root" installKBytes="5981">#chipsounds_SA.pkg</pkg-ref>
    <pkg-ref id="com.Plogue.MDAPluginspck" version="1.500" auth="Root" installKBytes="277">#MDAPluginsPack.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.chipsoundsau.pkg" version="1602" auth="Root" installKBytes="782">#chipsounds_AU.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.files.pkg" version="1625" auth="Root" installKBytes="104050">#chipsounds_Files.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.chipsoundsplugins.pkg" version="1504" auth="Root" installKBytes="1296">#chipsounds_Plugins.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.chipsoundsrtas.pkg" version="1504" auth="Root" installKBytes="732">#chipsounds_RTAS.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.chipsoundsvst.pkg" version="1602" auth="Root" installKBytes="881">#chipsounds_VST.pkg</pkg-ref>
    <pkg-ref id="com.Plogue.AriaMainpck" version="1625" auth="Root" installKBytes="16105">#AriaMain.pkg</pkg-ref>
    <pkg-ref id="com.plogue.chipsounds.converters.pkg" version="1601" auth="Root" installKBytes="626">#chipsounds_Converters.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

	const __IC_FLAT_DISTRIBUTION__=true;
	const IC_CPU_ARCHITECTURE_ANY=0;
	const IC_CPU_ARCHITECTURE_POWERPC=18;
	const IC_CPU_ARCHITECTURE_INTEL=7;
	const IC_CPU_ARCHITECTURE_TYPE_ANY=0;
	const IC_CPU_ARCHITECTURE_TYPE_32=1;
	const IC_CPU_ARCHITECTURE_TYPE_64=2;

	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_CheckCPU(inMinimumCoresCount,inSupportedArchitecture,inSupportedPowerPCArchitectureType,inSupportedIntelArchitectureType,inMinimumFrequency)
	{
		/* Check Minimum Core Count */
		
		if (system.sysctl('hw.ncpu')>=inMinimumCoresCount)
		{
			var tArchitecture;
			var t64BitSupport;
			
			tArchitecture=system.sysctl('hw.cputype');
			
			/* Check Architecture */
			
			if (inSupportedArchitecture!=IC_CPU_ARCHITECTURE_ANY)
			{
				if (inSupportedArchitecture!=tArchitecture)
				{
					return false;
				}
			}
			
			/* Check Architecture Type */
			
			t64BitSupport=system.sysctl('hw.cpu64bit_capable');
			
			if (tArchitecture==IC_CPU_ARCHITECTURE_POWERPC)
			{
				if ((inSupportedPowerPCArchitectureType==IC_CPU_ARCHITECTURE_TYPE_32 &amp;&amp; t64BitSupport==1) ||
					(inSupportedPowerPCArchitectureType==IC_CPU_ARCHITECTURE_TYPE_64 &amp;&amp; t64BitSupport==0))
				{
					return false;
				}
			}
			else if (tArchitecture==IC_CPU_ARCHITECTURE_INTEL)
			{
				if ((inSupportedIntelArchitectureType==IC_CPU_ARCHITECTURE_TYPE_32 &amp;&amp; t64BitSupport==1) ||
					(inSupportedIntelArchitectureType==IC_CPU_ARCHITECTURE_TYPE_64 &amp;&amp; t64BitSupport==0))
				{
					return false;
				}
			}
			
			/* Check Minimum CPU Frequency */
			
			if (system.sysctl('hw.cpufrequency_max')>=inMinimumFrequency)
			{
				return true;
			}
		}
		
		return false;
	}

	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_CheckCPU(1,IC_CPU_ARCHITECTURE_INTEL,IC_CPU_ARCHITECTURE_TYPE_ANY,IC_CPU_ARCHITECTURE_TYPE_ANY,866666);

		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;
	}

	function volume_check()
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.6.8',IC_OS_DISTRIBUTION_TYPE_ANY);

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

		return tResult;
	}

    </script>
</installer-script>