$Is_MacOS $Is_VMS
$Debug $Verbose $Quiet $MANIFEST $DEFAULT_MSKIP);
-$VERSION = '1.49';
+$VERSION = '1.51';
@ISA=('Exporter');
@EXPORT_OK = qw(mkmanifest
manicheck filecheck fullcheck skipcheck
my $read = {};
local *M;
unless (open M, $mfile){
- warn "$mfile: $!";
+ warn "Problem opening $mfile: $!";
return $read;
}
local $_;
sub _maniskip {
my @skip ;
my $mfile = "$MANIFEST.SKIP";
- local(*M,$_);
+ _check_mskip_directives($mfile) if -f $mfile;
+ local(*M, $_);
open M, $mfile or open M, $DEFAULT_MSKIP or return sub {0};
while (<M>){
chomp;
return sub { $_[0] =~ qr{$opts$regex} };
}
+# checks for the special directives
+# #!include_default
+# #!include /path/to/some/manifest.skip
+# in a custom MANIFEST.SKIP for, for including
+# the content of, respectively, the default MANIFEST.SKIP
+# and an external manifest.skip file
+sub _check_mskip_directives {
+ my $mfile = shift;
+ local (*M, $_);
+ my @lines = ();
+ my $flag = 0;
+ unless (open M, $mfile) {
+ warn "Problem opening $mfile: $!";
+ return;
+ }
+ while (<M>) {
+ if (/^#!include_default\s*$/) {
+ if (my @default = _include_mskip_file()) {
+ push @lines, @default;
+ warn "Debug: Including default MANIFEST.SKIP\n" if $Debug;
+ $flag++;
+ }
+ next;
+ }
+ if (/^#!include\s+(.*)\s*$/) {
+ my $external_file = $1;
+ if (my @external = _include_mskip_file($external_file)) {
+ push @lines, @external;
+ warn "Debug: Including external $external_file\n" if $Debug;
+ $flag++;
+ }
+ next;
+ }
+ push @lines, $_;
+ }
+ close M;
+ return unless $flag;
+ rename $mfile, "$mfile.bak";
+ warn "Debug: Saving original $mfile as $mfile.bak\n" if $Debug;
+ unless (open M, ">$mfile") {
+ warn "Problem opening $mfile: $!";
+ return;
+ }
+ print M $_ for (@lines);
+ close M;
+ return;
+}
+
+# returns an array containing the lines of an external
+# manifest.skip file, if given, or $DEFAULT_MSKIP
+sub _include_mskip_file {
+ my $mskip = shift || $DEFAULT_MSKIP;
+ unless (-f $mskip) {
+ warn qq{Included file "$mskip" not found - skipping};
+ return;
+ }
+ local (*M, $_);
+ unless (open M, $mskip) {
+ warn "Problem opening $mskip: $!";
+ return;
+ }
+ my @lines = ();
+ push @lines, "\n#!start included $mskip\n";
+ push @lines, $_ while <M>;
+ close M;
+ push @lines, "#!end included $mskip\n\n";
+ return @lines;
+}
+
=item manicopy
manicopy(\%src, $dest_dir);
copy($srcFile,$dstFile);
utime $access, $mod + ($Is_VMS ? 1 : 0), $dstFile;
- _manicopy_chmod($dstFile);
+ _manicopy_chmod($srcFile, $dstFile);
}
return &cp if $Is_VMS or ($^O eq 'MSWin32' and Win32::IsWin95());
link($srcFile, $dstFile);
- unless( _manicopy_chmod($dstFile) ) {
+ unless( _manicopy_chmod($srcFile, $dstFile) ) {
unlink $dstFile;
return;
}
# 2) Let everyone read it.
# 3) If the owner can execute it, everyone can.
sub _manicopy_chmod {
- my($file) = shift;
+ my($srcFile, $dstFile) = @_;
- my $perm = 0444 | (stat $file)[2] & 0700;
- chmod( $perm | ( $perm & 0100 ? 0111 : 0 ), $file );
+ my $perm = 0444 | (stat $srcFile)[2] & 0700;
+ chmod( $perm | ( $perm & 0100 ? 0111 : 0 ), $dstFile );
}
# Files that are often modified in the distdir. Don't hard link them.
used, similar to the example above. If you want nothing skipped,
simply make an empty MANIFEST.SKIP file.
+In one's own MANIFEST.SKIP file, certain directives
+can be used to include the contents of other MANIFEST.SKIP
+files. At present two such directives are recognized.
+
+=over 4
+
+=item #!include_default
+
+This inserts the contents of the default MANIFEST.SKIP file
+
+=item #!include /Path/to/another/manifest.skip
+
+This inserts the contents of the specified external file
+
+=back
+
+The included contents will be inserted into the MANIFEST.SKIP
+file in between I<#!start included /path/to/manifest.skip>
+and I<#!end included /path/to/manifest.skip> markers.
+The original MANIFEST.SKIP is saved as MANIFEST.SKIP.bak.
=head2 EXPORT_OK
use strict;
-use Test::More tests => 49;
+use Test::More tests => 66;
use Cwd;
use File::Spec;
use File::Path;
use File::Find;
+use Config;
my $Is_VMS = $^O eq 'VMS';
ok( chdir( 'mantest' ), 'chdir() to mantest' );
ok( add_file('foo'), 'add a temporary file' );
+# This ensures the -x check for manicopy means something
+# Some platforms don't have chmod or an executable bit, in which case
+# this call will do nothing or fail, but on the platforms where chmod()
+# works, we test the executable bit is copied
+chmod( 0744, 'foo') if $Config{'chmod'};
+
# there shouldn't be a MANIFEST there
my ($res, $warn) = catch_warning( \&mkmanifest );
# Canonize the order.
is( $files->{yarrow}, 'hock',' with comment' );
is( $files->{foobar}, '', ' preserved old entries' );
+# test including an external manifest.skip file in MANIFEST.SKIP
+{
+ maniadd({ foo => undef , albatross => undef,
+ 'mymanifest.skip' => undef, 'mydefault.skip' => undef});
+ add_file('mymanifest.skip' => "^foo\n");
+ add_file('mydefault.skip' => "^my\n");
+ $ExtUtils::Manifest::DEFAULT_MSKIP =
+ File::Spec->catfile($cwd, qw(mantest mydefault.skip));
+ my $skip = File::Spec->catfile($cwd, qw(mantest mymanifest.skip));
+ add_file('MANIFEST.SKIP' =>
+ "albatross\n#!include $skip\n#!include_default");
+ my ($res, $warn) = catch_warning( \&skipcheck );
+ for (qw(albatross foo foobar mymanifest.skip mydefault.skip)) {
+ like( $warn, qr/Skipping \b$_\b/,
+ "Skipping $_" );
+ }
+ ($res, $warn) = catch_warning( \&mkmanifest );
+ for (qw(albatross foo foobar mymanifest.skip mydefault.skip)) {
+ like( $warn, qr/Removed from MANIFEST: \b$_\b/,
+ "Removed $_ from MANIFEST" );
+ }
+ my $files = maniread;
+ ok( ! exists $files->{albatross}, 'albatross excluded via MANIFEST.SKIP' );
+ ok( exists $files->{yarrow}, 'yarrow included in MANIFEST' );
+ ok( exists $files->{bar}, 'bar included in MANIFEST' );
+ ok( ! exists $files->{foobar}, 'foobar excluded via mymanifest.skip' );
+ ok( ! exists $files->{foo}, 'foo excluded via mymanifest.skip' );
+ ok( ! exists $files->{'mymanifest.skip'},
+ 'mymanifest.skip excluded via mydefault.skip' );
+ ok( ! exists $files->{'mydefault.skip'},
+ 'mydefault.skip excluded via mydefault.skip' );
+ $Files{"$_.bak"}++ for (qw(MANIFEST MANIFEST.SKIP));
+}
+
add_file('MANIFEST' => 'Makefile.PL');
maniadd({ foo => 'bar' });
$files = maniread;
);
is_deeply( $files, \%expect, 'maniadd() vs MANIFEST without trailing newline');
-add_file('MANIFEST' => 'Makefile.PL');
-maniadd({ foo => 'bar' });
+#add_file('MANIFEST' => 'Makefile.PL');
+#maniadd({ foo => 'bar' });
SKIP: {
chmod( 0400, 'MANIFEST' );