home *** CD-ROM | disk | FTP | other *** search
/ Click Press Kit / Click Press Kit.iso / mac / QuickTime704.pkg / Contents / Resources / preflight < prev    next >
Encoding:
Text File  |  2005-09-02  |  4.7 KB  |  191 lines

  1. #!/usr/bin/perl
  2.  
  3. my $SYSVERS = "$ARGV[3]"."/System/Library/CoreServices/SystemVersion.plist";
  4. ##################
  5.  
  6. sub CheckVersion
  7. {
  8.     my $path            = $_[0];
  9.     my $version         = $_[1];
  10.     my $keyName         = $_[2];
  11.     my $operator        = $_[3];
  12.  
  13.     if (! -e $path) {
  14.         return 0;
  15.     }
  16.  
  17.     if (!$operator) {
  18.         $operator = "==";
  19.     }
  20.  
  21.     my $oldSeperator = $/;
  22.     $/ = \0;
  23.  
  24.     open( PLIST, "$path") || do {
  25.         return 0;
  26.     };
  27.  
  28.     $plistData = <PLIST>;
  29.     $plistData =~ /<dict>(.*?)<\/dict>/gis;
  30.  
  31.     @items = split(/<key>/, $plistData);
  32.  
  33.     shift @items;
  34.     foreach $item (@items) {
  35.         $item =~ /(.*?)<\/key>.*?<string>(.*?)<\/string>/gis;
  36.         $versiondata{ $1 } = $2;
  37.     }
  38.  
  39.     close(PLIST);
  40.  
  41.     $/ = $oldSeperator;
  42.  
  43.     @theVersionArray = split(/\./, $versiondata{$keyName});
  44.     for ($i = 0; $i < 3; $i++) {
  45.         if(!$theVersionArray[$i]) {
  46.             $theVersionArray[$i] = '0';
  47.         }
  48.     }
  49.  
  50.     @versionArray = split(/\./, $version);
  51.     
  52.     my $actualVersion;
  53.  
  54.     for ($i = 0; $i < 3; $i++) {
  55.         if (($theVersionArray[$i] != $versionArray[$i]) or ($i == 2)) {
  56.  
  57.             $actualVersion = $theVersionArray[$i];
  58.             $version = $versionArray[$i];
  59.  
  60.             last;
  61.         }
  62.     }
  63.  
  64.     my $expression = '$actualVersion ' . $operator . ' $version';
  65.     if( eval ($expression) )
  66.     {
  67.         return 1;
  68.     }
  69.     else
  70.     {
  71.         return 0;
  72.     }
  73.  
  74. }
  75.  
  76.  
  77. ########################################
  78.  
  79. my $runnerPID = getppid();
  80. my $installerPID = "";
  81. my $uid = "";
  82. my $uname = "";
  83.  
  84. open( PSOUT, "/bin/ps -axww -o pid,ppid -p $runnerPID |" );
  85. while( <PSOUT> ) {
  86.     my @fields = split '\s+', $_;
  87.     if ("$fields[1]" eq "$runnerPID") {
  88.         $installerPID = $fields[2];
  89.     }
  90. }
  91. close( PSOUT );
  92.  
  93. if ("$installerPID" ne "") {
  94.     open( PSOUT, "/bin/ps -axww -o pid,ruid -p $installerPID |" );
  95.     while( <PSOUT> ) {
  96.         my @fields = split '\s+', $_;
  97.         if ("$fields[1]" eq "$installerPID") {
  98.             $uid = $fields[2];
  99.         }
  100.     }
  101.     close( PSOUT );
  102. }
  103.  
  104. if ("$uid" ne "") {
  105.     open( PSOUTA, "/usr/bin/id -p $uid |" );
  106.     while( <PSOUTA> ) {
  107.         my @fields = split '\s+', $_;
  108.         if ("$fields[0]" eq "uid") {
  109.             $uname = $fields[1];
  110.         }
  111.     }
  112.     close( PSOUTA );
  113. }
  114.  
  115. # Marketing (aka Amy Fazio) sez we don't need to bring up the registration dialog anymore
  116. # but let's just comment it out for now in case they change their minds. - duano! 3/16/04
  117. # Yup, they changed their minds.   We do not need the registration anymore, but we still need
  118. # to put up the warning that they are about to lose their pro key.  -dennis  2/10/05
  119. if ("$ENV{COMMAND_LINE_INSTALL}" ne "1" && "$ENV{SOFTWARE_UPDATE}" ne "YES") {
  120.     my $ALERT_APP = "$ARGV[0]" . "/Contents/Resources/QT6Installer.app/Contents/MacOS/QT6Installer";
  121.     my $EXIT_VALUE = 0;
  122.     
  123.     my $cmd = "\"$ALERT_APP\" ";
  124.     if ("$uname" ne "") {
  125.         $cmd = "sudo -u $uname \"$ALERT_APP\" ";
  126.     } 
  127.     
  128.     $EXIT_VALUE = system("$cmd");
  129.     
  130.     if (($EXIT_VALUE >> 8) != 0) {
  131.         if ("$installerPID" ne "") {
  132.             kill "QUIT", $installerPID;
  133.         }
  134.         kill "QUIT", $runnerPID;
  135.         exit($EXIT_VALUE >> 8);
  136.     }
  137. }
  138.  
  139. ########
  140.  
  141. my $CLEANUP_PREFS = "$ARGV[0]" . "/Contents/Resources/CleanPrefs";
  142.  
  143. my $cmd = "\"$CLEANUP_PREFS\"";
  144. if ("$uname" ne "") {
  145.     $cmd = "sudo -u $uname \"$CLEANUP_PREFS\"";
  146. }
  147. system("$cmd");
  148.  
  149. my $QUICKTIME_VERS = "/System/Library/Frameworks/QuickTime.framework/Versions/A/Resources/version.plist";
  150.  
  151. my $Delete = "$ARGV[0]" . "/Contents/Resources/deleteomatic";
  152. my $DELETED_FILES="$ARGV[0]" . "/Contents/Resources/cleanup-list";
  153.  
  154. my $QuickTime_h = "QuickTime.h";
  155. my $Movies_h    = "Movies.h";
  156.  
  157. my $destinationBase = "$ARGV[3]" . "/System/Library/Frameworks/QuickTime.framework/Versions/A/Headers/";
  158. my $sourceBase = "$ARGV[0]" . "/Contents/Resources";
  159.  
  160.  ###########
  161.  
  162. my $devtools_check1 = "/Library/Receipts/DeveloperTools.pkg";
  163. my $devtools_check2 = "/Library/Receipt/DevTools.pkg";
  164. my $sdk_folder = "/Developer/SDKs";
  165. my $Headers_PKG= "$ARGV[0]" . "/Contents/Resources/QuickTime7Headers.pkg";
  166.  
  167. # remove the quicktime headers if quicktime is less than 7.0 and they have not read the license
  168. if (CheckVersion("$QUICKTIME_VERS", "7.0", "CFBundleVersion", "<")) {
  169.         if ( ! -e "/System/Library/Frameworks/QuickTime.framework/Versions/A/Headers/.qtheaderversion") {
  170.                 system ("$Delete \"$ARGV[2]\" \"$DELETED_FILES\"");
  171.                 # check if they are a quicktime developer
  172.                 if ((-e $devtools_check1) or (-e $devtools_check2)) {
  173.  
  174.                     # drop the mini installer
  175.                     if (! -e $sdk_folder) {
  176.                             system("/bin/mkdir \"$sdk_folder\"");
  177.                     }
  178.                     system("/bin/cp -rf \"$Headers_PKG\" \"$sdk_folder/\"");
  179.             
  180.                     #Replace with dummy headers
  181.                     system("/bin/cp -f \"$sourceBase/$QuickTime_h\" \"$destinationBase/$QuickTime_h\"");
  182.                     system("/bin/cp -f \"$sourceBase/$Movies_h\" \"$destinationBase/$Movies_h\"");
  183.             
  184.             }
  185.  
  186.     }
  187. }
  188.  
  189.  
  190.  
  191.