/[cvs]/nfo/perl/libs/libsetup.pm
ViewVC logotype

Diff of /nfo/perl/libs/libsetup.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by cvsjoko, Sat Jul 27 00:28:36 2002 UTC revision 1.4 by joko, Sun Dec 15 02:03:58 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.4  2002/12/15 02:03:58  joko
7    #  + using Tie::IxHash to keep the order of modules (passed in via an array)
8    #
9    #  Revision 1.3  2002/12/01 22:12:25  joko
10    #  + changed status-flags: 0 => 'notok'   1 => 'ok'
11    #
12    #  Revision 1.2  2002/10/25 11:38:50  joko
13    #  + sub checkCommonDeps
14    #  + sub checkDeps_orig
15    #  + refactored sub checkDeps
16    #
17  #  Revision 1.1  2002/07/27 00:28:36  cvsjoko  #  Revision 1.1  2002/07/27 00:28:36  cvsjoko
18  #  + new  #  + new
19  #  #
# Line 10  Line 21 
21  #  #
22  #################################  #################################
23    
 package libsetup;  
24    
25  require Exporter;  package libsetup;
 @ISA = qw( Exporter );  
 @EXPORT = qw(  
     Dumper  
     md5 md5_hex md5_base64  
     ParseDate UnixDate  
     strftime  
     stripHtml stripSpaces stripNewLines toReal trim  
     croak  
     array_getDifference  
 );  
26    
27  use strict;  use strict;
28  use warnings;  use warnings;
29    
30    use Tie::IxHash;
31    
32    my @modules = qw(  my @modules = qw(
33          Data::Dumper Digest::MD5 POSIX Carp    Data::Dumper Digest::MD5 POSIX Carp
34          LWP::UserAgent HTML::PullParser    LWP::UserAgent HTML::PullParser
35          Date::Manip    Date::Manip
36          DBI DBD::mysql    DBI DBD::mysql
37          Set::Object Tangram Class::Tangram    Set::Object Tangram Class::Tangram
38          WDDX    WDDX
39    );  );
40    
41    
42    sub setupCpanModule {  sub setupCpanModule {
43      my $module = shift;    my $module = shift;
44      use CPAN;    use CPAN;
45      print "try to setup module \"$module\"? (remember to be root) (y|n) ";    print "try to setup module \"$module\"? (remember to be root) (y|n) ";
46      my $result = <STDIN>;    my $result = <STDIN>;
47      print "\n";
48      chomp($result);
49      if (lc($result) eq 'y') {
50        print "installing \"$module from CPAN\" ...";
51        if (CPAN::install($module)) {
52    print "ok";
53    return 1;
54        } else {
55    print "failed";
56    exit;
57        }
58      print "\n";      print "\n";
     chomp($result);  
     if (lc($result) eq 'y') {  
       print "installing \"$module from CPAN\" ...";  
       if (CPAN::install($module)) {  
         print "ok";  
         return 1;  
       } else {  
         print "failed";  
         exit;  
       }  
       print "\n";  
59    
60        #my $obj = CPAN::Shell->expand('Module',$module);      #my $obj = CPAN::Shell->expand('Module',$module);
61        #$obj->install;      #$obj->install;
     }  
62    }    }
63    }
64    
65    
66  sub checkDeps {  sub checkCommonDeps {
67      checkDeps_orig(\@modules);
68    }
69    
70    sub checkDeps_orig {
71      my $modules = shift;
72      my @modules = @{$modules};
73    map {    map {
74      #print $_, "\n";      #print $_, "\n";
75      print "testing for \"$_\" ...";      print "testing for \"$_\" ...";
# Line 83  sub checkDeps { Line 90  sub checkDeps {
90    } @modules;    } @modules;
91  }  }
92    
93    sub checkDeps {
94      my $modules = shift;
95      my @modules = @{$modules};
96      my $result;
97      tie %$result, 'Tie::IxHash';
98      map {
99        my $evalcmd = "use $_;";
100        eval($evalcmd);
101        if ($@) {
102          $result->{$_} = 'notok';
103        } else {
104          $result->{$_} = 'ok';
105        }
106      } @modules;
107      return $result;
108    }
109    
110  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed