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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sun Dec 15 02:03:58 2002 UTC (21 years, 4 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +34 -40 lines
+ using Tie::IxHash to keep the order of modules (passed in via an array)

1 #################################
2 #
3 # $Id: libsetup.pm,v 1.3 2002/12/01 22:12:25 joko Exp $
4 #
5 # $Log: libsetup.pm,v $
6 # Revision 1.3 2002/12/01 22:12:25 joko
7 # + changed status-flags: 0 => 'notok' 1 => 'ok'
8 #
9 # Revision 1.2 2002/10/25 11:38:50 joko
10 # + sub checkCommonDeps
11 # + sub checkDeps_orig
12 # + refactored sub checkDeps
13 #
14 # Revision 1.1 2002/07/27 00:28:36 cvsjoko
15 # + new
16 #
17 #
18 #
19 #################################
20
21
22 package libsetup;
23
24 use strict;
25 use warnings;
26
27 use Tie::IxHash;
28
29 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
38
39 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 print "\n";
56
57 #my $obj = CPAN::Shell->expand('Module',$module);
58 #$obj->install;
59 }
60 }
61
62
63 sub checkCommonDeps {
64 checkDeps_orig(\@modules);
65 }
66
67 sub checkDeps_orig {
68 my $modules = shift;
69 my @modules = @{$modules};
70 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 sub checkDeps {
91 my $modules = shift;
92 my @modules = @{$modules};
93 my $result;
94 tie %$result, 'Tie::IxHash';
95 map {
96 my $evalcmd = "use $_;";
97 eval($evalcmd);
98 if ($@) {
99 $result->{$_} = 'notok';
100 } else {
101 $result->{$_} = 'ok';
102 }
103 } @modules;
104 return $result;
105 }
106
107 1;

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