<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion='1'>

	<!-- Installer UI-ey stuff -->
	<title>MANUAL_TITLE</title>
	<welcome file="SUDescription.html"/>
	<license file="License.rtf"/>
	
	<background file="background.tif"
				scaling="proportional"
				alignment="bottomleft"
	/>
	
	<options	customize			= "never"
				rootVolumeOnly		= "true"
				hostArchitectures	= "i386,ppc"
	/>

        <platforms>
                <client arch="ppc,i386"/>
                <server arch="ppc,i386"/>
        </platforms>
	
	<!-- Manual Install package layout -->
	<choices-outline>
		<line choice='manual'/>
	</choices-outline>

	<choice id='manual'>
		<pkg-ref auth='Root' id='com.apple.pkg.GarageBand_411'>.</pkg-ref>
	</choice>
	
	<choice id='manual'	title='MANUAL_TITLE' 
						versStr='SU_VERS'/>
	

	<!-- Software Update package layout -->
	<choices-outline ui='SoftwareUpdate'>
		<line choice='su'/>
	</choices-outline>

	<choice id='su'>
		<pkg-ref auth='Root' id='b'>GarageBand_411.pkg</pkg-ref>
	</choice>
	
	<choice id='su' visible ='VisibleCheck()'
					start_selected = 'true'
					suDisabledGroupID = 'GarageBand_411'
	/>
	
	<choice id='su' title='SU_TITLE' 
					versStr='SU_VERS'
					description='SU_DESCRIPTION' 
					description-mime-type='text/html'
	/>
	

	<!-- XXX: to test the Software Update logic with the Installer -->
	<installation-check script="InstallationCheck()" />	
    	<volume-check script='volumeCheck()'/>

	<!-- Auto-generated logic scripts from the update XML -->
<script>
	function InstallationCheck()
	{
		// Installation check since we're root volume only. That way, the user gets error
		// right away, not at volume select screen.
		
		return(rootVolumeHasNoTier3() &amp;&amp; rootVolumeIsEligible());
	}
	
	function VisibleCheck()
	{
		// only show in software update if volume really needs update
		// (InstallationCheck is also run)
		return (volumeNeedsUpdate());
	}

	function rootVolumeHasNoTier3()
	{
		var path = "/var/db/.AppleTier3Language";
		if (!system.files.fileExistsAtPath(path))
			return true;
			
		my.result.message = system.localizedStringWithFormat('volumeHasTier3');
		my.result.type = 'Fatal';
		return false;
	}

	function rootVolumeIsEligible()
	{

		var path = "/Applications/GarageBand.app";
		var bundle = system.files.bundleAtPath(path);
		var version = BundleGetCompositeVersion5(bundle);
		
		// if version is not less than 4.0 (ie. greater than or equal to) and version is less than 4.1.2, this volume can run a manual update
		if (version &amp;&amp; (system.compareVersions(version, "4.0") != -1) &amp;&amp;  (system.compareVersions(version, "4.1.2") != 1))
			return true;

		my.result.message = system.localizedStringWithFormat('noApp');
		my.result.type = 'Fatal';
		return false;
	}
        function volumeCheck()
        {
		// 10.4.9+
                if((-1 == system.compareVersions(my.target.systemVersion.ProductVersion, '10.4.9'))) {
			my.result.message = system.localizedStringWithFormat('verOS');
			my.result.type = 'Fatal';
               		return(false);
                }

		return(true);
	}
		
	function volumeNeedsUpdate()
	{
		var path = my.target.mountpoint + "/Applications/GarageBand.app";
		var bundle = system.files.bundleAtPath(path);
		var version = BundleGetCompositeVersion5(bundle);
		
		// if version is not less than 4.0 (ie. greater than or equal to) and version is less than 4.1.1, this volume can see auto update
		if (version &amp;&amp; (system.compareVersions(version, "4.0") != -1) &amp;&amp;  (system.compareVersions(version, "4.1.1") == -1))
			return true;

		return false;
	}
</script>

	<!-- Common include -->
<script>
	function _PadVersionString(version, tupleCount)
	{
		if (version == null)
			version = "0";
		var components = version.split(".");
		if (components.length &gt; tupleCount)
			components = components.slice(0, tupleCount);
		else
			for (; components.length&lt;tupleCount; )
				components.push("0");
		return components.join(".");
	}

	function BundleGetCompositeVersion5(bundle)
	{
		if (bundle == null)
			return null;
		var shortVers = bundle.CFBundleShortVersionString;
		shortVers = _PadVersionString(shortVers, 3);
		var sourceVers = bundle.SourceVersion;
		sourceVers = _PadVersionString(sourceVers, 1);
		var buildVers = bundle.BuildVersion;
		buildVers = _PadVersionString(buildVers, 1);
		var fiveTupleVers = shortVers + "." + sourceVers + "." + buildVers;
		return fiveTupleVers;
	}

	function CheckNameRegistry(path, property, value)
	{
		try
		{
			var obj = system.ioregistry.fromPath(path);
			if (obj == null)
				return false;

			var propObj = obj[property];
			if (propObj == null)
				return false;

			if (typeof(propObj) == "string")	// string
			{
				return (propObj == value);
			}
			else if (typeof(propObj) == "object")	// array contains
			{
				for (var i=0; i&lt;propObj.length; i++)
					if (propObj[i] == value)
						return true;
			}
		}
		catch (e) {}

		return false;
	}
</script>	

	<localization>
		<strings language="pl">
<![CDATA[
// From Localiazable.strings
"SU_TITLE" = "Uaktualnienie GarageBand";
"SU_VERS" = "4.1.1";
"SU_SERVERCOMMENT" = "Dla systemów typu klient oraz serwer.";

// From HTML description file
"SU_DESCRIPTION" = '<HTML>
<HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"></meta></HEAD>
<BODY> 
<FONT FACE="Lucida Grande">
<P>
To uaktualnienie poprawia ogólną stabilność oraz rozwiązuje zagadnienia związane z eksportowaniem do iPhone.
</P>
</FONT> 
</BODY>

</HTML>
';
]]>
		</strings>
	</localization>
</installer-gui-script>
