<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.6" authoringToolBuild="549" minSpecVersion="2">
    <options rootVolumeOnly="true" customize="never" allow-external-scripts="true"/>
    <volume-check>
        <allowed-os-versions>
            <os-version min="10.15.0"/>
        </allowed-os-versions>
    </volume-check>
    <installation-check script="installation_check()">
        <ram min-gb="2.00"/>
    </installation-check>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <background file="background" scaling="proportional" alignment="bottomleft"/>
    <background-darkAqua file="background" scaling="proportional" alignment="bottomleft"/>
    <welcome file="welcome.rtf"/>
    <readme file="readme.rtf"/>
    <license file="license.txt"/>
    <conclusion file="conclusion.rtf"/>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1"/>
    </choices-outline>
    <choice id="installer_choice_1" title="zfs1015" description="">
        <pkg-ref id="net.lundman.openzfs.1015.pkg"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="net.lundman.openzfs.1015.pkg" version="17.0" auth="Root" installKBytes="34116">#zfs1015.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

	const __IC_FLAT_DISTRIBUTION__=false;
	const IC_OS_DISTRIBUTION_TYPE_ANY=0;
	const IC_OS_DISTRIBUTION_TYPE_CLIENT=1;
	const IC_DISK_TYPE_DESTINATION=0;
	const IC_OS_DISTRIBUTION_TYPE_SERVER=2;
	const IC_DISK_TYPE_STARTUP_DISK=1;

	const IC_COMPARATOR_IS_EQUAL=0;
	const IC_COMPARATOR_IS_GREATER=1;
	const IC_COMPARATOR_IS_NOT_EQUAL=2;
	const IC_COMPARATOR_IS_LESS=-1;

	function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inMaximumVersion,inDistributionType)
	{
		var tOSVersion=undefined;
		
		/* Check Version Constraints */
		
		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);
			}
			
			if (inMustBeInstalled==false)
			{
				return false;
			}
		}
		else
		{
			tOSVersion=system.version.ProductVersion;
		}
		
		if (system.compareVersions(tOSVersion,inMinimumVersion)==-1)
			return false;
			
		if (inMaximumVersion!=undefined &amp;&amp;
			system.compareVersions(tOSVersion,inMaximumVersion)==1)
			return false;
		
		/* Check Distribution Type */
		
		if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY)
		{
			var tIsServer;
			
			if (system.compareVersions(tOSVersion,'10.8.0')==-1)
			{
				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');
				}
			}
			else
			{
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/Applications/Server.app');
				}
				else
				{
					tIsServer=system.files.fileExistsAtPath('/Applications/Server.app');
				}
			}
			
			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 IC_CheckScriptReturnValue(inScriptPath,inArguments,inComparator,inReturnValue)
	{
		var tReturnValue;
	
		if (inScriptPath.charAt(0)=='/')
		{
			/* Check Absolute Path Existence */
			
			if (system.files.fileExistsAtPath(inScriptPath)==false)
			{
				return false;
			}
		}
		else
		{
			if (__IC_FLAT_DISTRIBUTION__==true &amp;&amp; system.compareVersions(system.version.ProductVersion, '10.6.0')&lt;0)
			{
				system.log("[WARNING] Embedded scripts are not supported in Flat distribution format on Mac OS X 10.5");
          
				return true;
			}
		}
		
		if (inArguments.length&gt;0)
		{
			var tMethodCall;
			var tStringArguments=[];
			
			for(var i=0;i&lt;inArguments.length;i++)
			{
				tStringArguments[i]='inArguments['+i+']';
			}
			
			tMethodCall='system.run(inScriptPath,'+tStringArguments.join(',')+');';
			
			tReturnValue=eval(tMethodCall);
		}
		else
		{
			tReturnValue=system.run(inScriptPath);
		}
		
		if (tReturnValue==undefined)
		{
			return false;
		}
		
		if (inComparator==IC_COMPARATOR_IS_EQUAL)
		{
			return (tReturnValue==inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_GREATER)
		{
			return (tReturnValue&gt;inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_LESS)
		{
			return (tReturnValue&lt;inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_NOT_EQUAL)
		{
			return (tReturnValue!=inReturnValue);
		}
		
		return false;
	}

	function installation_check()
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_STARTUP_DISK,true,'10.5',undefined,IC_OS_DISTRIBUTION_TYPE_ANY);

		if (tResult==false)
		{
			my.result.title = system.localizedStandardStringWithFormat('InstallationCheckError', system.localizedString('DISTRIBUTION_TITLE'));
			my.result.message = ' ';
			my.result.type = 'Fatal';
		}

		if (tResult==true)
		{
			var tScriptArguments1=new Array();

			tResult=IC_CheckScriptReturnValue('poolcheck.sh',tScriptArguments1,IC_COMPARATOR_IS_EQUAL,1);

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

			if (tResult==true)
			{
				var tScriptArguments2=new Array();

				tResult=IC_CheckScriptReturnValue('zevocheck.sh',tScriptArguments2,IC_COMPARATOR_IS_EQUAL,1);

				if (tResult==false)
				{
					my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_2');
					my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_2');
					my.result.type = 'Fatal';
				}
			}
		}

		return tResult;
	}

    </script>
    <pkg-ref id="net.lundman.openzfs.1015.pkg">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.9.2" CFBundleVersion="1.9.2" id="net.lundman.zfs" path="Library/Extensions/zfs.kext"/>
            <bundle CFBundleShortVersionString="1.9.2" CFBundleVersion="1.9.2" id="net.lundman.spl" path="Library/Extensions/spl.kext"/>
            <bundle CFBundleShortVersionString="1.5.2" CFBundleVersion="1.5.2" id="net.lundman.filesystems.zfs" path="Library/Filesystems/zfs.fs"/>
        </bundle-version>
    </pkg-ref>
    <product version="1.9.2"/>
</installer-gui-script>