home *** CD-ROM | disk | FTP | other *** search
/ Peanuts NeXT Software Archives / Peanuts-2.iso / Developer / webobjects / extensions / win-nt / NTPerl5-109.exe / INSTALL.BAT next >
Encoding:
DOS Batch File  |  1996-08-09  |  8.3 KB  |  307 lines

  1. @rem = '--*-Perl-*--';
  2. @rem = '
  3. @echo off
  4. if not exist ntt\perl.exe goto perlnotthere
  5. echo ntt\perl.exe exists, copying into current directory
  6. del  perl.exe
  7. copy ntt\perl.exe .
  8. if not exist ntt\perl100.dll goto perlnotthere
  9. del  perl100.dll
  10. copy ntt\perl100.dll .
  11. :perldllnotthere
  12. :perlnotthere
  13. if exist perl.exe goto perlhere
  14. echo Could not find Perl interpreter!!
  15. echo *gasp* *wheez* *choke*
  16. pause
  17. goto endofperl 
  18. :perlhere
  19. if exist perl100.dll goto perldllhere
  20. echo Could not find Perl100.dll
  21. echo *gasp* *wheez* *choke*
  22. pause
  23. goto endofperl
  24. :perldllhere
  25. cls
  26. perl.exe install.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  27. goto endofperl
  28. @rem ';
  29.  
  30. BEGIN{
  31. @INC = qw( Lib 
  32.     Ext );
  33.  
  34. };
  35.  
  36. require "NT.ph";
  37.  
  38.  
  39. #(c) 1995 Microsoft Corporation. All rights reserved. 
  40. #        Developed by hip communications inc., http://info.hip.com/info/
  41.  
  42. print <<'--end--';
  43.  
  44.     *** Welcome to the Perl installation script ***
  45.  
  46.  
  47. This script will install Perl for Win32 into a destination directory of
  48. your choice.  Do you wish to proceed? [Y/n]
  49. --end--
  50. $in = <STDIN>;
  51. until ( $in eq "\n" || $in =~ /^y/i ) {
  52.     exit if ( $in =~ /^no?\n$/i );
  53.     print "Do you wish to proceed? [Y/n]";
  54.     $in = <STDIN>;
  55. }
  56.  
  57.  
  58. open ( LOG, '>>install.log' ) || warn "Couldn't open log file!\n";
  59.  
  60. require 'ctime.pl' || warn "$!\nDid you preserve the directory structure when you unzipped?\n";
  61. $date = ctime( time );
  62. &log( $date );
  63.  
  64. sub log {
  65.     ( $message ) = @_;
  66.     print LOG $message;
  67.     print $message;
  68. }
  69.  
  70. sub gripe {
  71.     ( $message ) = @_;
  72.     print LOG $message;
  73.     warn $message;
  74. }
  75.  
  76. sub mkdirs {
  77.     my(@path);
  78.     my $p='';
  79.     @path=split(/[\/\\]/, $_[0]);
  80.     $p=shift(@path) if $path[0] =~ /[a-zA-Z]:/;
  81.     foreach (@path) {
  82.     if(!($_ eq '')) {
  83.         $p.= "\\" . $_;
  84.         if(! -d $p) { return 0 if !mkdir($p,0); }
  85.     }
  86.     }
  87.     return $p;
  88. }
  89.  
  90. NTRegOpenKeyEx(&HKEY_LOCAL_MACHINE,
  91.   'SOFTWARE\Microsoft\Resource Kit\PERL5',
  92.   &NULL, &KEY_ALL_ACCESS, $hkey );
  93. NTRegQueryValueEx($hkey,'BIN',&NULL,$type,$PERL_BIN);
  94. NTRegCloseKey($hkey);
  95. if(!$PERL_BIN) { $PERL_BIN='C:\usr\perl\bin'; }
  96.  
  97. @PERL_DIR=split(/[\/\\]/,$PERL_BIN);
  98. pop @PERL_DIR;
  99. $PERL_DIR=join("\\",@PERL_DIR);
  100.  
  101. print "\nPlease specify path where Perl should be installed.\n";
  102. print "Full path [$PERL_DIR] ";
  103. $in = <STDIN>;
  104. if (!($in eq "\n")) { chop($in); $PERL_DIR=$in; }
  105. if(!-d $PERL_DIR) {
  106.     &gripe("Could not create directory $PERL_DIR\n") if !&mkdirs($PERL_DIR);
  107. }
  108. chop( $thisdir = `cd` );
  109.  
  110. print "\n";
  111. &log("Copying Perl files into $PERL_DIR\n");
  112. print "Please wait...";
  113. `xcopy "$thisdir" "$PERL_DIR" /E /Q`;
  114. print "\n";
  115.  
  116.  
  117. #chop( $perldir = `cd` );
  118. $perldir=$PERL_DIR;
  119.  
  120. $libdir = $perldir . '\lib';
  121. $docdir = $perldir . '\docs';
  122.  
  123. $perldir =~ s/\\5\.001//;
  124. $bindir = $perldir . '\bin';
  125.  
  126.  
  127. if ( -d $bindir ) {
  128.     &log( "$bindir exists\n" );
  129. } else {
  130.     &log( "creating $bindir\n" );
  131.     mkdir( $bindir, 0 ) || die $!;
  132. }
  133.  
  134. if( Win32::IsWinNT() ){
  135.     ( $myversion ) = grep( /perl[^\d]*(\d\.\d\.?\d\.?\d)/, `perl -v` );
  136.     ( $myversion ) = $myversion =~ /perl[^\d]*(\d\.(\d\.?)+)/;
  137. }
  138. else{
  139.     $myversion=95;
  140.     }
  141.     
  142.  
  143. &log( "Installing Perl for Win32 into $perldir\n" );
  144.  
  145.  
  146.  
  147. if ( -f "$bindir\\perl.exe" ) {
  148.     if( Win32::IsWinNT() ){
  149.         ( $version ) = grep( /perl[^\d]*(\d\.\d\.?\d\.?\d)/, `$bindir\\perl -v` );    
  150.         ( $version ) = $version =~ /perl[^\d]*(\d\.(\d\.?)+)/;
  151.     }
  152.     else{
  153.         $version = 95;
  154.     }
  155.  
  156.     &log( "Previous version $version exists in bin directory,\n" );
  157.     &log( "Renaming it to perl.$version.exe\n" );
  158.     rename "$bindir\\perl.exe", "$bindir\\perl.$version.exe";
  159. }
  160.  
  161. if ( -f "$bindir\\perl100.dll"){
  162.     $version=$version?$version:"old";                
  163.     &log("Renaming perl100.dll to perl100.$version.dll\n");
  164.     rename "$bindir\\perl100.dll","$bindir\\perl100.$version.dll";
  165. }
  166.  
  167.  
  168. &log("Copying over perl100.dll to $bindir \n");
  169. `copy ntt\\perl100.dll "$bindir\\perl100.dll"`;
  170.  
  171.  
  172. &log( "Copying over perl and utility scripts to $bindir\n" );
  173.  
  174. `copy ntt\\perl.exe "$bindir"`;
  175. `copy ntt\\perlglob.exe "$bindir"`;
  176. `copy ntt\\cmd32.exe "$bindir"`;
  177. `copy pl2bat.bat "$bindir"`;
  178.  
  179.  
  180. NTRegCreateKeyEx( &HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Resource Kit\PERL5',
  181.     &NULL, 'NT Perl 5', ®_OPTION_NON_VOLATILE, &KEY_ALL_ACCESS, &NULL,
  182.     $hkey, $disposition ) ?
  183.     &log( "Added key for Perl 5 to NT Registry Database..\n" ):
  184.     &gripe( "Couldn't add key for Perl 5 to NT Registry Database!!\n" );
  185.  
  186. if ( $disposition  == ®_OPENED_EXISTING_KEY ) {
  187.     &gripe( "Key exists already, modifying existing key...\n" );
  188. }
  189.  
  190. NTRegSetValueEx( $hkey, 'BIN', &NULL, ®_SZ, "$bindir" ) ?
  191.     &log( "Adding $bindir to script path information\n" ):
  192.     &gripe( "Couldn't add script path to registry!!\n" );
  193.  
  194. NTRegSetValueEx( $hkey, 'PRIVLIB', &NULL, ®_SZ, "$libdir" ) ?
  195.     &log( "Adding $libdir to library include path information\n" ):
  196.     &gripe( "Couldn't add library path to registry!!\n" );
  197.  
  198. NTRegSetValueEx( $hkey, 'HTML-DOCS', &NULL, ®_SZ, "$docdir" ) ?
  199.     &log( "Adding $docdir to documentation directory\n" ) :
  200.     &gripe( "Couldn't add documentation directory to registry!!\n" );
  201.  
  202. NTRegCloseKey( $hkey );
  203.  
  204. $fred = 'foo bar baz';
  205.  
  206. until ( $fred =~ /^(y|n)/i || $fred eq '' ) {
  207.     print "Modify search path? [Y/n]";
  208.     chop( $fred = <STDIN> );
  209. }
  210.  
  211. unless ( $fred =~ /^n/i ) {
  212.         if( Win32::IsWinNT() ){
  213.             NTRegOpenKeyEx ( &HKEY_LOCAL_MACHINE,
  214.                 'SYSTEM\CurrentcontrolSet\control\Session Manager\Environment',
  215.                 &NULL, &KEY_ALL_ACCESS, $hkey ) ?
  216.                 &log( "Retrieving Path information from session manager\n" ):
  217.                 &gripe( "Couldn't retrieve path information from session manager!!\n" );
  218.         
  219.             NTRegQueryValueEx( $hkey, 'Path', &NULL, $type, $pathstring );
  220.         
  221.             $pathstring =
  222.                 ".;$bindir;" . join (';', grep(!/(perl|\.)/i, split(/;/, $pathstring))) . ";";
  223.         
  224.             NTRegSetValueEx( $hkey, 'Path', &NULL, $type, $pathstring ) ?
  225.                 &log( "Updated path information in session manager\n" ):
  226.                 &gripe( "Couldn't update path information in session manager!!\n" );
  227.             NTRegCloseKey( $hkey );
  228.         }
  229.        else{ # must be win95, so update path in autoexec.bat
  230.         
  231.         &log("Attempting to change path in autoexec.bat");
  232.         ( $bootdrive = $ENV{'windir'} ) =~ s|\\.*||g;
  233.         &log( "bootdrive is $bootdrive\n");
  234.  
  235.         open( ABAT,">>$bootdrive\\autoexec.bat")||
  236.                 gripe( "Couldn't open $bootdrive\\autoexec.bat");
  237.  
  238.         print ABAT "path %path%;$bindir;\n";
  239.         close ABAT;
  240.  
  241.        }
  242.  
  243. }
  244.  
  245. #Check for IIS.
  246. if(!NTRegOpenKeyEx (&HKEY_LOCAL_MACHINE,
  247.                 'SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Script Map',
  248.                 &NULL,&KEY_ALL_ACCESS,$Servkey))
  249. {
  250.     print "No Microsoft Internet Information Server Installed\n";
  251.     print "Continue to install PerlIS.dll? [Y/n]";
  252.     $in = <STDIN>;
  253.     until( $in eq "\n" || $in =~ /^y/i )
  254.     {
  255.         if ( $in =~ /^no?\n$/i )
  256.         {
  257.             goto finishUp;
  258.         }
  259.         print "Continue? [Y/n]";
  260.         $in = <STDIN>;
  261.     }
  262. }
  263.  
  264. #copy PerlIS.dll into the bin directory.
  265. if ( -f "$bindir\\PerlIS.dll"){
  266.     $version=$version?$version:"old";                
  267.     &log("Renaming PerlIS.dll to PerlIS.$version.dll\n");
  268.     rename "$bindir\\PerlIS.dll","$bindir\\PerlIS.$version.dll";
  269. }
  270.  
  271.  
  272. &log("Copying over PerlIS.dll to $bindir \n");
  273. `copy ntt\\PerlIS.dll "$bindir\\PerlIS.dll"`;
  274.  
  275. #Ask for the extension to associate with perlIS.dll.
  276. print "\nPlease choose a file extension to associate with PerlIS.dll.";
  277. print "\nExtension:<pl is the default>";
  278.  
  279. $extension = <STDIN>;
  280. chop($extension);
  281. $extension = "pl" if ( $extension eq "" );    
  282. $extension = '.'.$extension unless ($extension =~ /\..*/ );
  283.  
  284. #make association.
  285.  
  286. NTRegSetValueEx( $Servkey,"$extension", &NULL, ®_SZ, "$bindir\\PerlIS.dll" ) ?
  287.     &log( "-->Association made\n" ) :
  288.     &gripe( "**Association of $extension to $bindir\\PerlIS.dll failed!!\n" );
  289.  
  290. NTRegCloseKey( $Servkey );
  291.  
  292. finishUp:
  293. print "\n";
  294. &log( "Perl $myversion installation finished.\n" );
  295. print "NOTE: The updated path information will not take effect\n";
  296. if( Win32::IsWinNT() ){
  297.         print "      until you log off and back on again. enjoy ;-)\n";
  298. }
  299. else{
  300.         print "      until you reboot your machine. enjoy ;-)\n";
  301. }
  302.  
  303. print "\nHit return to exit: "; $in=<STDIN>;
  304.  
  305. __END__
  306. :endofperl
  307.