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