Advertisement
shornby

OSX Mavericks Distribution Script- If checks ok, Upgrade.xml

Jun 14th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 13.23 KB | None | 0 0
  1. <?xml version="1.0" standalone="yes"?>
  2. <installer-gui-script minSpecVersion="1">
  3.   <options eraseOptionAvailable="true" hostArchitectures="i386" allow-external-scripts="yes" osVersion="10.9" osBuildVersion="13A476u"/>
  4.   <title>MacOSX_Title</title>
  5.   <license file="License.rtf"/>
  6.   <conclusion file="Conclusion.rtfd"/>
  7.   <script>
  8.         var minRam = 2048;
  9.  
  10. function checkSupportedMachine(machineType) {
  11.     return true;
  12. }
  13.  
  14. function checkSupportedBootRom(machineType) {
  15.     return true;
  16. }
  17.  
  18. function hasAtLeastRam(RAM) {
  19.     var requiredRAM = (RAM * 1024 * 1024);
  20.     var actualRAM = system.sysctl('hw.memsize');
  21.     return (actualRAM &gt; (requiredRAM - 1));
  22. }
  23.  
  24. function is64bit() {
  25.     var is64bit =system.sysctl('hw.cpu64bit_capable');
  26.     return is64bit;
  27. }
  28.  
  29. function isVirtualMachine(){
  30.    
  31.     var cpuFeatures = system.sysctl( 'machdep.cpu.features' );
  32.             cpuFeatures=cpuFeatures.split(" ");
  33.             for( var i = 0; i &lt; cpuFeatures.length; i++ ){
  34.                 if( cpuFeatures[i] == "VMM" ){
  35.                         return true;
  36.                 }  
  37.             }
  38.             return false;          
  39.            
  40. }
  41.  
  42. function isSupportedPlatform(){
  43.  
  44.     if( isVirtualMachine() ){
  45.         return true;
  46.     }
  47.    
  48.     var platformSupportValues=["Mac-031B6874CF7F642A","Mac-F42D88C8","Mac-50619A408DB004DA","Mac-F2218EA9","Mac-F42D86A9","Mac-F22C8AC8","Mac-F22586C8","Mac-AFD8A9D944EA4843","Mac-F227BEC8","Mac-F226BEC8","Mac-7DF2A3B5E5D671ED","Mac-35C1E88140C3E6CF","Mac-942B59F58194171B","Mac-2E6FAB96566FE58C","Mac-7BA5B2794B2CDB12","Mac-031AEE4D24BFF0B1","Mac-00BE6ED71E35EB86","Mac-4B7AC7E43945597E","Mac-F22C89C8","Mac-942459F5819B171B","Mac-F42388C8","Mac-F223BEC8","Mac-F4238CC8","Mac-F222BEC8","Mac-4BC72D62AD45599E","Mac-F2268DC8","Mac-F2208EC8","Mac-66F35F19FE2A0D05","Mac-F4238BC8","Mac-F221BEC8","Mac-C08A6BB70A942AC2","Mac-8ED6AF5B48C039E1","Mac-F2238AC8","Mac-FC02E91DDD3FA6A4","Mac-6F01561E16C75D06","Mac-F22589C8","Mac-F22587A1","Mac-F22788AA","Mac-F42C86C8","Mac-942C5DF58193131B","Mac-F2238BAE","Mac-F22C86C8","Mac-F2268CC8","Mac-F2218FC8","Mac-742912EFDBEE19B3","Mac-27ADBB7B4CEE8E61","Mac-F65AE981FFA204ED","Mac-F42D89C8","Mac-F22587C8","Mac-F42D89A9","Mac-F2268AC8","Mac-F42C89C8","Mac-942452F5819B1C1B","Mac-F2218FA9","Mac-F221DCC8","Mac-94245B3640C91C81","Mac-F42D86C8","Mac-F2268EC8","Mac-F2268DAE","Mac-7DF21CB3ED6977E5","Mac-F42C88C8","Mac-94245A3940C91C80","Mac-F42386C8","Mac-C3EC7CD22292981F","Mac-942B5BF58194151B","Mac-F2218EC8"];
  49.     var boardID = system.ioregistry.fromPath('IOService:/')['board-id'];
  50.    
  51.     if( !boardID || platformSupportValues.length == 0 ) {
  52.         return false
  53.     }
  54.     for( var i = 0; i &lt; platformSupportValues.length; i++ ){
  55.         if( boardID == platformSupportValues[i] ){
  56.                 return true;
  57.         }  
  58.     }
  59.  
  60.     return false;
  61. }
  62.  
  63.  
  64.  
  65.     function installCheckScript(){
  66.            
  67.             try{
  68.                 var machineType = system.ioregistry.fromPath('IODeviceTree:/')['compatible'];
  69.                
  70.                 if (typeof(isFNI) == "undefined" &amp;&amp; typeof(hwbeInstallCheck) != "undefined") {
  71.                     if (!hwbeInstallCheck()) {
  72.                         return false;
  73.                     }
  74.                 }
  75.                
  76.                 if(!is64bit()){
  77.                     my.result.message = system.localizedStringWithFormat('IC_Unsupported_Processor');
  78.                     my.result.type = 'Fatal';
  79.                     return false;
  80.                 }
  81.                
  82.                 if(!isSupportedPlatform()){
  83.                     my.result.message = system.localizedStringWithFormat('IC_Unsupported_Platform');
  84.                     my.result.type = 'Fatal';
  85.                     return false;
  86.                 }
  87.                
  88.                 if(!hasAtLeastRam(minRam)){
  89.                     my.result.message = system.localizedStringWithFormat('IC_RAM_message');
  90.                     my.result.type = 'Fatal';
  91.                     return false;
  92.                 }
  93.                
  94.                 if (system.compareVersions(system.version.ProductVersion, '10.9') &lt; 0 &amp;&amp; system.env.COMMAND_LINE_INSTALL) {
  95.                     my.result.message = system.localizedStringWithFormat('IC_Command_Line_message', '10.9');
  96.                     my.result.type = 'Fatal';
  97.                     return false;
  98.                 }
  99.                
  100.                 if (typeof(findBJPrinters) != "undefined") findBJPrinters();
  101.                
  102.             } catch (e) {
  103.                 system.log('installCheckScript threw exception ' + e);
  104.             }
  105.            
  106.             return true;
  107.     }
  108.  
  109.  
  110. function volCheckScript(){
  111.         var target = my.target;
  112.         var destSystemVersion = target['systemVersion'];
  113.        
  114.         if(system.files.fileExistsAtPath(my.target.mountpoint + "/Backups.backupdb")) {
  115.             my.result.message = system.localizedString('VC_Backup_message');
  116.             my.result.type = 'Fatal';
  117.             return false;
  118.         }
  119.        
  120.         if(my.target.systemVersion){
  121.             if( system.compareVersions(my.target.systemVersion.ProductVersion, '10.10') &gt;= 0){          
  122.                 my.result.message = system.localizedString('VC_Newer_message');
  123.                 my.result.type = 'Fatal';
  124.                 return false;
  125.             }          
  126.         }
  127.  
  128.         if (destSystemVersion) {
  129.        
  130.             // Don't allow upgrades on volumes less than 10.6.6
  131.             if (-1 == system.numericalCompare(destSystemVersion['ProductVersion'], '10.6.6')) {
  132.                     my.result.message = system.localizedString('VC_Upgrade_message');
  133.                     my.result.type = 'Fatal';
  134.                
  135.                     return false;
  136.             }
  137.         }
  138.        
  139.         //FDE CHECKS
  140.         var plist = system.files.plistAtPath('/System/Library/Extensions/CoreStorage.kext/Contents/Info.plist');
  141.         if(plist){
  142.                 var plistKeyValue = plist['CoreStorageDiskFormatVersion'];
  143.                 if((system.ioregistry.matchingClass('CoreStorageGroup').length != 0) &amp;&amp; (system.compareVersions(plistKeyValue, '1') != 0) ){
  144.                     my.result.message = system.localizedString('CS_message');
  145.                     my.result.type = 'Fatal';
  146.                     return false;
  147.  
  148.                 }  
  149.         }
  150.        
  151.         return true;
  152. }
  153.  
  154.    
  155.     function language_running(langKey){
  156.         var appleLanguages = system.defaults['AppleLanguages'];
  157.    
  158.    
  159.         if(!appleLanguages || (appleLanguages.length == 0))
  160.                 return ((langKey == 'English') || (langKey == 'en'))
  161.        
  162.         return (langKey == appleLanguages[0]);
  163.     }
  164.    
  165.     gLanguageRequired = {
  166.     };
  167.    
  168.     //Function returns true if the langKey is required, it uses a cache so that the logic doesn't
  169.     //have to be run hundreds of times
  170.     function language_required(langKey){
  171.        
  172.         if(! (gLanguageRequired[langKey])){
  173.             var required = false;
  174.            
  175.             if(language_running(langKey)){
  176.                 required =  true;
  177.             }
  178.            
  179.             gLanguageRequired[langKey] = required;
  180.         }
  181.        
  182.         return gLanguageRequired[langKey];
  183.     }
  184.    
  185.     function language_enabled(langKey){
  186.         var enabled = !(language_required(langKey));
  187.        
  188.         if(false == enabled){
  189.             my.choice.tooltip = system.localizedString('TT_Language_Required_message');
  190.         }
  191.        
  192.         return enabled;
  193.     }
  194.    
  195.     function language_selected(langKey){
  196.         var selected = my.choice.selected || language_required(langKey);
  197.  
  198.         return selected;
  199.     }
  200.        
  201.  
  202.     function verCompare(checkVer){
  203.         var sysVer = my.target['systemVersion'];
  204.         if (sysVer) {
  205.             return system.numericalCompare(sysVer['ProductVersion'],checkVer);
  206.         }
  207.         return -1;
  208.     }
  209.  
  210.     function upgrade_allowed(){
  211.         var argv = upgrade_allowed.arguments;
  212.         var upgradable = true;
  213.         var upgradeAction = my.choice.packageUpgradeAction;
  214.        
  215.         if(argv.length &gt; 0) {
  216.             upgradeAction = eval('choices.' + argv[0] + '.packageUpgradeAction');  
  217.         }
  218.        
  219.         if((upgradeAction == 'downgrade') || (upgradeAction == 'mixed')){
  220.             my.choice.tooltip = system.localizedString('TT_Newer_Package_Installed_message');  
  221.             upgradable = false;
  222.         }
  223.        
  224.         return upgradable;
  225.     }
  226.  
  227.     function systemHasDVD(){
  228.         var obj = system.ioregistry.matchingClass("IODVDBlockStorageDriver");
  229.         if (obj) {
  230.             return true;
  231.         }
  232.         var obj2 = system.ioregistry.matchingName("ApplePlatformEnabler","IOService");
  233.         if (obj2 ) {
  234.             if ( obj2[0]['DVDSupported'] ) {
  235.                 return true;
  236.             }
  237.         }
  238.         return false;
  239.     }
  240.    
  241.     function hasNetInfo() {
  242.         var path = my.target.mountpoint + "/private/var/db/netinfo/local.nidb";
  243.         if (system.files.fileExistsAtPath(path)) {
  244.             return true;
  245.         }
  246.        
  247.         return false;
  248.     }
  249.  
  250.     function needsX11redirect() {
  251.             var sysVer = my.target['systemVersion'];
  252.             if (!sysVer) {
  253.                 return true;
  254.             }
  255.             var path = my.target.mountpoint + "/private/var/db/receipts/com.apple.pkg.X11redirect.plist";
  256.             if (system.files.fileExistsAtPath(path) || system.compareVersions(my.target.systemVersion.ProductVersion, '10.9') &lt; 0) {
  257.                 return true;
  258.             }
  259.  
  260.             return false;
  261.         }
  262.  
  263.  
  264.    
  265.     </script>
  266.   <installation-check script="installCheckScript()"/>
  267.   <volume-check script="volCheckScript()"/>
  268.   <choices-outline>
  269.     <line choice="EssentialSystemSoftware">
  270.       <line choice="EssentialSystemSoftwareGroup"/>
  271.       <line choice="AdditionalEssentials"/>
  272.       <line choice="AdditionalSpeechVoices"/>
  273.       <line choice="AsianLanguagesSupport"/>
  274.       <line choice="MediaFiles"/>
  275.       <line choice="JavaEssentials"/>
  276.       <line choice="OxfordDictionaries"/>
  277.       <line choice="X11"/>
  278.     </line>
  279.     <line choice="OSInstallScripts"/>
  280.   </choices-outline>
  281.   <choice id="EssentialSystemSoftware" title="EssentialSystemSoftware_title" description="EssentialSystemSoftware_description" start_enabled="false" start_visible="false"/>
  282.   <choice id="EssentialSystemSoftwareGroup" start_visible="false" start_selected="true">
  283.     <pkg-ref id="com.apple.pkg.BaseSystemBinaries"/>
  284.     <pkg-ref id="com.apple.pkg.BaseSystemResources"/>
  285.     <system-image id="com.apple.dmg.MacOSX"/>
  286.     <pkg-ref id="com.apple.mpkg.OSInstall"/>
  287.     <pkg-ref id="com.apple.pkg.Essentials"/>
  288.     <pkg-ref id="com.apple.pkg.BSD"/>
  289.     <pkg-ref id="com.apple.pkg.JavaTools"/>
  290.   </choice>
  291.   <choice id="AdditionalEssentials" start_visible="false" start_selected="true">
  292.     <pkg-ref id="com.apple.pkg.AdditionalEssentials"/>
  293.     <pkg-ref id="com.apple.pkg.OSUpgrade" active="!my.target.ignoreContents &amp;&amp; hasNetInfo() &amp;&amp; verCompare(10.3) &gt;= 0"/>
  294.   </choice>
  295.   <choice id="AsianLanguagesSupport" start_visible="false" start_selected="true">
  296.     <pkg-ref id="com.apple.pkg.AsianLanguagesSupport"/>
  297.   </choice>
  298.   <choice id="JavaEssentials" start_visible="false" start_selected="true">
  299.     <pkg-ref id="com.apple.pkg.JavaEssentials"/>
  300.   </choice>
  301.   <choice id="MediaFiles" start_visible="false" start_selected="true">
  302.     <pkg-ref id="com.apple.pkg.MediaFiles"/>
  303.   </choice>
  304.   <choice id="OxfordDictionaries" start_visible="false" start_selected="true">
  305.     <pkg-ref id="com.apple.pkg.OxfordDictionaries"/>
  306.   </choice>
  307.   <choice id="OSInstallScripts" start_visible="false" start_selected="true">
  308.     <pkg-ref id="com.apple.pkg.OSInstall"/>
  309.   </choice>
  310.   <choice id="AdditionalSpeechVoices" start_visible="false" start_selected="true">
  311.     <pkg-ref id="com.apple.pkg.AdditionalSpeechVoices"/>
  312.   </choice>
  313.   <choice id="X11" start_selected="true" start_visible="false">
  314.     <pkg-ref id="com.apple.pkg.X11redirect" active="needsX11redirect()"/>
  315.   </choice>
  316.   <pkg-ref id="com.apple.pkg.AdditionalSpeechVoices" auth="root">AdditionalSpeechVoices.pkg</pkg-ref>
  317.   <pkg-ref id="com.apple.pkg.AsianLanguagesSupport" auth="root">AsianLanguagesSupport.pkg</pkg-ref>
  318.   <pkg-ref id="com.apple.pkg.BaseSystemBinaries" auth="root">BaseSystemBinaries.pkg</pkg-ref>
  319.   <pkg-ref id="com.apple.pkg.BaseSystemResources" auth="root">BaseSystemResources.pkg</pkg-ref>
  320.   <pkg-ref id="com.apple.pkg.BSD" auth="root">BSD.pkg</pkg-ref>
  321.   <pkg-ref id="com.apple.pkg.Essentials" auth="root">Essentials.pkg</pkg-ref>
  322.   <pkg-ref id="com.apple.pkg.AdditionalEssentials" auth="root">AdditionalEssentials.pkg</pkg-ref>
  323.   <pkg-ref id="com.apple.pkg.OSUpgrade" auth="root">OSUpgrade.pkg</pkg-ref>
  324.   <pkg-ref id="com.apple.pkg.JavaEssentials" auth="root">JavaEssentials.pkg</pkg-ref>
  325.   <pkg-ref id="com.apple.pkg.MediaFiles" auth="root">MediaFiles.pkg</pkg-ref>
  326.   <pkg-ref id="com.apple.pkg.OSInstall" auth="root">OSInstall.pkg</pkg-ref>
  327.   <pkg-ref id="com.apple.pkg.OxfordDictionaries" auth="root">OxfordDictionaries.pkg</pkg-ref>
  328.   <pkg-ref id="com.apple.pkg.X11redirect" auth="root">X11redirect.pkg</pkg-ref>
  329.   <pkg-ref id="com.apple.pkg.JavaTools" auth="root">JavaTools.pkg</pkg-ref>
  330.   <pkg-ref id="com.apple.mpkg.OSInstall" auth="root" version="10.9.0">OSInstall.mpkg</pkg-ref>
  331.   <system-image id="com.apple.dmg.MacOSX">InstallESD.dmg<pkg-ref id="com.apple.pkg.AdditionalEssentials" installKBytes="148274" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.AdditionalSpeechVoices" installKBytes="286659" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.AsianLanguagesSupport" installKBytes="3914" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.BaseSystemBinaries" installKBytes="533973" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.BaseSystemResources" installKBytes="346048" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.BSD" installKBytes="669815" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.Essentials" installKBytes="4509274" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.JavaEssentials" installKBytes="6490" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.JavaTools" installKBytes="92" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.MediaFiles" installKBytes="67926" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.OSInstall" installKBytes="0" version="10.9.0.1"/><pkg-ref id="com.apple.pkg.OSUpgrade" installKBytes="0" version="10.9.0.1"/><pkg-ref id="com.apple.pkg.OxfordDictionaries" installKBytes="99984" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.pkg.X11redirect" installKBytes="3391" version="10.9.0.1.1.1306847324"/><pkg-ref id="com.apple.mpkg.OSInstall" auth="root" version="10.9.0"/></system-image>
  332.   <system-image id="com.apple.dmg.MacOSX" version="10.9.0.1.1.1306847324" sha1="a8c7bfe475f047bbb09a41e1818f66d9b1efcaaa"/>
  333. </installer-gui-script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement