Skip to content

Commit b232f21

Browse files
committed
Add and use MANIFEST.SKIP file for Porting files
This change is merging the two ideas from #19523 and #19513 by relying on a traditional MANIFEST.SKIP file. Case #19523 simplifies the way we can easily exclude common noise Case #19513 provides a mechanism to avoid shipping not necessary files as part of the tarball This is adding a new 'Porting/Manifest.pm' file which provides helpers to list files from MANIFEST taking into account the 'MANIFEST.SKIP' using ExtUtils::Manifest.
1 parent 9d972c6 commit b232f21

19 files changed

+212
-189
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ lib/unicore/mktables.lst
139139
# generated by WinCE build
140140
xlib/
141141

142+
/stuff
143+
142144
# test byproducts
143145
t/rantests
144146
t/tmp*
@@ -150,6 +152,8 @@ t/test_state
150152
t/*.ph
151153
t/lib/*.ph
152154

155+
/rel2abs2rel*.pl
156+
153157
# t/op/require.t byproducts
154158
t/bleah.pm
155159
t/bleah.do

MANIFEST

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5103,7 +5103,6 @@ Makefile.SH A script that generates Makefile
51035103
malloc.c A version of malloc you might not want
51045104
malloc_ctl.h A version of malloc you might not want
51055105
MANIFEST This list of files
5106-
MANIFEST.SKIP Patterns for files not included in this file
51075106
mathoms.c A home for binary-compatible code artifacts
51085107
META.json Distribution meta-data in JSON
51095108
META.yml Distribution meta-data in YAML

MANIFEST.SKIP

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
^MANIFEST\.SKIP
2+
13
\.mailmap
24
\.gitignore
35
\.gitattributes
@@ -7,12 +9,13 @@
79
\.travis\.yml
810

911
# Porting tools
10-
Porting/bisect.pl
1112
Porting/bisect-example.sh
1213
Porting/bisect-runner.pl
14+
Porting/bisect.pl
1315
Porting/checkAUTHORS.pl
1416
Porting/git-deltatool
1517
Porting/git-find-p4-change
1618
Porting/git-make-p4-refs
1719
Porting/GitUtils.pm
20+
Porting/Manifest.pm
1821
Porting/updateAUTHORS.pl

Porting/Maintainers.pm

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,20 @@ require Exporter;
2828
use File::Find;
2929
use Getopt::Long;
3030

31+
use Manifest; # aka 'use Porting::Manifest' - note: Porting is in lib
32+
3133
my %MANIFEST;
3234

3335
# (re)read the MANIFEST file, blowing away any previous effort
3436

3537
sub reload_manifest {
36-
%MANIFEST = ();
37-
38-
foreach my $manifest_path ('MANIFEST','Porting/MANIFEST.dev') {
39-
if (! -e $manifest_path) {
40-
$manifest_path = "../MANIFEST";
41-
}
42-
43-
if (open(my $manfh, '<', $manifest_path )) {
44-
while (<$manfh>) {
45-
if (/^(\S+)/) {
46-
$MANIFEST{$1}++;
47-
}
48-
else {
49-
warn "MANIFEST:$.: malformed line: $_\n";
50-
}
51-
}
52-
close $manfh;
53-
} else {
54-
die "$0: Failed to open MANIFEST for reading: $!\n";
55-
}
56-
}
38+
39+
%MANIFEST = ( map { $_ => 1 } Porting::Manifest::get_files_from_all_manifests( 1 ) );
40+
41+
return;
5742
}
5843

59-
reload_manifest;
44+
reload_manifest();
6045

6146

6247
sub get_module_pat {

Porting/Manifest.pm

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!perl
2+
3+
package Porting::Manifest;
4+
5+
use strict;
6+
use warnings;
7+
8+
use v5.34;
9+
10+
##
11+
## list of all files from MANIFEST and ignored by MANIFEST.SKIP
12+
##
13+
14+
sub get_files_from_all_manifests {
15+
16+
my ($reload) = @_;
17+
18+
state @list;
19+
20+
@list = () if $reload;
21+
22+
return @list if scalar @list;
23+
24+
require ExtUtils::Manifest;
25+
require Cwd;
26+
27+
local $ExtUtils::Manifest::Quiet = $ExtUtils::Manifest::Quiet = 1; # no warnings 'once'
28+
29+
my @from_manifest;
30+
my @from_manifest_skip;
31+
32+
my $skip;
33+
34+
my $cwd = Cwd::getcwd();
35+
my @ls_files;
36+
my $ls_status;
37+
{
38+
my $root_pwd = Cwd::abs_path( $INC{"strict.pm"} );
39+
40+
#my $strict_path = $INC{"strict.pm"};
41+
$root_pwd =~ s{/*\Qlib/strict.pm\E$}{};
42+
chdir($root_pwd);
43+
44+
# read the manifest files
45+
@from_manifest = keys %{ ExtUtils::Manifest::maniread("MANIFEST") };
46+
$skip = ExtUtils::Manifest::maniskip("MANIFEST.SKIP");
47+
48+
@ls_files = `git ls-files --full-name`;
49+
$ls_status = $?
50+
}
51+
chdir($cwd);
52+
die q[Fail to run git ls-files] if $ls_status;
53+
54+
chomp(@ls_files);
55+
56+
foreach my $f (@ls_files) {
57+
next unless $skip->($f);
58+
push @from_manifest_skip, $f;
59+
}
60+
61+
my %uniq = map { $_ => 1 } @from_manifest, @from_manifest_skip;
62+
63+
return ( @list = sort keys %uniq );
64+
}
65+
66+
##
67+
## list of Porting files listed in MANIFEST or ignored by MANIFEST.SKIP
68+
##
69+
70+
sub get_porting_files {
71+
72+
return grep { $_ =~ qr{^Porting} && $_ !~ qr{\.(?:gitignore$|github|gitattributes|mailmap|travis)} } get_files_from_all_manifests();
73+
}
74+
75+
sub get_porting_perl_files {
76+
return grep { $_ !~ qr{\.sh} } get_porting_files();
77+
}
78+
79+
1;

Porting/README.pod

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ file is normally updated each time F<Configure> is updated.
106106

107107
=head2 F<core-cpan-diff>
108108

109-
Compare CPAN modules with their equivalent in core.
109+
Compare CPAN modules with their equivalent in core.
110110
Originally based on App::DualLivedDiff by Steffen Mueller.
111111

112112
=head2 F<corecpan.pl>
@@ -188,15 +188,15 @@ digits which acts the internal unique identifier for this commit
188188
=head2 F<Glossary>
189189

190190
This file is built by F<metaconfig>. This file contains a description of all
191-
the shell variables whose value is determined by the Configure script.
191+
the shell variables whose value is determined by the Configure script.
192192
It later gets incorporated into the pod for F<Config.pm>.
193193

194194
=head2 F<harness-timer-report.pl>
195195

196196
For analyzing the output of "env HARNESS_TIMER=1 make test", to find
197197
outliers of test execution times.
198198

199-
=head2 F<how_to_write_a_perldelta.pod>
199+
=head2 F<how_to_write_a_perldelta.pod>
200200

201201
This file contains a specification as to how to write a perldelta pod.
202202
Related file: F<perldelta_template.pod>
@@ -244,25 +244,17 @@ This script creates a release checklist as a simple HTML document.
244244
=head2 F<make_snapshot.pl>
245245

246246
This script is a quick and dirty snapshot generator for the perl5.git.perl.org
247-
web page to use to generate the snapshot files.
247+
web page to use to generate the snapshot files.
248248

249249
=head2 F<manicheck>
250250

251-
This script outputs a list of files in F<MANIFEST> and F<MANIFEST.dev>
252-
which don't exist and a list of files that exist and aren't in
253-
F<MANIFEST> or in F<MANIFEST.dev>
254-
255-
=head2 F<MANIFEST.dev>
256-
257-
This file lists all files that are not included in the F<MANIFEST>
258-
file in the root of the repo. The union of the files it contains with
259-
the files in C<MANIFEST> should be the same the list of file produced
260-
by C<git ls-files> from a git checkout.
251+
This script outputs a list of files in F<MANIFEST> which don't exist
252+
and a list of files that exist and aren't skipped by F<MANIFEST.SKIP>.
261253

262254
=head2 F<manifest_lib.pl>
263255

264256
This library provides functions used in checking and sorting the
265-
F<MANIFEST> and F<MANIFEST.dev> files. The sort order is similar to
257+
F<MANIFEST> files. The sort order is similar to
266258
dictionary sort order (alphabetical case insensitive) but where path
267259
components and extensions are sorted independently such that the
268260
following files would be sorted into the following order:
@@ -276,9 +268,18 @@ following files would be sorted into the following order:
276268

277269
Currently this code does not support EBCDIC. Patches welcome.
278270

271+
=head2 F<Manifest.pm>
272+
273+
A package which provides helper to list files from F<MANIFEST>
274+
taking into account F<MANIFEST.SKIP>.
275+
276+
=head2 F<MANIFEST.SKIP>
277+
278+
List files that we do not want to ship and are versionned in git.
279+
279280
=head2 F<manisort>
280281

281-
This script sorts the files in F<MANIFEST> or F<MANIFEST.dev>. It uses
282+
This script sorts the files in F<MANIFEST>. It uses
282283
F<manifest_list.pl> to do the sorting. Use C<Porting/manisort --man>
283284
to see instructions for use.
284285

@@ -337,7 +338,7 @@ Applies F<podtidy> to a file.
337338
=head2 F<pumpkin.pod>
338339

339340
Pumpkin - Notes on handling the Perl Patch Pumpkin And Porting Perl.
340-
Many of these are out of date or superseded by other documents in
341+
Many of these are out of date or superseded by other documents in
341342
this directory.
342343

343344
=head2 F<README.pod>

Porting/checkcfguse.pl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use strict;
1212
use warnings;
1313

14+
use lib '.';
15+
use Porting::Manifest;
16+
1417
my %SYM;
1518

1619
my @PAT =
@@ -70,32 +73,29 @@
7073
my $SYM = join("|", sort { length($b) <=> length($a) || $a cmp $b } keys %SYM);
7174

7275
my %found;
73-
foreach my $manifest_file ('MANIFEST', 'Porting/MANIFEST.dev') {
74-
open(my $mani, '<', $manifest_file)
75-
or die "$0: Failed to open '$manifest_file'\n";
7676

77-
while (<$mani>) {
78-
if (/^(\S+)\s+/) {
79-
my $fn = $1;
80-
# Skip matches from the config files themselves,
81-
# from metaconfig generated files that refer to
82-
# the config symbols, and from pods.
83-
next if $fn =~ m{^(?:config_h\.SH
84-
|Configure
85-
|configure\.com
86-
|Porting/(?:config|Glossary)
87-
|(?:plan9|win32)/(?:config|(?:GNU)?[Mm]akefile)
88-
|uconfig)
89-
|\.pod$}x;
90-
open my $fh, '<', $fn or die qq[$0: Failed to open $fn: $!];
91-
while (<$fh>) {
92-
while (/\b($SYM)\b/go) {
93-
$found{$1}{$fn}++;
94-
}
95-
}
77+
my @manifest_files = Porting::Manifest::get_files_from_all_manifests();
78+
79+
for (@manifest_files) {
80+
my $fn = $1;
81+
# Skip matches from the config files themselves,
82+
# from metaconfig generated files that refer to
83+
# the config symbols, and from pods.
84+
next if $fn =~ m{^(?:config_h\.SH
85+
|Configure
86+
|configure\.com
87+
|Porting/(?:config|Glossary)
88+
|(?:plan9|win32)/(?:config|(?:GNU)?[Mm]akefile)
89+
|uconfig)
90+
|\.pod$}x;
91+
open my $fh, '<', $fn or die qq[$0: Failed to open $fn: $!];
92+
while (<$fh>) {
93+
while (/\b($SYM)\b/go) {
94+
$found{$1}{$fn}++;
9695
}
9796
}
9897
}
98+
9999
for my $sym (sort keys %SYM) {
100100
if (exists $found{$sym}) {
101101
my @found = keys %{$found{$sym}};

Porting/manicheck

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use v5.14;
1111
use warnings;
1212
use File::Find;
1313
use Getopt::Long;
14-
use ExtUtils::Manifest 'maniskip';
14+
use ExtUtils::Manifest qw{ maniread maniskip };
1515
use constant MAX_EXIT_CODE => 124;
1616

1717
my $exitstatus;
@@ -22,51 +22,41 @@ my $bonus = 0;
2222
my $skip = maniskip;
2323

2424
sub read_manifest {
25-
my ($manifest_file) = @_;
26-
open my $fh, '<', $manifest_file
27-
or die "Can't read '$manifest_file': $!\n";
25+
my @from_manifest = sort keys %{ maniread("MANIFEST") };
26+
2827
my %files;
2928
my $missing = 0;
30-
for my $line (<$fh>) {
31-
my ($file) = $line =~ /^(\S+)/;
32-
if (!defined($file)) {
33-
warn "No file specified in '$manifest_file' line $.\n";
34-
next;
35-
}
36-
$files{$file} = $.;
29+
foreach my $file (@from_manifest) {
30+
$files{$file} = 1;
3731
next if -f $file;
3832
$missing++;
39-
print "'$file' from '$manifest_file' at line $. doesn't exist\n";
33+
print "'$file' from 'MANIFEST' doesn't exist\n";
4034
}
41-
close $fh or die "Failed to close '$manifest_file': $!\n";
35+
4236
return (\%files, $missing);
4337
}
4438

4539
my ($manifest_files, $manifest_missing) = read_manifest("MANIFEST");
46-
my ($porting_files, $porting_missing) = read_manifest("Porting/MANIFEST.dev");
40+
41+
my @ls_files = `git ls-files --full-name`;
42+
my %git_files = map { $_ => 1 } @ls_files;
4743

4844
find {
4945
no_chdir => 1,
5046
wanted => sub {
5147
return if -d;
5248
my $path = $File::Find::name =~ s!^\./!!r;
5349
return if $skip->($path);
54-
return if $files{$path};
55-
56-
# return if -d $_;
57-
# my $file = $_;
58-
# $file =~s!^\./!!;
59-
# return if $file=~m!^\.git/!;
60-
# return if $porting_files->{$file};
61-
# return if $manifest_files->{$file};
50+
return if $manifest_files->{$path};
51+
return unless $git_files{$path};
6252

6353
++$bonus;
64-
print "$path\t\tnot in MANIFEST\n";
54+
print "'$path'\t\tnot in MANIFEST or not skipped by MANIFEST.SKIP\n";
6555

6656
},
6757
}, ".";
6858

69-
my $problems = $manifest_missing + $porting_missing + $bonus;
59+
my $problems = $manifest_missing + $bonus;
7060

7161
# We can't (meaningfully) exit with codes above 255, so we're going to have to
7262
# clamp them to some range whatever we do. So as we need the code anyway, use

0 commit comments

Comments
 (0)