| 1 |
#!/usr/bin/perl -w
|
| 2 |
|
| 3 |
# This is a little utility designed to keep track of translations
|
| 4 |
# in the Debian manpages CVS repository.
|
| 5 |
#
|
| 6 |
# Hacked to deal with manpages as well
|
| 7 |
|
| 8 |
# This is GPL'ed code.
|
| 9 |
# Copyright 2002 Denis Barbier <barbier@debian.org>
|
| 10 |
|
| 11 |
# Invocation:
|
| 12 |
# compare_files.pl dbfile manroot
|
| 13 |
# where dbfile is a database file generated by webwml/check_trans.pl and
|
| 14 |
# manroot is the top-level directory of manpages
|
| 15 |
|
| 16 |
# It needs to be run from the top level manpages directory.
|
| 17 |
|
| 18 |
use strict;
|
| 19 |
use Getopt::Long;
|
| 20 |
|
| 21 |
# These modules reside under webwml/Perl
|
| 22 |
use lib ($0 =~ m|(.*)/|, $1 or ".") ."/../webwml/Perl";
|
| 23 |
use Webwml::L10n::Db;
|
| 24 |
|
| 25 |
sub usage {
|
| 26 |
print STDERR <<'EOT';
|
| 27 |
Usage: compare_files.pl [OPTIONS] pkgdb mandb
|
| 28 |
Options:
|
| 29 |
-h, --help display this help message
|
| 30 |
-m, --mailto=ADDRESS send output to an email address
|
| 31 |
EOT
|
| 32 |
exit($_[0]);
|
| 33 |
}
|
| 34 |
|
| 35 |
our $mailto = '';
|
| 36 |
our $help = 0;
|
| 37 |
GetOptions(
|
| 38 |
'help|h' => \$help,
|
| 39 |
'mailto|m=s' => \$mailto,
|
| 40 |
) or usage(1);
|
| 41 |
|
| 42 |
usage(0) if $help;
|
| 43 |
usage(1) unless $#ARGV == 1;
|
| 44 |
|
| 45 |
my $DB_FILE = shift @ARGV;
|
| 46 |
my $MAN_ROOT = shift @ARGV;
|
| 47 |
|
| 48 |
my $maintainer = 'barbier@ftp-master.debian.org';
|
| 49 |
|
| 50 |
my $data = Webwml::L10n::Db->new();
|
| 51 |
$data->read($DB_FILE);
|
| 52 |
|
| 53 |
my %errors = ();
|
| 54 |
|
| 55 |
foreach my $pkg ($data->list_packages()) {
|
| 56 |
next unless $data->has_man($pkg);
|
| 57 |
foreach my $line (@{$data->man($pkg)}) {
|
| 58 |
my ($man, $lang, $link) = @{$line};
|
| 59 |
my $pkgdir = $MAN_ROOT."/".$data->pooldir($pkg);
|
| 60 |
open (INFOS, "< $lang/$pkg/INFOS") or next;
|
| 61 |
my $manpage = '';
|
| 62 |
while (<INFOS>) {
|
| 63 |
chomp;
|
| 64 |
if ($_ =~ m/^\s*$/) {
|
| 65 |
$manpage = '';
|
| 66 |
} elsif (s/^manpage:\s*//i) {
|
| 67 |
$manpage = $_;
|
| 68 |
} elsif (s/^build-source:\s*//i) {
|
| 69 |
my $cmd = <INFOS> || last;
|
| 70 |
chomp $cmd;
|
| 71 |
if ($cmd =~ m/^\s*perldoc\s+-uF\s+\S+\s+>\s+$man\s*$/) {
|
| 72 |
system("cd $pkgdir; gzip -dc $link.gz > $link; perldoc -uF $link > $manpage && gzip -f $manpage; rm -f $link");
|
| 73 |
$link = $manpage;
|
| 74 |
}
|
| 75 |
}
|
| 76 |
}
|
| 77 |
close (INFOS);
|
| 78 |
$link = $pkgdir."/".$link;
|
| 79 |
my $rc = qx,zcmp $link.gz $lang/$pkg/$man 2>\&1,;
|
| 80 |
if ($rc) {
|
| 81 |
$errors{$pkg} = [] unless defined $errors{$pkg};
|
| 82 |
push(@{$errors{$pkg}}, "$lang/$pkg/$man", $rc);
|
| 83 |
}
|
| 84 |
}
|
| 85 |
}
|
| 86 |
|
| 87 |
my $text = '';
|
| 88 |
foreach my $pkg (sort keys %errors) {
|
| 89 |
$text .= "\n".$pkg.' '.$data->version($pkg)."\n";
|
| 90 |
my @lines = @{$errors{$pkg}};
|
| 91 |
while (@lines) {
|
| 92 |
$text .= " ".shift(@lines)."\n ".shift(@lines);
|
| 93 |
}
|
| 94 |
}
|
| 95 |
exit (0) unless $text;
|
| 96 |
|
| 97 |
if ($mailto) {
|
| 98 |
open(SENDMAIL, "|/usr/lib/sendmail -t -oi -odq")
|
| 99 |
or die "Can't fork for sendmail: $!\n";
|
| 100 |
print SENDMAIL <<"EOF";
|
| 101 |
From: $maintainer
|
| 102 |
To: $mailto
|
| 103 |
Subject: [ddp-manpages] Daily report
|
| 104 |
Reply-to: $mailto
|
| 105 |
Mail-Followup-To: $mailto
|
| 106 |
Mail-Copies-To: never
|
| 107 |
|
| 108 |
List of packages shipping man pages different from the ones found
|
| 109 |
in the ddp-manpages CVS repository:
|
| 110 |
$text
|
| 111 |
EOF
|
| 112 |
close(SENDMAIL) or warn ("sendmail didn't close nicely");
|
| 113 |
} else {
|
| 114 |
print STDERR $text;
|
| 115 |
}
|
| 116 |
|
| 117 |
1;
|
| 118 |
|