Line # Revision Author
1 3 ahitrov@rambler.ru #!/usr/bin/perl
2
3 use strict;
4
5 my ($module, $version) = @ARGV;
6 $module =~ s/-/::/g;
7 my $installed;
8
9 unless ($module && $version) {
10 print "export PERL_CHECKED=cancel";
11 exit;
12 }
13
14 eval "require $module;";
15 if ($@) {
16 print "export PERL_CHECKED=install";
17 exit;
18 }
19
20
21 my @parts = split /\./, $module->VERSION();
22 $installed->{version} = join(".", $parts[0], join("", @parts[1 .. $#parts]) || ());
23 (my $path=$module) =~ s/::/\//g;
24 $installed->{path} = $INC{$path.".pm"};
25
26 if ($installed->{version} >= $version) {
27 unless ($ENV{DRY_RUN}||'' eq 'yes') {
28 print STDERR "##############################################################################\n";
29 print STDERR "# Found installed module: $module\n";
30 print STDERR "# Version: $installed->{version}\n";
31 print STDERR "# Location: $installed->{path}\n";
32 print STDERR "#\n";
33 print STDERR "# Skipped version: $version\n";
34 print STDERR "##############################################################################\n";
35 sleep 2;
36 }
37 print "export PERL_CHECKED=skip";
38 exit;
39 }
40
41 print STDERR "##############################################################################\n";
42 print STDERR "# Found installed module: $module\n";
43 print STDERR "# Version: $installed->{version}\n";
44 print STDERR "# Location: $installed->{path}\n";
45 print STDERR "#\n";
46 print STDERR "# Would you like continue to install version: $version ?\n";
47 print STDERR "##############################################################################\n";
48
49 my $a;
50 while (1) {
51 print STDERR "[I]nstall, [S]kip, [C]ancel ? ";
52 $a = lc(scalar(<STDIN>));
53 chomp $a;
54 last if $a eq 'i' || $a eq 's' || $a eq 'c';
55 }
56 print "export PERL_CHECKED=install" if $a eq 'i';
57 print "export PERL_CHECKED=skip" if $a eq 's';
58 print "export PERL_CHECKED=cancel" if $a eq 'c';