#!/usr/bin/perl ################################################################## $WrittenBy = "Arther Neal Garrett"; $Date = "Aug 26, 2004"; $Version = "v0.1"; ################################################################## $PERLVERSION = 584; #Minimum Perl Verion to scan for @REQLIBS = qw(File/Find.pm Net/FTP.pm Net/Telnet.pm Getopt/Std.pm Tk.pm Tk/JComboBox.pm Tk/ProgressBar/Mac.pm); $INSTSCRIPT = "NetExport.pl"; &AINIT; if($SPILTMILK > $TRAP) { print "Seaching for perl v$PERLVERSION or greater\n"; &LOCATEPERL; }else {$COMPPERL = 1;} chdir($curdir); unless ($COMPPERL) { print "Perl v${PERLVERSION} was not found on this server\n"; print "Please have your UNIX admin install perl v5.84 or\n"; print "later from http://www.activeperl.com\n"; exit; } if($SPILTMILK > $TRAP) { $PUI = "$curdir"."/"."$INSTSCRIPT"; &REWRITE; $PUI = "$curdir"."/"."Install.pl"; &REWRITE; print "$solperlpath v$VSTRING FOUND\!\n"; system "$PUI"; exit; } &LOCATELIBS; foreach $missingmod(@REQTRAK) { #Curent Directory needs a subdirectory called MODS containing each mod.pm $in = "$curdir"."/MODS/"."$missingmod"; if (-f $in) { $outdir = ($DIRa, $DIRb, $DIRc) = split(/\//,$missingmod); @ODIRS = <$DIRa $DIRb $DIRc>; @perlliboutdir = grep(/site/,@INC); $perlliboutdir = @perlliboutdir[0]; $out = "$perlliboutdir"."/"."$missingmod"; print "\n< $out\n"; foreach $MDIR(@ODIRS) { unless($MDIR =~ /\.pm$/) { $NEWDIR = "$perlliboutdir"."/"."$MDIR"; unless(-d $NEWDIR) { mkdir "$NEWDIR", 0777 or warn "Cannot make $NEWDIR directory: $!\n"; } $perlliboutdir = "$NEWDIR"; } } unless (-f $out) { $copy = `cp $in $out`; } } else { print "$in NOT FOUND\!\n"; } } foreach $libs(@foundlibs) { print "> $libs\n"; } print "\nDone.\n"; ############################################################################# ## SUBS ############################################################################# sub AINIT { $starttime = time(); use File::Find; @curdir = `pwd`; $curdir = @curdir[0]; chomp($curdir); $PUI = "$curdir"."/"."Install.pl"; ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks)= stat("$PUI"); $SPILTMILK = ($starttime - $mtime); $TRAP = 3;# Seconds } sub GETDIRLIST { opendir SUBD, $SUBDIR; @FILES = readdir(SUBD); @FILES = grep(/$findfile/,@FILES); close(SUBD); $filecount = (grep(/.*/,@FILES) - 2); } sub LOCATEFILE { push @DIRLIST, $FIND_DIR; chdir($FIND_DIR); @ARGZ = ("$FIND_DIR"); find sub {push @DIRLIST, $File::Find::name if -d}, @ARGZ; foreach $SUBDIR(@DIRLIST) { chomp($SUBDIR); if ($SUBDIR =~ /^\/proc/) {next;} if ($SUBDIR eq "." or $SUBDIR eq ".." or $SUBDIR =~ 'lost+found') {next;} &GETDIRLIST; foreach $filename (@FILES) { chomp($filename); $longname = "$SUBDIR"."/"."$filename"; if("$filename" eq "$findfile") { if (-f $longname) { @perlversion = `${SUBDIR}/${findfile} -v|grep "This is perl,"`; ($NULL, $VSTRING) = split(/,/,@perlversion[0]); if($VSTRING =~ "version") { ($NULL, $NULL, $VSTRING, $NULL, $NULL, $NULL) = split(/ /,$VSTRING); } else { ($NULL, $VSTRING, $NULL, $NULL, $NULL) = split(/ /,$VSTRING); ($NULL, $VSTRING) = split(/v/,$VSTRING); } ($VSTRING, $BUILD) = split(/_/,$VSTRING); $VSTRING = "$VSTRING"."."."$BUILD"; ($VerA, $VerB, $VerC, $VerD) = split(/\./,$VSTRING); $VSTRING = "$VerA"."${VerB}${VerC}${VerD}"; $VINT = substr("$VSTRING", 0, 3); $VINT = int($VINT); chomp($VSTRING); if ($VINT >= $PERLVERSION) { $solperlpath = "#!"."$SUBDIR"."/"."$findfile"; $COMPPERL = 1; } } } if($filename eq $findfile) {last;} } last if($COMPPERL); } } sub LOCATEPERL { $FIND_DIR = "/"; $findfile = "perl"; &LOCATEFILE; } sub LOCATELIBS { @REQTRAK = <@REQLIBS>; $REQTOTAL = grep(/.*/,@REQLIBS); foreach $libpath(@INC) { foreach $requiredlib(@REQLIBS) { $required = "$libpath"."/"."$requiredlib";; $skipper = grep(/$required/,@foundlibs); if (-f $required and $skipper < 1) { $pe = ($pe + 1); push @foundlibs, "$required"; @REQTRAK = grep(!/$requiredlib/,@REQTRAK); next; } } } } sub REWRITE { open INSTME, "$PUI"; @INSELF = ; close(INSTME); open NEWME, ">$PUI"; foreach $newmeline(@INSELF) { if($newmeline =~ /^#!/) { print NEWME "$solperlpath\n"; } else { print NEWME "$newmeline"; } } close(NEWME); }