merge_copyrights revision 50722c0d550a63d4a2b8f34e907b693a81d864e0
824N/A#!/usr/local/bin/perl -w
824N/A#
824N/A# Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
824N/A# Copyright (C) 1998-2001, 2003 Internet Software Consortium.
824N/A#
824N/A# Permission to use, copy, modify, and distribute this software for any
824N/A# purpose with or without fee is hereby granted, provided that the above
824N/A# copyright notice and this permission notice appear in all copies.
824N/A#
824N/A# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
824N/A# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
824N/A# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
824N/A# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
824N/A# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
824N/A# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
824N/A# PERFORMANCE OF THIS SOFTWARE.
824N/A
824N/A# $Id: merge_copyrights,v 1.26 2006/10/05 00:31:43 marka Exp $
824N/A
824N/A%file_types = ();
824N/A%file_years = ();
824N/A
824N/Aopen(COPYRIGHTS, "<util/copyrights") || die "can't open ./util/copyrights: $!";
824N/Awhile (<COPYRIGHTS>) {
824N/A chomp;
824N/A ($file, $type, $years) = split;
824N/A $file_types{$file} = $type;
824N/A $file_years{$file} = $years;
824N/A}
824N/Aclose(COPYRIGHTS);
824N/A
824N/A($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
833N/A$year += 1900;
824N/A
824N/A$find = "find . -type f -print";
824N/A
824N/Aopen(FILES, "$find | sort |") || die "can't start \"$find\": $!";
824N/Awhile (<FILES>) {
824N/A chomp;
824N/A
824N/A next if (m%/\.\# | # CVS old conflict file
824N/A /CVS/ | # CVS directory
824N/A util/newcopyrights | # our output
824N/A \.bak$ | # created by update_copyrights
824N/A /(dnssafe|openssl)/.*\.[ch]$ | # imported
824N/A doc/(draft|expired|rfc)/ # imported
824N/A %x);
824N/A
824N/A if (!$file_types{$_}) {
824N/A # Strip any .in extension to find out the file's real type.
833N/A # .in files are processed by configure to produce the target file.
824N/A ($base = $_) =~ s/\.in$//;
824N/A
824N/A # Contributed code should maintain its own copyright.
824N/A if ($base =~ /\.\/contrib\//) {
824N/A $file_types{$_} = "X";
824N/A } elsif ($base =~ /\.(c|h|css)$/) {
824N/A $file_types{$_} = "C";
824N/A } elsif ($base =~ /\.y$/) {
824N/A $file_types{$_} = "YACC";
824N/A } elsif ($base =~ /\.pl$/i) {
824N/A $file_types{$_} = "PERL";
833N/A } elsif ($base =~ /\.sh$/) {
824N/A $file_types{$_} = "SH";
824N/A } elsif ($base =~ /\.docbook$/ ||
824N/A $base =~ /.xsl$/ ||
824N/A $base =~ /.xml$/) {
824N/A $file_types{$_} = "SGML";
824N/A } elsif ($base =~ /\.html$/) {
824N/A $file_types{$_} = "HTML";
824N/A } elsif ($base =~ /\.(man|[0-9])$/) {
824N/A $file_types{$_} = "MAN";
824N/A } elsif ($base =~ /\/Makefile$/) {
$file_types{$_} = "MAKE";
} elsif ($base =~ /\/(named|rndc).?\.conf$/) {
$file_types{$_} = "CONF-C";
} elsif ($base =~ /\/resolv.?\.conf$/) {
$file_types{$_} = "CONF-SH";
} elsif ($base =~ /\.(db|hint)$/) {
$file_types{$_} = "ZONE";
} elsif ($base =~ /(\/\.cvsignore|\.gif|\.jpg|\.dsp|\.dsw)$/i) {
$file_types{$_} = "X";
} else {
$file_types{$_} = "?";
}
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks)
= stat($_);
($sec,$min,$hour,$mday,$mon,$c_year,$wday,$yday,$isdst) =
localtime($ctime);
($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
localtime($mtime);
$c_year += 1900;
$m_year += 1900;
if ($m_year != $year || $c_year != $year) {
print "$_: must set copyright year(s) manually\n";
$file_years{$_} = "????";
} else {
$file_years{$_} = "$year";
}
# keep perl from issuing warnings about "used only once"
$dev = $ino = $mode = $nlink = $uid = $gid = $rdev = $size = 0;
$atime = $blksize = $blocks = 0;
} else {
if (! defined($file_years{$_}) || $file_years{$_} eq "????") {
print "$_: must set copyright year(s) manually\n";
$file_years{$_} = "????";
next;
}
# track the modification years even if we are not going to be
# updating the copyrights.
# next if $file_types{$_} eq "X";
next if ($file_years{$_} =~ /^PARENT:/);
next if ($file_years{$_} eq "DOCBOOK");
@years = split(/,/, $file_years{$_});
$has_current = 0;
foreach $fyear (@years) {
if ($fyear == $year) {
$has_current = 1;
}
}
if (!$has_current) {
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks)
= stat($_);
($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
localtime($mtime);
$m_year += 1900;
if ($m_year == $year) {
$file_years{$_} .= ",$year";
}
}
}
}
close(FILES);
open(NEWCOPYRIGHTS, ">util/newcopyrights") ||
die "can't open newcopyrights: $!";
foreach $file (sort(keys(%file_types))) {
print NEWCOPYRIGHTS "$file";
$len = length($file);
if ($len >= 48) {
$tabs = 1;
} else {
$needed = int (48 - $len);
$tabs = int ($needed / 8);
if ($needed % 8 != 0) {
$tabs++;
}
}
for ($i = 0; $i < $tabs; $i++) {
printf NEWCOPYRIGHTS "\t";
}
printf NEWCOPYRIGHTS "%s\t%s\n", $file_types{$file}, $file_years{$file};
}
close(NEWCOPYRIGHTS);