$cvsroot = $ENV{'CVSROOT'};
$) = $(;
$dostatus = 1;
while (@ARGV) {
$arg = shift @ARGV;
if ($arg eq '-m') {
$users = "$users " . shift @ARGV;
} elsif ($arg eq '-f') {
($logfile) && die "Too many '-f' args";
$logfile = shift @ARGV;
} elsif ($arg eq '-s') {
$dostatus = 0;
} else {
($donefiles) && die "Too many arguments!\n";
$donefiles = 1;
@files = split(/ /, $arg);
}
}
$modulepath = shift @files;
$mailcmd = "| Mail -s 'CVS update: $modulepath'";
@mos = (January,February,March,April,May,June,July,August,September,
October,November,December);
@days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$login = getlogin || (getpwuid($<))[0] || "nobody";
open(OUT, ">>" . $logfile) || die "Could not open(" . $logfile . "): $!\n";
if ($users) {
$mailcmd = "$mailcmd $users";
open(MAIL, $mailcmd) || die "Could not Exec($mailcmd): $!\n";
}
print OUT "\n";
print OUT "****************************************\n";
print OUT "Date:\t$days[$wday] $mos[$mon] $mday, 19$year @ $hour:" . sprintf("%02d", $min) . "\n";
print OUT "Author:\t$login\n\n";
if (MAIL) {
print MAIL "\n";
print MAIL "Date:\t$days[$wday] $mos[$mon] $mday, 19$year @ $hour:" . sprintf("%02d", $min) . "\n";
print MAIL "Author:\t$login\n\n";
}
open(IN, "-");
while (<IN>) {
print OUT $_;
if (MAIL) {
print MAIL $_;
}
}
close(IN);
print OUT "\n";
if ($dostatus != 0) {
while (@files) {
$file = shift @files;
if ($file eq "-") {
print OUT "[input file was '-']\n";
if (MAIL) {
print MAIL "[input file was '-']\n";
}
last;
}
$pid = open(RCS, "-|");
if ( !defined $pid )
{
die "fork failed: $!";
}
if ($pid == 0)
{
exec 'cvs', '-nQq', 'status', '-v', $file;
die "cvs exec failed: $!";
}
while (<RCS>) {
print OUT;
if (MAIL) {
print MAIL;
}
}
close(RCS);
}
}
close(OUT);
die "Write to $logfile failed" if $?;
close(MAIL);
die "Pipe to $mailcmd failed" if $?;
exit 0;