Advertisement
Guest User

Wacom's idea of an installationCheck script for OSX

a guest
Sep 18th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.80 KB | None | 0 0
  1. #! /usr/bin/perl -w
  2. ###################################################################
  3. #
  4. # Make sure the user's system is one we should be installing on
  5. #   i.e. The driver no longer supports PPC machines, so don't run the installer
  6. #       on a PPC machine.
  7. #
  8. # Copyright WACOM Technologies, Inc. 2012
  9. # All rights reserved.
  10. ###################################################################
  11.  
  12. use strict;
  13. use Env;
  14. use File::Basename;
  15.  
  16. my $CPU_TYPE_MC680x0        = 6;
  17. my $CPU_TYPE_X86            = 7;
  18. my $CPU_TYPE_MC98000        = 10;
  19. my $CPU_TYPE_HPPA           = 11;
  20. my $CPU_TYPE_ARM            = 12;
  21. my $CPU_TYPE_MC88000        = 13;
  22. my $CPU_TYPE_SPARC          = 14;
  23. my $CPU_TYPE_I860           = 15;
  24. my $CPU_TYPE_POWERPC        = 18;
  25.  
  26.  
  27.  
  28.  
  29. ###################################################################
  30. sub main
  31. {
  32.     my $installationCheck_location = dirname($0);
  33.    
  34.     my $parameter1 = 'tell application "Finder"';
  35.     my $parameter2 = 'activate';
  36.     my $parameter3 = 'display dialog "This driver will not run on a PowerPC machine. Please install version 6.1.6"';
  37.     my $parameter4 = 'end tell';
  38.     my $returnValue = 0;
  39.     my $swVersion = `sw_vers -productVersion`;
  40.     my $swMinorVersion = 0;
  41.    $ENV{PATH} = "";
  42.     delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};   # Make %ENV safer
  43.    
  44.  
  45.     print "Begin Installation Check\n";
  46.     #my $theArchictectureType = system(qq(/usr/sbin/sysctl), qq(hw.cputype));
  47.     my $theArchictectureType = `/usr/sbin/sysctl -n hw.cputype`;
  48.    
  49.     print "theArchictectureType = $theArchictectureType\n";
  50.     #is this is a PPC machine? Then quit, and explain why to the user via a dialog using Applescript
  51.     if ($theArchictectureType == $CPU_TYPE_POWERPC){
  52.     #if ($theArchictectureType == $CPU_TYPE_X86){
  53.         print "Unsupported architecture:PPC\n";
  54.         #rather than showing a dialog box here, return an failure code. Packagemaker will then
  55.         #look up the correct localized string from installationCheck.strings, and show that in
  56.         #a dialog. The string index will be the returned value - 96 (e.g. 112-96=16)
  57.         $returnValue = 112;
  58.         #system "/usr/bin/osascript -e '$parameter1' -e '$parameter2' -e '$parameter3' -e '$parameter4'";
  59.         }
  60.    
  61.     if ($swVersion)
  62.    {
  63.      
  64.       my $minorVersionNumber = int(substr($swVersion, 3,1));
  65.       my $majorVersionNumber = int(substr($swVersion, 0,2));
  66.       if(($majorVersionNumber == 10) && ($minorVersionNumber > 5))
  67.       {
  68.          #10.6 and newer are supported.
  69.             print("Supported OS Version detected ",$majorVersionNumber,".", $minorVersionNumber);
  70.       }
  71.       else
  72.       {
  73.          print("Unsupported OS version ", $swVersion);
  74.          $returnValue = 113;
  75.       }
  76.  
  77.    }
  78.     print "End Installation Check\n";
  79.     exit ($returnValue);
  80. }
  81.  
  82.  
  83.  
  84. ###################################################################
  85. main();
  86.  
  87.  
  88.  
  89. ###################################################################
  90. __END__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement