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