#!/usr/bin/perl
#=========================================================== PSTINSTALL2
=pod

Aid pstinstall in getting archive_env(0) output.  

pstinstall cannot access any perl packages because when pstinstall is
invoked, the packages have not yet been linked properly.  As a result,
pstinstall cannot call archive_env(0).  However, after pstinstall has 
linked the other routines (including this one) and placed them in their
correct locations, it can then use their functions through pstinstall2.

pstinstall currently uses pstinstall2 to accomplish two tasks:

1. obtain environment variables and other parameters.
1. edit local.pm so it contains $PSTDIR.

note: pstinstall2 cannot use the edited version of local.pm, because it
already obtains file information at compile time; therefore, we should
disregard the output from local.pm regarding $PSTDIR and use instead 
what was passed to this routine.

usage: pstinstall2 $dir $file PSTDIR=$PSTDIR

HISTORY
  6-10-2001: Joe Werne
    1. include argument in call to archive_env()

=cut

use constant PSTDIR => "/usr/local/pst";
use lib PSTDIR;
use SET::Set;
use TUSC::archive;
#------------------------------------------------- Scope local variables
my (%e,$key,$dir,$file,%V,$tmp,@tmp);
#-------------------------------------------------- Read input variables
$dir  =$ARGV[0]; 
$file =$ARGV[1]; 
$tmp  =$ARGV[2];
#--------------------------- Parse PSTDIR key/value pair and store in %V
@tmp=split /\=/,$tmp,2;
$PSTDIR=$tmp[1]; 
#$V{$tmp[0]} = $PSTDIR;
#$V{SRCDIR}  = $PSTDIR;
#------------------------------------- Get and print archive_env(0) output
%e=archive_env(0);
#$V{ARCHIVE_HOST}=$e{ARCHIVE_HOST};

#foreach $key (keys %e) { 
#  if ($key ne "PST_NOTE" && $key ne "PSTDIR") {
#    print "\$$key=$e{$key}\n" 
#  }
#}
print "\nInstallation for $e{PST_SITE}\n";
print "\n$e{PST_NOTE}\n";
#--------------------------------------------------------- Edit local.pm
#@tmp=PSTset("$PSTDIR/$dir/PSTctd/CTD$file","no",\%V);
#$CSTAT = system("/bin/cp $tmp[1] $PSTDIR/$dir/$file");   
#if ($CSTAT != 0) {warn "Could not copy local.pm to $PSTDIR/$dir/\n"}
#else { unlink $tmp[1] }
#------------------------------------------------------ Our work is done
__END__
