From owner-man-jp@jp.freebsd.org  Sun Nov 12 18:09:05 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id SAA50410;
	Sun, 12 Nov 2000 18:09:05 +0900 (JST)
	(envelope-from owner-man-jp@jp.FreeBSD.org)
Received: from smtp1.interramp.com (smtp1.interramp.com [38.8.45.2])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id SAA50405
	for <man-jp@jp.freebsd.org>; Sun, 12 Nov 2000 18:09:03 +0900 (JST)
	(envelope-from horikawa@psinet.com)
Received: from [38.26.194.197] (helo=localhost)
	by smtp1.interramp.com with esmtp (Exim 1.90 #1)
	for man-jp@jp.freebsd.org
	id 13ut8A-0005qJ-00; Sun, 12 Nov 2000 04:08:55 -0500
To: man-jp@jp.freebsd.org
X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Sun_Nov_12_03:36:43_2000_809)--"
Content-Transfer-Encoding: 7bit
Message-Id: <20001112040831S.horikawa@psinet.com>
Date: Sun, 12 Nov 2000 04:08:31 -0500
From: Kazuo Horikawa <horikawa@psinet.com>
X-Dispatcher: imput version 20000228(IM140)
Lines: 387
Reply-To: man-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: man-jp 2876
Subject: [man-jp 2876] newsyncstat.pl summary.pl
Errors-To: owner-man-jp@jp.freebsd.org
Sender: owner-man-jp@jp.freebsd.org
X-Originator: horikawa@psinet.com

