merge_copyrights revision 460b427411b72da26b1836b9424e2e70d65d9394
20c794b39650d115e17a15983b6b82e46238cf45gavinm#!/usr/local/bin/perl -w
20c794b39650d115e17a15983b6b82e46238cf45gavinm#
20c794b39650d115e17a15983b6b82e46238cf45gavinm# Copyright (C) 1998-2000 Internet Software Consortium.
20c794b39650d115e17a15983b6b82e46238cf45gavinm#
20c794b39650d115e17a15983b6b82e46238cf45gavinm# Permission to use, copy, modify, and distribute this software for any
20c794b39650d115e17a15983b6b82e46238cf45gavinm# purpose with or without fee is hereby granted, provided that the above
20c794b39650d115e17a15983b6b82e46238cf45gavinm# copyright notice and this permission notice appear in all copies.
20c794b39650d115e17a15983b6b82e46238cf45gavinm#
20c794b39650d115e17a15983b6b82e46238cf45gavinm# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
20c794b39650d115e17a15983b6b82e46238cf45gavinm# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
20c794b39650d115e17a15983b6b82e46238cf45gavinm# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
20c794b39650d115e17a15983b6b82e46238cf45gavinm# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20c794b39650d115e17a15983b6b82e46238cf45gavinm# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
20c794b39650d115e17a15983b6b82e46238cf45gavinm# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
20c794b39650d115e17a15983b6b82e46238cf45gavinm# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20c794b39650d115e17a15983b6b82e46238cf45gavinm# SOFTWARE.
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm%file_types = ();
20c794b39650d115e17a15983b6b82e46238cf45gavinm%file_years = ();
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmopen(COPYRIGHTS, "<util/copyrights") || die "can't open ./util/copyrights: $!";
20c794b39650d115e17a15983b6b82e46238cf45gavinmwhile (<COPYRIGHTS>) {
8cffa125fa3761e4ea4b99a01cb1207e1d90e740Stephen Hanson chomp;
20c794b39650d115e17a15983b6b82e46238cf45gavinm ($file, $type, $years) = split;
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$file} = $type;
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_years{$file} = $years;
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinmclose(COPYRIGHTS);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
20c794b39650d115e17a15983b6b82e46238cf45gavinm$year += 1900;
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm$find = "find . -type f -print";
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmopen(FILES, "$find | sort |") || die "can't start \"$find\": $!";
20c794b39650d115e17a15983b6b82e46238cf45gavinmwhile (<FILES>) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm chomp;
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm next if (m%/\.\# | # CVS old conflict file
20c794b39650d115e17a15983b6b82e46238cf45gavinm /CVS/ | # CVS directory
20c794b39650d115e17a15983b6b82e46238cf45gavinm \.bak$ | # created by update_copyrights
20c794b39650d115e17a15983b6b82e46238cf45gavinm /(dnssafe|openssl)/.*\.[ch]$ | # imported
20c794b39650d115e17a15983b6b82e46238cf45gavinm doc/(draft|expired|rfc)/ # imported
20c794b39650d115e17a15983b6b82e46238cf45gavinm %x);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinm if (!$file_types{$_}) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm if ($_ =~ /\.(c|h|css)$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "C";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\.y$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "YACC";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\.pl$/i) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "PERL";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\.sh$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "SH";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\.html$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "HTML";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\.man$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "MAN";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\/Makefile\.in$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "MAKE";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\/named.?\.conf$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "CONF-C";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /\.(db|hint)(\.in)?$/) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "ZONE";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } elsif ($_ =~ /(\/\.cvsignore|\.gif|\.jpg)$/i) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "X";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } else {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_types{$_} = "?";
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
20c794b39650d115e17a15983b6b82e46238cf45gavinm $blksize,$blocks)
20c794b39650d115e17a15983b6b82e46238cf45gavinm = stat($_);
20c794b39650d115e17a15983b6b82e46238cf45gavinm ($sec,$min,$hour,$mday,$mon,$c_year,$wday,$yday,$isdst) =
20c794b39650d115e17a15983b6b82e46238cf45gavinm localtime($ctime);
20c794b39650d115e17a15983b6b82e46238cf45gavinm ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
20c794b39650d115e17a15983b6b82e46238cf45gavinm localtime($mtime);
20c794b39650d115e17a15983b6b82e46238cf45gavinm $c_year += 1900;
20c794b39650d115e17a15983b6b82e46238cf45gavinm $m_year += 1900;
20c794b39650d115e17a15983b6b82e46238cf45gavinm if ($m_year != $year || $c_year != $year) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm print "$_: must set copyright year(s) manually\n";
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_years{$_} = "????";
20c794b39650d115e17a15983b6b82e46238cf45gavinm } else {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_years{$_} = "$year";
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm # keep perl from issuing warnings about "used only once"
20c794b39650d115e17a15983b6b82e46238cf45gavinm $dev = $ino = $mode = $nlink = $uid = $gid = $rdev = $size = 0;
20c794b39650d115e17a15983b6b82e46238cf45gavinm $atime = $blksize = $blocks = 0;
20c794b39650d115e17a15983b6b82e46238cf45gavinm } else {
20c794b39650d115e17a15983b6b82e46238cf45gavinm if ($file_types{$_} eq "X" || $file_years{$_} eq "????") {
20c794b39650d115e17a15983b6b82e46238cf45gavinm next;
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm @years = split(/,/, $file_years{$_});
20c794b39650d115e17a15983b6b82e46238cf45gavinm $has_current = 0;
20c794b39650d115e17a15983b6b82e46238cf45gavinm foreach $fyear (@years) {
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye if ($fyear == $year) {
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye $has_current = 1;
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (!$has_current) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
20c794b39650d115e17a15983b6b82e46238cf45gavinm $blksize,$blocks)
20c794b39650d115e17a15983b6b82e46238cf45gavinm = stat($_);
20c794b39650d115e17a15983b6b82e46238cf45gavinm ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
20c794b39650d115e17a15983b6b82e46238cf45gavinm localtime($mtime);
20c794b39650d115e17a15983b6b82e46238cf45gavinm $m_year += 1900;
20c794b39650d115e17a15983b6b82e46238cf45gavinm if ($m_year == $year) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $file_years{$_} .= ",$year";
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh }
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm}
20c794b39650d115e17a15983b6b82e46238cf45gavinmclose(FILES);
20c794b39650d115e17a15983b6b82e46238cf45gavinm
20c794b39650d115e17a15983b6b82e46238cf45gavinmopen(NEWCOPYRIGHTS, ">util/newcopyrights") ||
20c794b39650d115e17a15983b6b82e46238cf45gavinm die "can't open newcopyrights: $!";
20c794b39650d115e17a15983b6b82e46238cf45gavinmforeach $file (sort(keys(%file_types))) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm print NEWCOPYRIGHTS "$file";
20c794b39650d115e17a15983b6b82e46238cf45gavinm $len = length($file);
20c794b39650d115e17a15983b6b82e46238cf45gavinm if ($len >= 48) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $tabs = 1;
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh } else {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh $needed = int (48 - $len);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh $tabs = int ($needed / 8);
20c794b39650d115e17a15983b6b82e46238cf45gavinm if ($needed % 8 != 0) {
20c794b39650d115e17a15983b6b82e46238cf45gavinm $tabs++;
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh for ($i = 0; $i < $tabs; $i++) {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh printf NEWCOPYRIGHTS "\t";
20c794b39650d115e17a15983b6b82e46238cf45gavinm }
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh printf NEWCOPYRIGHTS "%s\t%s\n", $file_types{$file}, $file_years{$file};
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh}
20c794b39650d115e17a15983b6b82e46238cf45gavinmclose(NEWCOPYRIGHTS);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh