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