<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion='1'>
    <!-- Installer UI-ey stuff -->
    <title>SU_TITLE</title>
    <welcome file="Welcome.rtf"/>
    <license file="License.rtf" sla="EA0396"/>
    <background file='background.tif' scaling='none' alignment='left'/>
    <options customize="never" rootVolumeOnly="true" hostArchitectures='ppc,i386'/>
    <platforms>
        <client arch="ppc,i386"/>
        <server arch="ppc,i386"/>
    </platforms>
    <!-- Manual Install package layout -->
    <choices-outline>
        <line choice='manual'/>
    </choices-outline>
    <choice id='manual' title='SU_TITLE' versStr='SU_VERS'>
        <pkg-ref auth='Root' id='manual'>#MacBookAppSupportUpdate.pkg</pkg-ref>
    </choice>
    <!-- Software Update package layout -->
    <choices-outline ui='SoftwareUpdate'>
        <line choice='su'/>
    </choices-outline>
    <choice id='su' title='SU_TITLE' versStr='SU_VERS' description='SU_DESCRIPTION' description-mime-type='text/html' secondaryDescription='SU_SERVERCOMMENT' suDisabledGroupID='MacBookAppSupportUpdate' visible='isCorrectHardware()'>
        <pkg-ref auth='Root' id='su'>MacBookAppSupportUpdate.pkg</pkg-ref>
    </choice>
    <!-- SCRIPT stuff -->
    <installation-check script="InstallationCheck()"/>
    <script>
function InstallationCheck()
{
	return(hasLeopard() &amp;&amp; needsRepair());
}

function hasLeopard()
{
	if ( system.compareVersions(system.version.ProductVersion, "10.5") &lt; 0) {
		my.result.message = system.localizedStringWithFormat('systemTooOld');
		my.result.type = 'Fatal';
		return false;
	}
	
	return true;
}
	
function needsRepair()
{
	// Must have GAS framework or we can't fix
	var path = "/System/Library/PrivateFrameworks/GraphicsAppSupport.framework/";
	var bundle = system.files.bundleAtPath(path);
	if ((typeof bundle) == "undefined")
	{
		// there's no bundle there. Can't fix that.
		my.result.message = system.localizedStringWithFormat('noRepairNeeded');
		my.result.type = 'Fatal';
		return false;
	}

	var path = "/System/Library/PrivateFrameworks/GraphicsAppSupport.framework/Versions/A/Frameworks/";
	if (!system.files.fileExistsAtPath(path))
	{
		// folder missing. Can't fix that.
		my.result.message = system.localizedStringWithFormat('noRepairNeeded');
		my.result.type = 'Fatal';
		return false;
	}

	// if these bundles don't exist, or they have versions 0.0.0.0.0, we need to repair.
	
	// First, ImageKit
	var path = "/System/Library/PrivateFrameworks/GraphicsAppSupport.framework/Versions/A/Frameworks/ImageKit.framework";
	var bundle = system.files.bundleAtPath(path);
	if ((typeof bundle) == "undefined") return true;
	
	var version = BundleGetCompositeVersion5(bundle);
	if (system.compareVersions(version, "0.0.0.0.0") == 0) return true;
	
	
	// Now, QuartzComposer
	path = "/System/Library/PrivateFrameworks/GraphicsAppSupport.framework/Versions/A/Frameworks/QuartzComposer.framework";
	bundle = system.files.bundleAtPath(path);
	if ((typeof bundle) == "undefined") return true;
	
	version = BundleGetCompositeVersion5(bundle);
	if (system.compareVersions(version, "0.0.0.0.0") == 0) return true;
	
	
	// Both frameworks are good, so return false
	my.result.message = system.localizedStringWithFormat('noRepairNeeded');
	my.result.type = 'Fatal';
	return false;
}

function isCorrectHardware()
{
	// only offer update for the original model that had the problem
	var property = system.sysctl("hw.model");
	return (property &amp;&amp; (property == "MacBook3,1"));
}
	
</script>
    <!-- Common include -->
    <script>
	function _PadVersionString(version, tupleCount)
	{
		if (version == null)
			version = "0";
		var components = version.split(".");
		if (components.length > 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["SU_TITLE"			= "Uaktualnienie obsługi programów MacBooka";
"SU_VERS"			= "1.0";
"SU_SERVERCOMMENT"	= "Dla systemów stacjonarnych oraz serwerów.";

"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 rozwiązuje problem awarii programów, które mogą występować na komputerach MacBook po odtworzeniu systemu operacyjnego przy użyciu dołączonego do komputera zestawu dysków instalacyjnych Mac OS X 10.5.
</p><p>
Aby poznać szczegóły dotyczące tego uaktualnienia, odwiedź tę witrynę: <a href="http://support.apple.com/kb/TS2275?viewlocale=pl_PL">http://support.apple.com/kb/TS2275</a>.
</P>
</FONT> 
</BODY>
</HTML>
';
]]></strings>
    </localization>

	<pkg-ref id='su' installKBytes='96' version='1.0.1.1221256485'/>
</installer-gui-script>