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