#!/usr/bin/perl -w # # $Id$ # Copyright B. Cornec 2005-2013 # Provided under the GPL v2 # # Get perl modules required by mindi and mondo and that should be on the restore media # use strict; use MondoRescue::File; use Data::Dumper; use File::Basename; use ProjectBuilder::Base; use Getopt::Long qw(:config auto_abbrev no_ignore_case); use Module::ScanDeps; =pod =head1 NAME mindi-get-perl-modules keeps track of the perl modules that should be on your restore media =head1 DESCRIPTION mindi-get-perl-modules keeps track of the perl modules that should be on your restore media by analyzing the references made to them in the scripts passed as parameters and returning all the modules needed to have them work correctly. =head1 SYNOPSIS mindi-get-perl-modules /path/to/perl-script ... =head1 ARGUMENTS =over 4 =item B This is the path of the perl script to analyze and for which we want its perl modules in dependence to be included =back =head1 WEB SITES The main Web site of the project is available at L. Bug reports should be filled using the trac instance of the project at L. =head1 USER MAILING LIST For community exchanges around MondoRescue please use the list L =head1 AUTHORS The MondoRescue team lead by Bruno Cornec L. =head1 COPYRIGHT MondoRescue is distributed under the GPL v2.0 license or later, described in the file C included with the distribution. =cut # Globals my %files; my %found; my %opts; my @includes; my $req; GetOptions( "verbose|v+" => \$opts{'v'}, ); pb_syntax_init("mindi-get-perl-modules Version PBVER-rPBREV\n"); $pbdebug = $opts{'v'}; $pbdebug = 0 if (not defined $pbdebug); if (not defined $ARGV[0]) { pb_syntax(); } pb_temp_init(); # Adds missing modules not found automatically in certain cases # my $tmpf = "$ENV{'PBTMP'}/mgpm.$$.pl"; open(TMPF,"> $tmpf") || die "Unable to create $tmpf: !$\n"; print TMPF "# To include module corresponding to perl -w\n"; print TMPF "use warnings;\n"; print TMPF "# To include module used by Data:Dumper in a masked way for this script\n"; print TMPF "use bytes;\n"; print TMPF "# To prevent a bug with perl 5.10.0\n"; print TMPF "use Tie::Hash::NamedCapture;\n"; print TMPF "# To prevent a bug somewhere with scan_deps :-(\n"; print TMPF "use lib;\n"; close(TMPF); push @ARGV,$tmpf; my $h = scan_deps( files => \@ARGV, recurse => 1, ); unlink("$tmpf"); pb_log(1,"Returning:"); pb_log(1,Dumper($h)); pb_log(1,"-----------------------\n"); foreach my $f (sort keys %$h) { # Skip the temp file next if ($h->{$f}->{'file'} =~ /$ENV{'PBTMP'}/); print "$h->{$f}->{'file'}\n"; } exit 0;