home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / mac / Software / entwickl / win95 / pw32i306.exe / bin / perlw32-install.bat < prev    next >
DOS Batch File  |  1997-04-09  |  7KB  |  216 lines

  1. @rem = '--*-Perl-*--';
  2. @rem = '
  3. @echo off
  4. if exist perl.exe goto perlhere
  5. cd bin
  6. if not exist perl.exe goto perlnotthere
  7. :perlhere
  8. if not exist Perl300.dll goto perlnotthere
  9. if not exist Perlglob.exe goto perlnotthere
  10. perl.exe PerlW32-install.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  11. goto endofperl
  12. @rem ';
  13.  
  14. BEGIN{
  15.     @INC = qw( ..\Lib ..\Ext );
  16.  
  17. };
  18.  
  19. require "NT.ph";
  20. # xxx get rid of this dpreciated syntax !!!!
  21.  
  22. #(c) 1996 Microsoft Corporation. All rights reserved. 
  23. #    Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
  24.  
  25.  
  26. # TODO xxxx check if a copy of Perl is already installed
  27. # --- important on systems that have Res Kit installed
  28. # get the version of our binary, then cd up a level
  29. # and exec perl.exe -v to see if it exists -- note
  30. # that our new binary could alread be in path, so check
  31. # build info to see if it is what we get back if we
  32. # exec ourselves
  33.  
  34.  
  35. print <<'--end--';
  36. This install script assumes that you have unpacked 
  37. Perl for Win32 into the final intended destination 
  38. directory.
  39. Do you wish to proceed? [Y/n]
  40. --end--
  41. $in = <STDIN>;
  42. until ( $in eq "\n" || $in =~ /^y/i ) {
  43.     exit if ( $in =~ /^no?\n$/i );
  44.     print "Do you wish to proceed? [Y/n]";
  45.     $in = <STDIN>;
  46. }
  47.  
  48.  
  49. chop( $perldir = `cd` );
  50. $bindir = $perldir;
  51. $perldir =~ s/\\bin$//mi;
  52.  
  53. print "perldir = $perldir\n";
  54.  
  55. $libdir = $perldir . '\lib';
  56. $docdir = $perldir . '\docs';
  57.  
  58. require 'ctime.pl' || warn "$!\nDid you preserve the directory structure when you unzipped?\n";
  59.  
  60. $date = ctime( time );
  61.  
  62. if( Win32::IsWinNT() ){
  63.     ( $myversion ) = grep( /perl[^\d]*(\d\.\d\.?\d\.?\d)/, `perl -v` );
  64.     ( $myversion ) = $myversion =~ /perl[^\d]*(\d\.(\d\.?)+)/;
  65. }
  66. else{
  67.     $myversion=95;
  68.     }
  69.     
  70.  
  71. open ( LOG, '>>install.log' ) || warn "Couldn't open log file!\n";
  72.  
  73. &log( $date );
  74.  
  75. sub log {
  76.     ( $message ) = @_;
  77.     print LOG $message;
  78.     print $message;
  79. }
  80.  
  81. sub gripe {
  82.     ( $message ) = @_;
  83.     print LOG $message;
  84.     warn $message;
  85. }
  86.  
  87. &log( "Installing Perl for Win32 into $perldir\n" );
  88.  
  89. Win32::RegCreateKeyEx( &HKEY_LOCAL_MACHINE, 'SOFTWARE\ActiveWare\Perl5',
  90.     &NULL, 'NT Perl 5', ®_OPTION_NON_VOLATILE, &KEY_ALL_ACCESS, &NULL,
  91.     $hkey, $disposition ) ?
  92.     &log( "Added key to HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveWare\\Perl5 ..\n" ):
  93.     &gripe( "Couldn't add key to HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveWare\\Perl5!!\n" );
  94.  
  95. if ( $disposition  == ®_OPENED_EXISTING_KEY ) {
  96.     &gripe( "Key exists already, modifying existing key...\n" );
  97. }
  98.  
  99. Win32::RegSetValueEx( $hkey, 'BIN', &NULL, ®_SZ, "$bindir" ) ?
  100.     &log( "Adding $bindir to script path information\n" ):
  101.     &gripe( "Couldn't add script path to registry!!\n" );
  102.  
  103. Win32::RegSetValueEx( $hkey, 'PRIVLIB', &NULL, ®_SZ, "$libdir" ) ?
  104.     &log( "Adding $libdir to library include path information\n" ):
  105.     &gripe( "Couldn't add library path to registry!!\n" );
  106.  
  107. Win32::RegSetValueEx( $hkey, 'HTML-DOCS', &NULL, ®_SZ, "$docdir" ) ?
  108.     &log( "Adding $docdir to documentation directory\n" ) :
  109.     &gripe( "Couldn't add documentation directory to registry!!\n" );
  110.  
  111. Win32::RegCloseKey( $hkey );
  112.  
  113. $fred = 'foo bar baz';
  114.  
  115. until ( $fred =~ /^(y|n)/i || $fred eq '' ) {
  116.     print "Modify search path? [Y/n]";
  117.     chop( $fred = <STDIN> );
  118. }
  119.  
  120. unless ( $fred =~ /^n/i ) {
  121.         if( Win32::IsWinNT() ){
  122.             Win32::RegOpenKeyEx ( &HKEY_LOCAL_MACHINE,
  123.                 'SYSTEM\CurrentcontrolSet\control\Session Manager\Environment',
  124.                 &NULL, &KEY_ALL_ACCESS, $hkey ) ?
  125.                 &log( "Retrieving Path information from session manager\n" ):
  126.                 &gripe( "Couldn't retrieve path information from session manager!!\n" );
  127.         
  128.             Win32::RegQueryValueEx( $hkey, 'Path', &NULL, $type, $pathstring );
  129.         
  130.             $pathstring =
  131.                 "$bindir;" . join (';', grep(!/perl/i, split(/;/, $pathstring))) . ";";
  132.         
  133.             Win32::RegSetValueEx( $hkey, 'Path', &NULL, $type, $pathstring ) ?
  134.                 &log( "Updated path information in session manager\n" ):
  135.                 &gripe( "Couldn't update path information in session manager!!\n" );
  136.             Win32::RegCloseKey( $hkey );
  137.         }
  138.        else{ # must be win95, so update path in autoexec.bat
  139.         
  140.         &log("Attempting to change path in autoexec.bat\n");
  141.         ( $bootdrive = $ENV{'windir'} ) =~ s|\\.*||g;
  142.         &log( "bootdrive is $bootdrive\n");
  143.  
  144.         open( ABAT,">>$bootdrive\\autoexec.bat") ||
  145.                 gripe( "Couldn't open $bootdrive\\autoexec.bat");
  146.  
  147.         print ABAT "path %path%;$bindir;\n";
  148.         close ABAT;
  149.  
  150.        }
  151.  
  152. }
  153.  
  154. if( Win32::IsWinNT() ){
  155.     $fred = 'foo bar baz';
  156.     until ( $fred =~ /^(y|n)/i || $fred eq '' ) {
  157.         print "Associate .pl with Perl.exe? [Y/n]";
  158.         chop( $fred = <STDIN> );
  159.     }
  160.     unless ( $fred =~ /^n/i ) {
  161.         ($sCSDVersion, $MajorVersion, $MinorVersion, $BuildNumber, $PlatformId) = Win32::GetOSVersion;
  162.         if($MajorVersion >= 4)
  163.         {
  164.             &log( "Associating .pl extension with Perl.exe.\n" );
  165.             `assoc .pl=Perl`;
  166.             `ftype Perl=perl.exe \%1 \%*`;
  167.             #
  168.             # unable to locate where PATHEXT is in the registry
  169.             # `set PATHEXT=%PATHEXT%;.pl`;
  170.             # print "\nIf foo.pl is in the PATH, typing foo at any command prompt will run it.\n\n";
  171.             #
  172.             print "\nIf foo.pl is in the PATH, typing foo.pl at any command prompt will run it.\n\n";
  173.         }
  174.     }
  175. }
  176.  
  177. if( Win32::IsWinNT() ){
  178.     if(Win32::RegOpenKeyEx (&HKEY_LOCAL_MACHINE,
  179.                 'SYSTEM\CurrentControlSet\Services\W3SVC\Parameters',
  180.                 &NULL,&KEY_ALL_ACCESS,$Servkey)) {
  181.         $fred = 'foo bar baz';
  182.         until ( $fred =~ /^(y|n)/i || $fred eq '' ) {
  183.             print "Add registry key to support standard I/O redirection in IIS? [Y/n]";
  184.             chop( $fred = <STDIN> );
  185.         }
  186.         unless ( $fred =~ /^n/i ) {
  187.             Win32::RegSetValueEx( $Servkey, "CreateProcessWithNewConsole", &NULL, ®_DWORD, 1 ) ?
  188.                 &log( "Added CreateProcessWithNewConsole value for IIS\n" ) :
  189.                 gripe( "Adding CreateProcessWithNewConsole value for IIS failed!!\n" );
  190.         }
  191.         Win32::RegCloseKey( $Servkey );
  192.     }
  193. }
  194.  
  195. finishUp:
  196. &log( "Perl $myversion installation finished.\n" );
  197. print "NOTE: The updated path information will not take effect\n";
  198. if( Win32::IsWinNT() ){
  199.         print "      until you log off and back on again. enjoy ;-)\n";
  200. }
  201. else{
  202.         print "      until you reboot your machine. enjoy ;-)\n";
  203. }
  204.  
  205.  
  206. __END__
  207. :perlnotthere
  208. echo Could not find Perl interpreter!!
  209. echo *gasp* *wheez* *choke*
  210. echo Did you build it? I looked in
  211. @echo off
  212. cd
  213. :endofperl
  214. notepad ..\docs\Perl-Win32\release.txt
  215. pause
  216.