<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion="1">
    <options type="firmware" customize="never" hostArchitectures="i386" rootVolumeOnly="true"/>
    <title>SU_TITLE</title>
    <script>
</script>
    <installation-check script="InstallationCheck()"/>
    <script>
		var updateName = "iMacGraphicsFWUpdate";
		
			function needsGraphicsUpdate()
			{			
				var reg = system.ioregistry.matchingClass("IOPCIDevice")

				if( reg )
				{
					for( var i = 0; i &lt; reg.length; i++ )
					{
						var rom = reg[i]['ATY,Rom#'];						

						if( rom )
						{
							if( ((rom.substring(0,11) == "113-C2950H-") &amp;&amp; parseInt(rom.substring(11, 14)) &lt; 170) || 
								((rom.substring(0,11) == "113-C0170C-") &amp;&amp; parseInt(rom.substring(11, 14)) &lt; 170) ||
								((rom.substring(0,11) == "113-C0170F-") &amp;&amp; parseInt(rom.substring(11, 14)) &lt; 170) ||
								((rom.substring(0,11) == "113-C2960H-") &amp;&amp; parseInt(rom.substring(11, 14)) &lt; 188))
							{
								debuglog("ATY,ROM# for this CPU is: " + rom);
								return true;
							}
						}
					}
				}
				return false;
			}

		function debuglog(message)
		{
			// yes, this is secure
			if (system.files.fileExistsAtPath("/tmp/com.apple.pkg.testing")) system.log("********** " + updateName + ": " + message);
		}
	</script>
    <script>
function compareBuildVersions(lhs, rhs) {
	var lhsMatch = lhs.match(/([0-9]+)([A-Z])([0-9]+)([a-z])?/);
	var rhsMatch = rhs.match(/([0-9]+)([A-Z])([0-9]+)([a-z])?/);
	return system.compareVersions(lhsMatch.slice(1).join(","), rhsMatch.slice(1).join(","));
}
function InstallationCheck(prefix) {
	var models = ['iMac12,1','iMac12,2',];
	var model = system.sysctl('hw.model');
	if (models.indexOf(model) == -1) {
		my.result.message = system.localizedString('ERROR_1');
		my.result.type = 'Fatal';
		return false;
	}
	if (system.compareVersions(system.version.ProductVersion, '10.6.7') &lt; 0) {
		my.result.message = system.localizedStringWithFormat('ERROR_0', '10.6.7');
		my.result.type = 'Fatal';
		return false;
	}
	if (compareBuildVersions(system.version.ProductBuildVersion, '10J4138') &lt; 0) {
		my.result.message = system.localizedString('ERROR_1');
		my.result.type = 'Fatal';
		return false;
	}
	my.result.message = system.localizedString('ERROR_1');
	if (!Script0("/")) {
		my.result.type = 'Fatal';
		return false;
	}
	return true;
}
function Script0(prefix) {
	if (!needsGraphicsUpdate()) {
		return false;
	}
	return true;
}
</script>
    <platforms>
        <client arch="i386"/>
        <server arch="i386"/>
    </platforms>
    <choices-outline ui="SoftwareUpdate">
        <line choice="su"/>
    </choices-outline>
    <choices-outline>
        <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="iMacGraphicsFirmwareUpdate2.0">
        <pkg-ref id="iMac" auth="Root" packageIdentifier="com.apple.pkg.iMacGraphicsFWUpdate" onConclusion="RequireRestart">iMacGraphicsFWUpdate.pkg</pkg-ref>
    </choice>
    <localization>
        <strings language="pl"><![CDATA["SU_TITLE" = "Uaktualnienie oprogramowania sprzętowego grafiki iMaca";
"SU_VERS" = "2.0";
"SU_SERVERCOMMENT" = "Dla komputerów klienckich i serwerów";
"SU_DESCRIPTION" = '<HTML><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <style type="text/css">
	p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11px Lucida Grande;}
  </style>
</head>
<body>
<p class="p1">To uaktualnienie oprogramowania sprzętowego naprawia sporadycznie występujący problem, który może powodować zawieszanie iMaca w czasie uruchamiania lub budzenia ze snu.</p><br>
</body>
</html>
';
]]></strings>
    </localization>
    <readme mime-type="text/html"><![CDATA[<HTML><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <style type="text/css">
	p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11px Lucida Grande;}
  </style>
</head>
<body>
<p class="p1">Nie wyłączaj zasilania iMaca w trakcie uaktualniania. Utrata zasilania może uniemożliwić uruchomienie iMaca.</p>
</body>
</html>
]]></readme>

	<pkg-ref id='iMac' installKBytes='697' version='2.0.0.0.1.1306360164'/>
</installer-gui-script>