This file is indexed.

/usr/share/perl5/Module/Extract.pm is in libmodule-extract-perl 0.01-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
package Module::Extract;

=pod

=head1 NAME

Module::Extract - Base class for working with Perl distributions

=head1 SYNOPSIS

Creating a Module::Extract subclass.

  package My::Readme;
  
  # Shows the README file for a module
  
  use strict;
  use base 'Module::Extract';
  
  sub show {
      my $self   = shift;
      my $readme = $self->file_path('README');
      if ( -f $readme ) {
          system( "cat $readme" );
      } else {
          print "Dist does not have a README file";
      }
  }
  
  1;

A script that uses the module to show the readme file for a distribution
filename provided by the user.

  #!/usr/bin/perl
  
  use My::Readme;
  
  My::Readme->new( dist_file => $ARGV[0] )->show;
  
  exit(0);

=head1 DESCRIPTION

B<Module::Extract> is a convenience base class for creating module that
work with Perl distributions.

Its purpose is to take care of the mechanisms of locating and extracting
a Perl distribution so that your module can do something specific to the
distribution.

This module was originally created to provide an abstraction for the
extraction logic for both L<Module::Inspector> and L<Module::P4P> and
to allow additional features to be added in the future without having
to modify both of them, because the general problem of "locate, download,
and expand a distribution" is one that is almost ideal for adding
additional features down the line.

=cut

use strict;
use Carp ();
use File::Path ();
use File::Temp ();

use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.01';
}

# Flag Archive::Extract for prefork'ing if needed
eval " use prefork 'Archive::Extract'; ";





#####################################################################
# Constructor and Accessors

=pod

=head2 new

  my $from_file = My::Class->new(
      dist_file => 'tarball.tar.gz',
      );
  
  my $from_dir = My::Class->new(
      dist_dir  => 'some/dir',
      );

The C<new> constructor takes a C<dist_file> and/or a C<dist_dir> param,
locates and (if needed) expands the distribution tarball.

It takes either a C<dist_file> param, which should be the local path
to the tarball, or a C<dist_dir> which should be the path to a directory
which contains an already-expanded distribution (such as from a
repository checkout).

Return a new B<Module::Extract>-subclass object, or dies on error.

=cut

sub new {
	my $class = shift;
	my $self  = bless { @_ }, $class;

	if ( $self->dist_file ) {
		# Create the inspector for a tarball
		unless ( $self->dist_file =~ /\.(?:zip|tgz|tar\.gz)$/ ) {
			Carp::croak("The dist_file '" . $self->dist_file . "' is not a zip|tgz|tar.gz");
		}
		unless ( -f $self->dist_file ) {
			Carp::croak("The dist_file '" . $self->dist_file . "' does not exist");
		}

		# Do we have a directory to unroll to
		if ( $self->dist_dir ) {
			# The directory should not exist
			if ( -d $self->dist_dir ) {
				Carp::croak("Cannot reuse an pre-existing dist_dir '"
					. $self->dist_dir
					. "'" );
			}

			# Create it
			File::Path::mkpath( $self->dist_dir );
		} else {
			# Find a temp directory
			$self->{dist_dir} = File::Temp::tempdir( CLEANUP => 1 );
		}

		# Double check it now exists and is writable
		unless ( -d $self->dist_dir and -w $self->dist_dir ) {
			Carp::croak("The dist_dir '" . $self->dist_dir . "' is not writeable");
		}

		# Unpack dist_file into dist_dir
		require Archive::Extract;
		my $archive = Archive::Extract->new( archive => $self->dist_file )
			or Carp::croak("Failed to extract dist_file '"
				. $self->dist_file . "'"
				);
		$self->{dist_type} = $archive->type;
		unless ( $archive->extract( to => $self->dist_dir ) ) {
			Carp::croak("Failed to extract dist_file '"
				. $self->dist_file . "'"
				);
		}

		# Double check the expansion directory
		if ( $archive->extract_path ne $self->dist_dir ) {
			# Archive::Extract can extract to a single
			# directory beneath the target, in which case
			# we actually want to be using that as our dist_dir.
			$self->{dist_dir} = $archive->extract_path;
		}

	} elsif ( $self->dist_dir ) {
		# Create the inspector for a directory
		unless ( -d $self->dist_dir ) {
			Carp::croak("Missing or invalid module root $self->{dist_dir}");
		}

	} else {
		# Missing a module location
		Carp::croak("Did not provide a dist_file or dist_dir param");
	}

	$self;
}

=pod

=head2 dist_file

The C<dist_file> accessor returns the (absolute) path to the
distribution tarball. If the inspector was created with C<dist_dir>
rather than C<dist_file>, this will return C<undef>.

=cut

sub dist_file {
	$_[0]->{dist_file};
}

=pod

=head2 dist_type

The C<dist_type> method returns the archive type of the
distribution tarball. This will be either 'tar.gz', 'tgz', or
'zip'. Other file types are not supported at this time.

If the inspector was created with C<dist_dir> rather than 
C<dist_file>, this will return C<undef>.

=cut

sub dist_type {
	$_[0]->{dist_type};
}

=pod

=head2 dist_dir

The C<dist_dir> method returns the (absolute) distribution root directory.

If the inspector was created with C<dist_file> rather than C<dist_file>,
this method will return the temporary directory created to hold the
unwrapped tarball.

=cut

sub dist_dir {
	$_[0]->{dist_dir};
}

=pod

=head2 file_path

  my $local_path = $inspector->file_path('lib/Foo.pm');

To simplify implementations, most tools that work with distributions
identify files in unix-style relative paths.

The C<file_path> method takes a unix-style relative path and returns
a localised absolute path to the file on disk (either in the actual
distribution directory, or the temp directory holding the expanded
tarball.

=cut

sub file_path {
	File::Spec->catfile( $_[0]->dist_dir, $_[1] );
}

=pod

=head2 dir_path

  my $local_path = $inspector->file_path('lib');

The C<dir_path> method is the matching pair of the C<file_path> method.

As for that method, it takes a unix-style relative directory name,
and returns a localised absolute path to the directory.

=cut

sub dir_path {
	File::Spec->catdir( $_[0]->dist_dir, $_[1] );
}

1;

=pod

=head1 SUPPORT

This module is stored in an Open Repository at the following address.

L<http://svn.phase-n.com/svn/cpan/trunk/Module-Extract>

Write access to the repository is made available automatically to any
published CPAN author, and to most other volunteers on request.

If you are able to submit your bug report in the form of new (failing)
unit tests, or can apply your fix directly instead of submitting a patch,
you are B<strongly> encouraged to do so as the author currently maintains
over 100 modules and it can take some time to deal with non-Critcal bug
reports or patches.

This will guarentee that your issue will be addressed in the next
release of the module.

If you cannot provide a direct test or fix, or don't have time to do so,
then regular bug reports are still accepted and appreciated via the CPAN
bug tracker.

L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Extract>

For other issues, for commercial enhancement or support, or to have your
write access enabled for the repository, contact the author at the email
address above.

=head1 AUTHORS

Adam Kennedy E<lt>adamk@cpan.orgE<gt>

=head1 SEE ALSO

L<Module::Inspector>, L<Module::P4P>

=head1 COPYRIGHT

Copyright 2006 Adam Kennedy.

This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the
LICENSE file included with this module.

=cut