Exclude all files in htdocs/releases, and better check and sanitize the
exclude path used.
This commit is contained in:
parent
2e832d5849
commit
90c78f7750
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=50814
1 changed files with 15 additions and 12 deletions
|
@ -48,7 +48,7 @@ my $svn = '/usr/local/bin/svn';
|
||||||
my $xargs = '/usr/bin/xargs';
|
my $xargs = '/usr/bin/xargs';
|
||||||
|
|
||||||
my $docdir = '/usr/doc/en_US.ISO8859-1';
|
my $docdir = '/usr/doc/en_US.ISO8859-1';
|
||||||
my $exclpath = 'htdocs/releases/*/*.html';
|
my $exclpath = 'htdocs/releases/*/*';
|
||||||
my $verbose = 0;
|
my $verbose = 0;
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
|
@ -64,8 +64,9 @@ sub usage {
|
||||||
print "encoding directories like en_US.ISO8859-1 to UTF-8. The\n";
|
print "encoding directories like en_US.ISO8859-1 to UTF-8. The\n";
|
||||||
print "documentation directory must be a Subversion checkout. After\n";
|
print "documentation directory must be a Subversion checkout. After\n";
|
||||||
print "files are converted, the directory is renamed to *.UTF-8.\n\n";
|
print "files are converted, the directory is renamed to *.UTF-8.\n\n";
|
||||||
print "The default exclude path prevents conversion of statically-\n";
|
print "The default exclude path prevents conversion of all files\n";
|
||||||
print "generated HTML files in htdocs/releases/*/*.html.\n";
|
print "htdocs/releases/*/*. These files are typically statically-\n";
|
||||||
|
print "generated historical files.\n";
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,10 +95,17 @@ sub make_clean {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub find_files {
|
sub find_files {
|
||||||
my ($dn) = @_;
|
my ($dn,$exclpath) = @_;
|
||||||
|
|
||||||
|
my $fullexclpath = "$dn/$exclpath";
|
||||||
|
# sanitize exclude path, find is very picky about matches
|
||||||
|
# convert multiple slashes to single
|
||||||
|
$fullexclpath =~ s%/{2,}%/%;
|
||||||
|
die "** exclude path '$exclpath' must be relative (under '$docdir')\n" if $exclpath =~ m%^/%;
|
||||||
|
|
||||||
print "finding files to be converted in '$dn'\n" if $verbose;
|
print "finding files to be converted in '$dn'\n" if $verbose;
|
||||||
print "excluding files matching \"$dn$exclpath/*\"\n" if $verbose;
|
print "excluding files matching \"$fullexclpath/*\"\n" if $verbose;
|
||||||
return map(/^(.*):/, `$find $dn -not -path \"$dn$exclpath\" -type f -print0 | $xargs -0 $file | $grep 'XML\\|SGML\\|BSD'`);
|
return map(/^(.*):/, `$find $dn -not -path \"$fullexclpath\" -type f -print0 | $xargs -0 $file | $grep 'XML\\|SGML\\|BSD'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub convert_file {
|
sub convert_file {
|
||||||
|
@ -149,11 +157,6 @@ sub main {
|
||||||
$docdir = $opt_d if $opt_d;
|
$docdir = $opt_d if $opt_d;
|
||||||
$exclpath = $opt_e if $opt_e;
|
$exclpath = $opt_e if $opt_e;
|
||||||
|
|
||||||
# sanitize exclude path, find is very picky about matches
|
|
||||||
# convert multiple slashes to single
|
|
||||||
$exclpath =~ s%/{2,}%/%;
|
|
||||||
die "** exclude path '$exclpath' must be relative (under '$docdir')\n" if $exclpath =~ m%^/%;
|
|
||||||
|
|
||||||
my $basedir = basename($docdir);
|
my $basedir = basename($docdir);
|
||||||
die "** '$docdir' does not have a standard ISO xy_AB directory name\n" unless $basedir =~ /^([a-z]{2}_[A-Z]{1,3})\./;
|
die "** '$docdir' does not have a standard ISO xy_AB directory name\n" unless $basedir =~ /^([a-z]{2}_[A-Z]{1,3})\./;
|
||||||
my $isolang = $1;
|
my $isolang = $1;
|
||||||
|
@ -179,7 +182,7 @@ sub main {
|
||||||
|
|
||||||
make_clean($docdir);
|
make_clean($docdir);
|
||||||
|
|
||||||
my @files = find_files($docdir);
|
my @files = find_files($docdir, $exclpath);
|
||||||
|
|
||||||
for my $f (@files) {
|
for my $f (@files) {
|
||||||
convert_file($f, $basedir, $isolang, $fromcode, $tocode);
|
convert_file($f, $basedir, $isolang, $fromcode, $tocode);
|
||||||
|
|
Loading…
Reference in a new issue