Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item13844: MANIFEST fixes for 1.1.10
- Loading branch information
Showing
3 changed files
with
174 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,164 @@ | ||
#! /usr/bin/perl | ||
#! /usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
# cruise back up the tree until we find lib and data subdirs | ||
require Cwd; | ||
use Cwd; | ||
use File::Spec; | ||
use File::Find; | ||
|
||
my $manifest = 'MANIFEST'; | ||
my $manifest = shift || 'MANIFEST'; | ||
my @skip = | ||
qw(tools/develop tools/githooks tools/pkg tools/benchmark tools/distro test working logs MANIFEST DEPENDENCIES build\.pl PREINSTALL TIDY .*?\.psd .*?\.xcf \.gitignore); | ||
my $cvs = 'subversion'; | ||
my $skipPattern = join( '|', @skip ); | ||
|
||
#unless (-f $manifest) { | ||
# File::Find::find( sub { /^MANIFEST\z/ && ( $manifest = $File::Find::name ) | ||
# }, "$root/lib/TWiki" ); | ||
#} | ||
die "No such MANIFEST $manifest" unless -e $manifest; | ||
#print "SKIPPING $skipPattern\n"; | ||
my @lost; # Files on disk not in MANIFEST | ||
my %man; # Hash of MANIFEST content: file => perm | ||
my %alt; # Hash of alternate version of _src file | ||
my $checkperm = 0; | ||
my @manfiles; | ||
|
||
my %man; | ||
# Search the current working directory and its parents | ||
# for a directory called like the first parameter | ||
sub findPathToDir { | ||
my $lookForDir = shift; | ||
|
||
open MAN, '<', $manifest or die "Can't open $manifest for reading: $!"; | ||
while (<MAN>) { | ||
next if /^!include/; | ||
$man{$1} = 1 if /^(\S+)\s+\d+.*$/; | ||
my @dirlist = File::Spec->splitdir( Cwd::getcwd() ); | ||
do { | ||
my $dir = File::Spec->catdir( @dirlist, $lookForDir ); | ||
return File::Spec->catdir(@dirlist) if -d $dir; | ||
} while ( pop @dirlist ); | ||
return; | ||
} | ||
close MAN; | ||
|
||
my @cwd = split( /[\/\\]/, Cwd::getcwd() ); | ||
my $root; | ||
# Checks if a file is in the MANIFEST, and removes it | ||
# otherwise, adds it to @lost | ||
sub isFileInManifest { | ||
my ( $root, $file ) = @_; | ||
|
||
my $diskfile = "$root/$file"; | ||
return if -d $diskfile; # For Subversion | ||
if ( my $mode = delete $man{$file} ) { | ||
my $cmode = ( stat($diskfile) )[2] & 07777; | ||
printf "Permissions for $file differ" | ||
. " in MANIFEST ($mode) and on disk (%lo)\n", $cmode | ||
if ( $checkperm && oct( 0 + $mode ) != $cmode ); | ||
} | ||
else { | ||
return if $file =~ m#^(?:$skipPattern)/#; # For git | ||
#print "Checking ($file) against #/(?:$skipPattern)\$# \n"; | ||
return if $file =~ m#(?:^|/)(?:$skipPattern)$#; # For git | ||
return if $file =~ m#/TestCases/#; | ||
push @lost, $file; | ||
} | ||
|
||
while ( scalar(@cwd) > 1 ) { | ||
$root = join( '/', @cwd ); | ||
if ( -d "$root/lib" && -d "$root/data" ) { | ||
last; | ||
# Try to save file alternate versions, just in case | ||
$alt{"$file.gz"}++; | ||
if ( $file =~ /^(.*)_src(\..*)$/ ) { | ||
$alt{"$1$2"}++; | ||
$alt{"$1$2.gz"}++; | ||
} | ||
if ( $file =~ /^(.*)\.uncompressed(\..*)$/ ) { | ||
$alt{"$1$2"}++; | ||
$alt{"$1$2.gz"}++; | ||
} | ||
pop(@cwd); | ||
} | ||
|
||
die "Can't find root" unless ( -d "$root/lib" && -d "$root/data" ); | ||
# Prints some "helpful" messages | ||
sub help { | ||
print <<"END"; | ||
Run this script from a directory with a MANIFEST file, or from a top level of | ||
an extension, or from within an extension, passing the path of the MANIFEST as | ||
first parameter. | ||
my @skip = qw(tools test working logs); | ||
print <<END; | ||
Run this script from anywhere a directory with a MANIFEST file | ||
The script will find and scan MANIFEST and compare the contents with what is | ||
checked in under $cvs. Any differences are reported. | ||
The script will find and scan MANIFEST and compare the contents with | ||
what is checked in under subversion. Any differences are reported. | ||
It will also compare permissions given in the MANIFEST with permissions which | ||
are on disk. | ||
END | ||
print "The ", join( ',', @skip ), " directories are *not* scanned.\n"; | ||
|
||
my @lost; | ||
my $sk = join( '|', @skip ); | ||
foreach my $dir ( | ||
grep { -d "$root/$_" } | ||
split( /\n/, `svn ls $root` ) | ||
) | ||
{ | ||
next if $dir =~ /^($sk)\/$/; | ||
print "Examining $root/$dir\n"; | ||
push( @lost, | ||
grep { !$man{$_} && !/\/TestCases\// && !-d "$root/$_" } | ||
map { "$dir$_" } | ||
split( /\n/, `svn ls -R $root/$dir` ) ); | ||
print "The " . join( ', ', @skip ) . " directories are *not* scanned.\n"; | ||
} | ||
|
||
my $root = findPathToDir('lib'); | ||
die "Can't find root" unless ( -d "$root/lib" && -d "$root/data" ); | ||
|
||
unless ( -f $manifest ) { | ||
File::Find::find( | ||
sub { | ||
/^MANIFEST\z/ && ( $manifest = $File::Find::name ); | ||
push @manfiles, $manifest if /^MANIFEST\z/; | ||
}, | ||
File::Spec->catdir( $root, 'lib' ) | ||
); | ||
} | ||
die "No such MANIFEST $manifest" unless -e $manifest; | ||
|
||
#foreach my $mf ( @manfiles ) { | ||
# print " .. FOUND $mf \n"; | ||
# } | ||
|
||
open my $man, '<', $manifest or die "Can't open $manifest for reading: $!"; | ||
print "Processing manifest $manifest\n"; | ||
while (<$man>) { | ||
next if /^!include/; | ||
$man{$1} = $2 if /^#?(\S+)\s+(\d+)/; | ||
} | ||
close $man; | ||
|
||
if ( my $gitdir = findPathToDir('.git') ) { | ||
$cvs = 'git'; | ||
|
||
#help($cvs); | ||
for my $file ( split /\n/, qx{cd $root && git ls-files} ) { | ||
$file =~ s#^$root/##; # Should never happen, but safer | ||
$file =~ s#^(?:\.\./)*##; # If checking not from top level | ||
isFileInManifest( $root => $file ); | ||
} | ||
} | ||
else { | ||
help($cvs); | ||
foreach my $dir ( | ||
grep { -d "$root/$_" } | ||
split( /\n/, `svn ls $root` ) | ||
) | ||
{ | ||
next if $dir =~ m#/(?:$skipPattern)/#o; | ||
print "Examining $root/$dir\n"; | ||
for my $file ( | ||
map { "$dir$_" } | ||
split( /\n/, `svn ls -R $root/$dir` ) | ||
) | ||
{ | ||
isFileInManifest( $root => $file ); | ||
} | ||
} | ||
} | ||
print "The following files were found in subversion, but are not in MANIFEST\n"; | ||
print join( "\n", @lost ), "\n"; | ||
|
||
if (@lost) { | ||
my $lost = scalar @lost; | ||
print "The following $lost file" | ||
. ( $lost > 1 ? 's' : '' ) | ||
. " files were found in $cvs, but are not in MANIFEST:\n"; | ||
print join( "\n", @lost, '' ); | ||
} | ||
|
||
#else { | ||
# print "All files in MANIFEST are checked in.\n"; | ||
#} | ||
my @found = sort grep { !delete $alt{$_} } keys %man; | ||
if (@found) { | ||
my $found = scalar @found; | ||
print "The following $found file" | ||
. ( $found > 1 ? 's' : '' ) | ||
. " were found in MANIFEST, but not in $cvs:\n"; | ||
print join( "\n", @found, '' ); | ||
} | ||
|
||
#else { | ||
# print "All files in MANIFEST are in $cvs.\n"; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
perl tools/check_manifest.pl | ||
cd ../AutoViewTemplatePlugin && perl ../core/tools/check_manifest.pl | ||
cd ../CompareRevisionsAddOn && perl ../core/tools/check_manifest.pl | ||
cd ../CommentPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../EditTablePlugin && perl ../core/tools/check_manifest.pl | ||
cd ../EmptyPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../FamFamFamContrib && perl ../core/tools/check_manifest.pl | ||
cd ../HistoryPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../InterwikiPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../JSCalendarContrib && perl ../core/tools/check_manifest.pl | ||
cd ../JQueryPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../MailerContrib && perl ../core/tools/check_manifest.pl | ||
cd ../PatternSkin && perl ../core/tools/check_manifest.pl | ||
cd ../PreferencesPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../RenderListPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../SlideShowPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../SmiliesPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../SpreadSheetPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../TablePlugin && perl ../core/tools/check_manifest.pl | ||
cd ../TinyMCEPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../TipsContrib && perl ../core/tools/check_manifest.pl | ||
cd ../TopicUserMappingContrib && perl ../core/tools/check_manifest.pl | ||
cd ../TWikiCompatibilityPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../TwistyPlugin && perl ../core/tools/check_manifest.pl | ||
cd ../WysiwygPlugin && perl ../core/tools/check_manifest.pl |