1 |
760 |
ahitrov |
#!/usr/bin/env perl |
2 |
8 |
ahitrov@rambler.ru |
|
3 |
|
|
use strict; |
4 |
|
|
|
5 |
657 |
ahitrov |
my ($module, $version, $mode) = @ARGV; |
6 |
8 |
ahitrov@rambler.ru |
$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 |
657 |
ahitrov |
if ($installed->{version} >= $version || $mode eq 'pass') { |
27 |
8 |
ahitrov@rambler.ru |
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'; |