source: MondoRescue/branches/3.2/mindi/mindi-get-perl-modules@ 3462

Last change on this file since 3462 was 3462, checked in by Bruno Cornec, 9 years ago
  • Fix mindi-get-perl-modules, non working on Debian 8 and probably other distribs by removing completely old code remaining, and avoiding mixing up with @INC. Simpler and now working on Debian 8 as well as Mageia 5
  • Property svn:executable set to *
File size: 2.7 KB
RevLine 
[2183]1#!/usr/bin/perl -w
2#
[3143]3# $Id$
4# Copyright B. Cornec 2005-2013
5# Provided under the GPL v2
6#
[2183]7# Get perl modules required by mindi and mondo and that should be on the restore media
8#
9use strict;
10
[3223]11use MondoRescue::File;
[3385]12use Data::Dumper;
13use File::Basename;
[3386]14use ProjectBuilder::Base;
15use Getopt::Long qw(:config auto_abbrev no_ignore_case);
[3388]16use Module::ScanDeps;
[2183]17
[3143]18=pod
19
20=head1 NAME
21
22mindi-get-perl-modules keeps track of the perl modules that should be on your restore media
23
24=head1 DESCRIPTION
25
26mindi-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.
27
28=head1 SYNOPSIS
29
30mindi-get-perl-modules /path/to/perl-script ...
31
32=head1 ARGUMENTS
33
34=over 4
35
36=item B</path/to/perl-script>
37
38This is the path of the perl script to analyze and for which we want its perl modules in dependence to be included
39
40=back
41
42=head1 WEB SITES
43
44The main Web site of the project is available at L<http://www.mondorescue.org>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>.
45
46=head1 USER MAILING LIST
47
48For community exchanges around MondoRescue please use the list L<http://sourceforge.net/mailarchive/forum.php?forum_name=mondo-devel>
49
50=head1 AUTHORS
51
52The MondoRescue team lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
53
54=head1 COPYRIGHT
55
56MondoRescue is distributed under the GPL v2.0 license or later,
57described in the file C<COPYING> included with the distribution.
58
59=cut
60
[3386]61# Globals
[3385]62my %files;
63my %found;
[3386]64my %opts;
65my @includes;
66my $req;
67GetOptions(
68 "verbose|v+" => \$opts{'v'},
69);
[2183]70
[3386]71pb_syntax_init("mindi-get-perl-modules Version PBVER-rPBREV\n");
72
73$pbdebug = $opts{'v'};
74$pbdebug = 0 if (not defined $pbdebug);
75
[3388]76if (not defined $ARGV[0]) {
[3386]77 pb_syntax();
78}
79
80pb_temp_init();
81
[3462]82# Adds missing modules not found automatically in certain cases
83#
84my $tmpf = "$ENV{'PBTMP'}/mgpm.$$.pl";
[3386]85
86open(TMPF,"> $tmpf") || die "Unable to create $tmpf: !$\n";
87print TMPF "# To include module corresponding to perl -w\n";
88print TMPF "use warnings;\n";
89print TMPF "# To include module used by Data:Dumper in a masked way for this script\n";
90print TMPF "use bytes;\n";
[3389]91print TMPF "# To prevent a bug with perl 5.10.0\n";
[3390]92print TMPF "use Tie::Hash::NamedCapture;\n";
93print TMPF "# To prevent a bug somewhere with scan_deps :-(\n";
94print TMPF "use lib;\n";
[3386]95close(TMPF);
96
[3388]97push @ARGV,$tmpf;
98
99my $h = scan_deps(
100 files => \@ARGV,
101 recurse => 1,
102 );
103
[3386]104unlink("$tmpf");
105
[3388]106pb_log(1,"Returning:");
107pb_log(1,Dumper($h));
108pb_log(1,"-----------------------\n");
109foreach my $f (sort keys %$h) {
[3389]110 # Skip the temp file
111 next if ($h->{$f}->{'file'} =~ /$ENV{'PBTMP'}/);
[3388]112 print "$h->{$f}->{'file'}\n";
[2183]113}
114
[3383]115exit 0;
Note: See TracBrowser for help on using the repository browser.