----Next_Part(Sun_Nov_12_03:36:43_2000_809)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

 $BKY@n$G$9!#(B

 $B@N(B ($B5nG/$N(B 6 $B7n$/$i$$(B) $B=q$$$?(B syncstat.pl $B$H(B summary.pl $B$r99?7$7$F!"(B
$BLuJ8Cf$N(B $FreeBSD:$ $B$+$i86J8$rC5$9$h$&$K$7$F$_$^$7$?!#(B

[$BI,MW$J$b$N(B]
 (1) src $B$N(B CVS repository
 (2) $BLuJ8$N(B work directory (CVS repository $B$G$O$J$$(B)
 (3) perl5
 (4) newsyncstat.pl, summary.pl ($BK\%a!<%k$KE:IU(B)

[$B%+%9%?%^%$%:(B]
 newsyncstat.pl $B$N<!$NJQ?t$r@_Dj$7$^$9!'(B
 o $cvsroot $B$O(B src $B%G%#%l%/%H%j$N?F$r@_Dj$7$^$9!#(B
 o $transroot $B$O!"DL>o$O(B doc $B%G%#%l%/%H%j$N?F$r@_Dj$7$^$9!#(B

 $B;d$N;HMQ4D6-Nc!'(B
	$cvsroot = "/pub/cvsup/FreeBSD.cvs/"
	$transroot = "/home/horikawa/CVS_FREEFALL/"

[$B%*%W%7%g%s(B]
 --docdir=directory
	$transroot/directory $BCf$NA4%U%!%$%k$rD4$Y$k(B
 --htmlout=file
	HTML $B$N=PNO@h$N%U%!%$%kL>(B

[$B;HMQNc(B]
./newsyncstat.pl --docdir=doc/ja_JP.eucJP/man/man1
      --htmlout=$HOME/public_html/syncstat/1.html;
$B$J$I$H$7$^$9(B ($BN>J}$N0z?t$H$bI,MW(B)$B!#(B

 $B;n83E*$K(B http://home.jp.FreeBSD.org/~horikawa/syncstat/
$B:n$k$h$&$K$7$F$*$-$^$9!#(B
(crontab $B$G(B
 40 7 * * * date ; cd $HOME/SYNC ; for i in 1 2 3 4 5 6 7 8 9 ;
  do
    ./newsyncstat.pl --docdir=doc/ja_JP.eucJP/man/man$i
      --htmlout=$HOME/public_html/syncstat/$i.html;
  done
 $B$N$h$&$K$7$F$$$^$9(B)

 $B6a!9!"(B
 o html $B=PNO@h$r(B
   http://home.jp.FreeBSD.org/man-jp/yoyaku/syncstat/[156789].html
   $B$K$9$k(B
 o newsyncstat.pl $B$H(B summary.pl $B$r(B home.jp.FreeBSD.org $B$N(B CVS repository
   man-jp $B$N$I$3$+$KF~$l$k(B
$B$H$$$&$N$r$d$j$?$$$G$9!#(B

 $B$^$?!"(B
 o NG $B$N$b$N$@$1Cj=P$9$k%Z!<%8$r:n$k(B
 o $FreeBSD: $ $B$,L5$$$b$N$K$D$$$F$O!"LuJ8$K86J8%Q%9$r=q$1$k$h$&$K$9$k(B
 o $B86J8$HLuJ8$N%j%S%8%g%s$,0c$&$b$N$KBP$7!"(B
   $B:9J,$r(B cvsweb $B$+$i<h$l$k%j%s%/$rD%$k(B
 o $BC4Ev<T%a!<%k%"%I%l%9$r%^%K%e%"%k$K=q$$$F$*$/$H!"(B
   $B86J8$HLuJ8$N%j%S%8%g%s$,0c$&$h$&$K$J$C$?$iC4Ev<T$K%a!<%k$r=P$9(B
 o $BC4Ev<T%a!<%k%"%I%l%9$r%^%K%e%"%k$K=q$$$F$J$$$H(B
   man-jp@jp.FreeBSD.org $B08$K%a!<%k$r=P$9(B($B$G$h$$$N$+!)(B)
$B$H$$$&5!G=$b!"$=$N$&$A$d$C$F$_$?$$$G$9!#(B

($B$=$NA0$K(B paths.pl $B:n$k$Y$-$H$+!"(B$str_NotAvail $B$r6&DL$N%U%!%$%k$GDj5A(B
 $B$9$Y$-$H$+!"%^%K%e%"%k=q$/$Y$-(B($B!)(B))
--
$BKY@nOBM:(B

----Next_Part(Sun_Nov_12_03:36:43_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: newsyncstat.pl
Content-Disposition: attachment; filename="newsyncstat.pl"

#!/usr/bin/perl
#
# Copyright (C) 2000 Kazuo Horikawa <horikawa@jp.FreeBSD.org>
# All rights reserved 
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Header:$

$summary_generator =	"./summary.pl";
$cvsroot =		"/pub/cvsup/FreeBSD.cvs/";
$transroot =		"/home/horikawa/CVS_FREEFALL/";
$releng =		"RELENG_4";
$str_NotAvail =		'N/A';
$rev_pattern =		"\[\\d\\\.\]\+\\d\+";
$branch_pattern =	"\[\\d\\\.\]\+\\\.0\\\.\\d\+";
$debug =		0;

# Get original's revision number from translated files
# We will see `%FreeBSD: xx.xx', `%Id: xx.xx' and `Original Revision: xx.xx'.
# We do not see `jpman %Id: xx.xx'.
#
# If "xx.xx" found, return "xx.xx" else return "N/A".
sub rev_of_trans{
    my ($filename) = @_;
    my $revision = "";

    printf("filename = %s\n", $filename) if $debug;

    open(IN, "$transroot$filename") || die "cannot open $transroot$filename";
    while($_ = <IN>){
	if(/jpman\s\%Id:\s\S+,v\s($rev_pattern)/) {
	    # Ignore "jpman Id: xx.xx"
	    print "Ignore jpman\n" if $debug;
	    next;
	} elsif(/[Oo]riginal\s[Rr]evision:\s($rev_pattern)/) {
	    # Accept "Original Revision: xx.xx"
	    $revision = $1;
	    print "Original revision tag\n" if $debug;
	    last;			# "Original Revision" has priority
	} elsif(/%FreeBSD:\s\S+,v\s($rev_pattern)/) {
	    # Accept "FreeBSD: xx.xx"
	    print "Id: tag\n" if $debug;
	    $revision = $1;
	    next;			# "Original Revision" has priority
	} elsif(/%Id:\s\S+,v\s($rev_pattern)/) {
	    # Accept "Id: xx.xx"
	    print "Id: tag\n" if $debug;
	    $revision = $1 if($revision == "");
	    next;			# "Original Revision" has priority
	}
    }
    close(IN);

    $revision = $str_NotAvail unless $revision;		# "" becomes 'N/A'
    return $revision;
}

# Get revision number of original files
#
# We must able to find revision number.
sub rev_of_orig{
    my ($filename) = @_;
    my $branch_number ="";
    my $revision = "";

    printf("filename = %s\n", $filename) if $debug;

    if(!open(IN, "$cvsroot$filename,v")) {
	use File::Basename;
	my $basename, $path, $suffix;
	($basename, $path, $suffix) = fileparse($filename,"");
	printf "retry %s\n", "$cvsroot$path/Attic/$basename,v" ;
	open(IN, "$cvsroot$path/Attic/$basename,v")
	    ||die "cannot open $cvsroot$filename";
    }
    # First, find symbols line and convert $releng to branch number.
  FIND_BRANCH_LOOP: while($_ = <IN>){
	if(/symbols\s.*$releng:($rev_pattern)/){
	    printf("%s is %s\n", $releng, $1) if $debug;
	    $branch_number = $1;
	    last;
	}
	elsif(/symbols/){
	    while($_ = <IN>){
		if(/$releng:($rev_pattern)/){
		    $branch_number = $1;
		    printf("branch = %s\n", $branch_number) if $debug;
		    last FIND_BRANCH_LOOP;
		} elsif(/^\@\@$/) {
		    last FIND_BRANCH_LOOP;
		}
	    }
	}
    }
    $branch_number || die "Cannot find branch number for $filename\n";

    # "a.b.0.c" will be converted to "a.b.c"
    $branch_number =~ s/\.0\./\./;

    # Next, find exact revision number.
    while($_ = <IN>){
	if(/^($branch_number\.\d+)/){
	    $revision = $1;
	} elsif(/^\@\@$/){
	    last;
	}
    }
    close(IN);

    if($revision) {
	# return "a.b.c.x"
	print "return $revision\n" if $debug;
	return $revision;
    } else {
	# return "a.b"
	$revision = $branch_number;
	$revision =~ s/\.\d+$//;
	print "return $revision\n" if $debug;
	return $revision;
    }
}

#
# Find original file from translated file
# Use FreeBSD: RCS keyword to find original file
#
sub find_orig_file{
    my ($filename) = @_;

    printf("filename = %s\n", $filename) if $debug;

    open(IN, "$transroot$filename") || die "cannot open $transroot$filename";
    while($_ = <IN>){
	if(/%FreeBSD: (src.*),v/){
	    return ($1);
	}
    }
}

sub usage {
    die "Usage: newsyncstat.pl --docdir=directory --htmlout=file\n";
}

MAIN:{
    use Getopt::Long;
    GetOptions ("docdir=s", "htmlout=s");
    $opt_docdir || $opt_htmlout || &usage();

    # build @manlist
    opendir(JA_DIR, "$transroot$opt_docdir") || die "cannot opendir";
    @manlist = grep{ /\.\d/ && -f "$transroot$opt_docdir/$_" } readdir(JA_DIR);
    @manlist = sort(@manlist);

    open(OUT, "|$summary_generator > $opt_htmlout") || die;

    while($_ = shift(@manlist)){
	$transfilename = "$opt_docdir/$_";
	$origfilename = &find_orig_file("$transfilename");

	if($origfilename) {
	    $trans_ver = &rev_of_trans($transfilename);
	    $orig_ver = &rev_of_orig($origfilename);
	    printf(OUT "%s %s %s %s\n",
		   $transfilename, $origfilename, $trans_ver, $orig_ver);
	} else { 
	    $trans_ver = &rev_of_trans($transfilename);
	    printf(OUT "%s %s %s %s\n",
		   $transfilename, $str_NotAvail, $trans_ver, $str_NotAvail);
	}
    }

    close(OUT);
}

----Next_Part(Sun_Nov_12_03:36:43_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: summary.pl
Content-Disposition: attachment; filename="summary.pl"

#!/usr/bin/perl
#
# Copyright (C) 2000 Kazuo Horikawa <horikawa@jp.FreeBSD.org>
# All rights reserved 
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Header:$

$cvsweb		= "http://www.jp.FreeBSD.org/cgi/cvsweb.cgi/";
$str_NotAvail	= 'N/A';
$rev_pattern	= "\[\\d\\\.\]\+\\d\+";
$stat_OK	= "<SPAN CLASS=\"ok\">OK</SPAN>";
$stat_NG	= "<SPAN CLASS=\"warn\">NG</SPAN>";
$stat_UNKNOWN	= "<SPAN CLASS=\"warn\">Unknown</SPAN>";

$str_Html_Header = <<'EOT';
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-2022-JP">
<STYLE type=text/css>
	BODY { color: black; background: white; }
	a:link    { color: #5555ff; background: white; }
	a:visited { color: #B22222; background: white; }
	a:active  { color: #FF0000; background: white; }
	H1        { text-align: center; color: #00007f; background: white; }
	SPAN.ok   { color: green; }
	SPAN.warn { color: red; }
</STYLE>
<TITLE>Syncstat</TITLE>
</HEAD>
<BODY>
<H1>Status of Synchronization</H1>
EOT

$str_Table_Begin = <<'EOT';
<TABLE BORDER=1 WIDTH="100%">
<TR>
<TD>jman</TD><TD>src</TD><TD>jman rev</TD><TD>man rev</TD><TD>stat</TD>
</TR>
EOT

$str_Table_End = <<'EOT';
</TABLE>
EOT

$str_Html_Footer = <<'EOT';
<P><A HREF="http://jigsaw.w3.org/css-validator"><IMG style="border:0;width:88px;height:31px" SRC="http://jigsaw.w3.org/css-validator/images/vcss.gif" ALT="Valid CSS!"></A>
</BODY></HTML>
EOT

MAIN:{
    use File::Basename;

    print $str_Html_Header;
    print $str_Table_Begin;

    while($_ = <STDIN>){
	if(/(\S+)\s+(\S+)\s+($rev_pattern)\s+($rev_pattern)/){
	    ($jman, $src, $jman_rev, $man_rev) = ($1, $2, $3, $4);
	    
	    if($3 eq $4) {
		$stat = $stat_OK;
	    } else {
		$stat = $stat_NG;
	    }
	} elsif (/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/){
	    ($jman, $src, $jman_rev, $man_rev) = ($1, $2, $3, $4);
	    $stat = $stat_UNKNOWN;
	}

	print("<TR>");
	$jman_basename = basename($jman);
	print("<TD><A HREF=\"$cvsweb$jman\">$jman_basename</A></TD>");
	if ($src eq $str_NotAvail) {
	    print("<TD>$src</TD>");
	} else {
	    print("<TD><A HREF=\"$cvsweb$src\">$src</A></TD>");
	}
	print("<TD>$jman_rev</TD><TD>$man_rev</TD><TD>$stat</TD>");
	print("</TR>\n");
    }
    close (IN);

    print $str_Table_End;

    $lastmodified = localtime;
    print "<P>Last Modified: $lastmodified</P>\n";
    print $str_Html_Footer;
}

----Next_Part(Sun_Nov_12_03:36:43_2000_809)----
