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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Fri Oct 25 11:38:50 2002 UTC (22 years ago) by joko
Branch: MAIN
Changes since 1.1: +27 -3 lines
+ sub checkCommonDeps
+ sub checkDeps_orig
+ refactored sub checkDeps

1 cvsjoko 1.1 #################################
2     #
3 joko 1.2 # $Id: libsetup.pm,v 1.1 2002/07/27 00:28:36 cvsjoko Exp $
4     #
5     # $Log: libsetup.pm,v $
6     # Revision 1.1 2002/07/27 00:28:36 cvsjoko
7     # + new
8 cvsjoko 1.1 #
9     #
10     #
11     #################################
12    
13     package libsetup;
14    
15     require Exporter;
16     @ISA = qw( Exporter );
17     @EXPORT = qw(
18     Dumper
19     md5 md5_hex md5_base64
20     ParseDate UnixDate
21     strftime
22     stripHtml stripSpaces stripNewLines toReal trim
23     croak
24     array_getDifference
25     );
26    
27     use strict;
28     use warnings;
29    
30    
31     my @modules = qw(
32     Data::Dumper Digest::MD5 POSIX Carp
33     LWP::UserAgent HTML::PullParser
34     Date::Manip
35     DBI DBD::mysql
36     Set::Object Tangram Class::Tangram
37     WDDX
38     );
39    
40    
41     sub setupCpanModule {
42     my $module = shift;
43     use CPAN;
44     print "try to setup module \"$module\"? (remember to be root) (y|n) ";
45     my $result = <STDIN>;
46     print "\n";
47     chomp($result);
48     if (lc($result) eq 'y') {
49     print "installing \"$module from CPAN\" ...";
50     if (CPAN::install($module)) {
51     print "ok";
52     return 1;
53     } else {
54     print "failed";
55     exit;
56     }
57     print "\n";
58    
59     #my $obj = CPAN::Shell->expand('Module',$module);
60     #$obj->install;
61     }
62     }
63    
64    
65 joko 1.2 sub checkCommonDeps {
66     checkDeps_orig(\@modules);
67     }
68    
69     sub checkDeps_orig {
70     my $modules = shift;
71     my @modules = @{$modules};
72 cvsjoko 1.1 map {
73     #print $_, "\n";
74     print "testing for \"$_\" ...";
75     my $evalcmd = "use $_;";
76     eval($evalcmd);
77     if ($@) {
78     print "failed"; print "\n";
79     #print $@, "\n";
80     #print "could not load \"$_\", maybe this module is not installed", "\n";
81     if (!setupCpanModule($_)) {
82     print "setup of \"$_\" failed, exit.", "\n";
83     exit;
84     }
85     } else {
86     print "ok";
87     }
88     print "\n";
89     } @modules;
90     }
91    
92 joko 1.2 sub checkDeps {
93     my $modules = shift;
94     my @modules = @{$modules};
95     my $result;
96     map {
97     my $evalcmd = "use $_;";
98     eval($evalcmd);
99     if ($@) {
100     $result->{$_} = 0;
101     } else {
102     $result->{$_} = 1;
103     }
104     } @modules;
105     return $result;
106     }
107 cvsjoko 1.1
108     1;

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