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 |
# Revision 1.2 2002/10/25 11:38:50 joko |
13 |
# + sub checkCommonDeps |
# + sub checkCommonDeps |
14 |
# + sub checkDeps_orig |
# + sub checkDeps_orig |
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 checkCommonDeps { |
sub checkCommonDeps { |
94 |
my $modules = shift; |
my $modules = shift; |
95 |
my @modules = @{$modules}; |
my @modules = @{$modules}; |
96 |
my $result; |
my $result; |
97 |
|
tie %$result, 'Tie::IxHash'; |
98 |
map { |
map { |
99 |
my $evalcmd = "use $_;"; |
my $evalcmd = "use $_;"; |
100 |
eval($evalcmd); |
eval($evalcmd); |
101 |
if ($@) { |
if ($@) { |
102 |
$result->{$_} = 0; |
$result->{$_} = 'notok'; |
103 |
} else { |
} else { |
104 |
$result->{$_} = 1; |
$result->{$_} = 'ok'; |
105 |
} |
} |
106 |
} @modules; |
} @modules; |
107 |
return $result; |
return $result; |