Merge branch 'master' of mathias-kettner.de:omd
[omd.git] / packages / perl-modules / orphaned_modules
blob84cf79ea777b0c90e7a4efe50535563615e7600d
1 #!/usr/bin/perl
3 use warnings;
4 use strict;
5 use Getopt::Long;
7 use lib 'lib';
8 use BuildHelper;
10 BEGIN {
11 for my $val (qw/PERL5LIB PERL_MB_OPT PERL_LOCAL_LIB_ROOT PERL_MM_OPT/) {
12 undef $ENV{$val} if defined $ENV{$val};
16 ####################################
17 my $verbose = 0;
18 GetOptions ('v|verbose' => \$verbose);
20 ####################################
21 my @packages = glob("../jmx4perl/jmx4perl-*.tar.gz ../thruk/Thruk-*.tar.gz ../check_webinject/Webinject-*.tar.gz");
22 my $more_modules = {
23 'App::cpanminus' => '0', # OMD
24 'CPAN' => '0', # OMD
25 'File::Copy::Recursive' => '0', # required by Thruks inc::Module::Install
26 'Module::Install' => '1.01', # OMD
27 'Monitoring::Plugin' => '0', # OMD
28 'Nagios::Plugin' => '0.35', # OMD
29 'HTML::Lint' => '2.06', # OMD tests
30 'Monitoring::Livestatus' => '0', # OMD
31 'Monitoring::Livestatus::Class' => '0.04', # OMD tests
32 'DBI' => '0', # check_oracle_health / check_mysql_health
33 'DBD::mysql' => '4.019', # check_mysql_health
34 'Gearman::Client' => '1.11', # pnp4nagios / gearman
35 'Crypt::Rijndael' => '1.09', # pnp4nagios / gearman
36 'Term::ReadLine::Gnu' => '1.20', # jmx4perl
39 ####################################
40 # get module dependencies
41 my($deps,$files) = BuildHelper::get_all_deps(1);
42 my $orphaned = BuildHelper::get_orphaned($deps, $files, $verbose);
44 ####################################
45 # remove referenced modules
46 for my $p (@packages) {
47 my $meta = BuildHelper::get_meta($p);
48 my $rem_deps = BuildHelper::get_deps_from_meta($meta, 1);
49 for my $rem_dep (keys %{$rem_deps}) {
50 my $rdep = BuildHelper::module_to_file($rem_dep, $files, $rem_deps->{$rem_dep});
51 my $cv = BuildHelper::is_core_module($rem_dep, 5.008);
52 if(!$rdep and !BuildHelper::version_compare($cv, $rem_deps->{$rem_dep}) and $rem_dep !~ m/^(Test|Devel)/mx) {
53 print "WARNING: ",$rem_dep, " does not resolve to a file\n";
54 } else {
55 delete $orphaned->{$rdep} if $rdep;
60 ####################################
61 for my $f (keys %{$files}) {
62 my($m,$v) = BuildHelper::file_to_module($files->{$f});
63 my $cv = BuildHelper::is_core_module($m, 5.008);
64 if($cv and BuildHelper::version_compare($cv, $v)) {
65 print "WARNING: ",$m, " is a core module (".$cv.") and ",$files->{$m}," should be removed\n";
69 # check other modules
70 for my $m (keys %{$more_modules}) {
71 if(BuildHelper::is_core_module($m, 5.008)) {
72 print "WARNING: ",$m, " is a core module and should be removed\n";
73 next;
75 my $mdep = BuildHelper::module_to_file($m, $files, $more_modules->{$m});
76 if(!defined $mdep) {
77 print "WARNING: ",$m, " does not resolve to a file\n";
78 } else {
79 delete $orphaned->{$mdep};
83 ####################################
84 # print result
85 for my $file (keys %{$orphaned}) {
86 my($m,$v) = BuildHelper::file_to_module($file);
87 if(!defined $more_modules->{$m}) {
88 print $file, " is orphaned and could probably removed\n";