<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
    <options hostArchitectures="i386" customize="never"/>
    <title>SU_TITLE</title>
    <script/>
    <installation-check script="InstallationCheck()"/>
    <locator>
        <search id="STP" type="component">
            <bundle CFBundleIdentifier="com.apple.SafariTechnologyPreview"/>
        </search>
    </locator>
    <pkg-ref id="SafariElCapitan" installKBytes="156094" version="1.0.0.0.1.1473394029">
        <relocate search-id="STP">
            <bundle id="com.apple.SafariTechnologyPreview"/>
        </relocate>
        <must-close>
            <app id="com.apple.SafariTechnologyPreview"/>
        </must-close>
    </pkg-ref>
    <volume-check script="VolumeCheck()"/>
    <tags>
        <tag>{"SafariTechnologyPreview":{"Version":1, "MajorOS": 10, "MinorOS": 11, "PatchOSes": [4,5], "OSUpdateURL": "macappstore://showUpdatesPage", "AlertInformativeText": "To continue testing the latest WebKit features and enhancements, install the OS X El Capitan 10.11.6 update."}}</tag>
    </tags>
    <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) {
	if (system.compareVersions(system.version.ProductVersion, '10.11') &lt; 0 || system.compareVersions(system.version.ProductVersion, '10.12') &gt;= 0) {
		my.result.message = system.localizedStringWithFormat('ERROR_0', '10.11');
		my.result.type = 'Fatal';
		return false;
	}
	return true;
}

function VolumeCheck(prefix) {
	if (system.env.OS_INSTALL == 1) return true;

	var myTargetSystemVersion = (my.target.systemVersion || system.files.plistAtPath(my.target.mountpoint + "/System/Library/CoreServices/SystemVersion.plist"));
	if (!myTargetSystemVersion || system.compareVersions(myTargetSystemVersion.ProductVersion, '10.11.4') &lt; 0) {
		my.result.message = system.localizedStringWithFormat('ERROR_0', '10.11.4');
		my.result.type = 'Fatal';
		return false;
	}

	if (!myTargetSystemVersion || system.compareVersions(myTargetSystemVersion.ProductVersion, '10.11.5') &gt; 0) {
		my.result.message = system.localizedStringWithFormat('ERROR_3', '10.10.5');
		my.result.type = 'Fatal';
		return false;
	}

	if (compareBuildVersions(myTargetSystemVersion.ProductBuildVersion, '15D6') &lt; 0) {
		my.result.message = system.localizedString('ERROR_4');
		my.result.type = 'Fatal';
		return false;
	}
	my.result.message = system.localizedString('ERROR_4');
	if (!DoesntHaveNewerWebkit(my.target.mountpoint)) {
		my.result.type = 'Fatal';
		return false;
	}
	return true;
}

function DoesntHaveNewerWebkit(prefix) {
	if (typeof(my.result) != 'undefined') my.result.message = system.localizedString('ERROR_5');
	if (FrameworkOlderOrEqual(prefix)) {
		return true;
	}
	return false;
}

function FrameworkOlderOrEqual(prefix) {
	var result = my.search.results['STP'][0];
	if (! result) {
		return true;
	}

	var plist = system.files.plistAtPath(prefix + result + '/Contents/Frameworks/WebKitLegacy.framework/Resources/Info.plist');
	if (!plist) {
		return true;
	}
	var plistKeyValue = plist['CFBundleVersion'];
	if (!plistKeyValue) {
		return true;
	}

	if (system.compareVersions(plistKeyValue, '11603.1.3') &gt; 0) {
		return false;
	}

	return true;
}

function DoesntHaveNewerOrSameWebkit(prefix) {
        if (FrameworkOlder(prefix)) {
                return true;
        }
        return false;
}
function FrameworkOlder(prefix) {
		var result = my.search.results['STP'][0];
		if ( !result ) {
			return false;
		}
        var plist = system.files.plistAtPath(prefix + result + '/Contents/Frameworks/WebKitLegacy.framework/Resources/Info.plist');
        if (!plist) {
                return false;
        }
        var plistKeyValue = plist['CFBundleVersion'];
        if (!plistKeyValue) {
                return false;
        }

        if (system.compareVersions(plistKeyValue, '11603.1.3') &gt;= 0) {
                return false;
        }
        return true;
}
</script>
    <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="SafariTechPreviewElCapitan" start_selected="true" visible="DoesntHaveNewerOrSameWebkit('/')">
        <pkg-ref id="SafariElCapitan" auth="Root" packageIdentifier="com.apple.pkg.SafariTechPreviewElCapitan">SafariTechPreviewElCapitan.pkg</pkg-ref>
    </choice>
    <script/>
    <platforms>
        <client arch="i386"/>
        <server arch="i386"/>
    </platforms>
    <localization>
        <strings language="pl">"SU_TITLE" = "Safari Technology Preview for OS X El Capitan";
"SU_TITLE_ALT" = "";
"SU_VERS" = "9.1.1";
"SU_VERS_ALT" = "";
"SU_SERVERCOMMENT" = "Dla komputerów klienckich i serwerów";
"SU_DESCRIPTION" = '&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
  &lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;meta name="Generator" content="Cocoa HTML Writer"&gt;
  &lt;meta name="CocoaVersion" content="1038.36"&gt;
  &lt;style type="text/css"&gt;
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
    li.li1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    span.s1 {text-decoration: underline}
    ul.ul1 {list-style-type: disc}
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p class="p1"&gt;This is Safari Technology Preview for OS X El Capitan.&lt;/p&gt;
&lt;br /&gt;
&lt;p class="p1"&gt;Use of this Apple Software is subject to the Software License Agreement for Apple Confidential Safari Pre-Release Seed Software.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
';
"SU_DESCRIPTION_ALT" = '';
</strings>
    </localization>
</installer-gui-script>