merge_copyrights revision 620a452ebe92fff63e85c5930a6e6dc8d9455918
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User#!/usr/local/bin/perl -w
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater#
7a2a1b8b14fc804ac80612d7b98064095e445be5Automatic Updater# Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
7a42357217528037bdfedcb17eeebfe96ae4266aAutomatic Updater# Copyright (C) 1998-2001, 2003 Internet Software Consortium.
1167fc7904c5f0a472f8df207ac46dd52c7f1ec8Automatic Updater#
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater# Permission to use, copy, modify, and/or distribute this software for any
46da3117812814a29432a8d9a9ccf8acdbfdadceAutomatic Updater# purpose with or without fee is hereby granted, provided that the above
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# copyright notice and this permission notice appear in all copies.
fe84edc17e0d582cf7b4270f8df9d4742a107b1cAutomatic Updater#
79b273c187a4aa1016a62181983dfdd0521681aeMark Andrews# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
b253dcf9668f95e141bce9556dc88e30d3305a1dTinderbox User# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
bbde8dc56605130058a1540609264fa109da3b63Automatic Updater# PERFORMANCE OF THIS SOFTWARE.
bbde8dc56605130058a1540609264fa109da3b63Automatic Updater
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# $Id: merge_copyrights,v 1.35 2009/12/03 04:45:10 marka Exp $
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updater%file_types = ();
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews%file_years = ();
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews
a01aa536188bb3535dfc1107a623e6355a8e6b7cMark Andrewsopen(COPYRIGHTS, "<util/copyrights") || die "can't open ./util/copyrights: $!";
89623368b8f662d458d9964b923050f33c5f75b0Tinderbox Userwhile (<COPYRIGHTS>) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews chomp;
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater ($file, $type, $years) = split;
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews $file_types{$file} = $type;
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $file_years{$file} = $years;
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson}
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterclose(COPYRIGHTS);
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater$year += 1900;
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User$find = "find . -type f -print";
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updateropen(FILES, "$find | sort |") || die "can't start \"$find\": $!";
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterwhile (<FILES>) {
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt chomp;
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater next if (m%/\.\# | # CVS old conflict file
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater /CVS/ | # CVS directory
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt util/newcopyrights | # our output
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater \.bak$ | # created by update_copyrights
2d2dc37599979c83495510f8af8d1756753aa2c5Automatic Updater /(dnssafe|openssl)/.*\.[ch]$ | # imported
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt doc/(draft|expired|rfc)/ # imported
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User %x);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater if (!$file_types{$_}) {
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater # Strip any .in extension to find out the file's real type.
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater # .in files are processed by configure to produce the target file.
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater ($base = $_) =~ s/\.in$//;
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater # Contributed code should maintain its own copyright.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater if ($base =~ /\.\/contrib\//) {
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater $file_types{$_} = "X";
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews } elsif ($base =~ /\/openssl-[a-z0-9.]*-patch$/) {
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews $file_types{$_} = "X";
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews } elsif ($base =~ /\.(c|h|css)$/) {
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User $file_types{$_} = "C";
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User } elsif ($base =~ /\.y$/) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $file_types{$_} = "YACC";
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater } elsif ($base =~ /\.pl$/i) {
8e9f3b69914ee02a80b87c97b1f8093edb3e9ae0Automatic Updater $file_types{$_} = "PERL";
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews } elsif ($base =~ /\.sh$/) {
930f6069e5aa157cf6987cdafd412f5757a5a558Automatic Updater $file_types{$_} = "SH";
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews } elsif ($base =~ /\.docbook$/ ||
930f6069e5aa157cf6987cdafd412f5757a5a558Automatic Updater $base =~ /.xsl$/ ||
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater $base =~ /.xml$/) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $file_types{$_} = "SGML";
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater } elsif ($base =~ /\.html$/) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $file_types{$_} = "HTML";
114f7780384371121918624ae2c80ecfce545683Tinderbox User } elsif ($base =~ /\.(man|[0-9])$/) {
693c4232dfdffaff672197d4b9fea944c64cf80aAutomatic Updater $file_types{$_} = "MAN";
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews } elsif ($base =~ /\/Makefile$/) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $file_types{$_} = "MAKE";
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson } elsif ($base =~ /\/(named|rndc).?\.conf$/) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $file_types{$_} = "CONF-C";
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater } elsif ($base =~ /\/resolv.?\.conf$/) {
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews $file_types{$_} = "CONF-SH";
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater } elsif ($base =~ /\.(db|hint)$/) {
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson $file_types{$_} = "ZONE";
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater } elsif ($base =~ /(\/\.cvsignore|\.gif|\.jpg|\.dsp|\.dsw|\.mak)$/i) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $file_types{$_} = "X";
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson } elsif ($base =~ /\.rnc$/i) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $file_types{$_} = "RNC";
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User } elsif ($base =~ /^\.\/EXCLUDED$/i) {
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews $file_types{$_} = "X";
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews } elsif ($base =~ /\.bat$/i) {
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User $file_types{$_} = "BAT";
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User } else {
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews $file_types{$_} = "?";
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont }
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User $blksize,$blocks)
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont = stat($_);
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews ($sec,$min,$hour,$mday,$mon,$c_year,$wday,$yday,$isdst) =
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User localtime($ctime);
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews localtime($mtime);
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews $c_year += 1900;
24bf1e02f03577db0feb50b80238c4150c96d05dAutomatic Updater $m_year += 1900;
24bf1e02f03577db0feb50b80238c4150c96d05dAutomatic Updater if ($m_year != $year || $c_year != $year) {
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews print "$_: must set copyright year(s) manually\n";
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews $file_years{$_} = "????";
7500521cecdff3c00e594ec41d3a17292332ffbcTinderbox User } else {
a308b69ac66fadf66863484f301314d6e6a3f1d2Automatic Updater $file_years{$_} = "$year";
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews }
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # keep perl from issuing warnings about "used only once"
a01aa536188bb3535dfc1107a623e6355a8e6b7cMark Andrews $dev = $ino = $mode = $nlink = $uid = $gid = $rdev = $size = 0;
89623368b8f662d458d9964b923050f33c5f75b0Tinderbox User $atime = $blksize = $blocks = 0;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews } else {
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews if (! defined($file_years{$_}) || $file_years{$_} eq "????") {
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews print "$_: must set copyright year(s) manually\n";
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews $file_years{$_} = "????";
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews next;
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews }
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater # track the modification years even if we are not going to be
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater # updating the copyrights.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater # next if $file_types{$_} eq "X";
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater next if ($file_years{$_} =~ /^PARENT:/);
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater next if ($file_years{$_} eq "DOCBOOK");
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater @years = split(/,/, $file_years{$_});
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $has_current = 0;
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater foreach $fyear (@years) {
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson if ($fyear == $year) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $has_current = 1;
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews }
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson }
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater if (!$has_current) {
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater $blksize,$blocks)
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater = stat($_);
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater localtime($mtime);
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $m_year += 1900;
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson if ($m_year == $year) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $file_years{$_} .= ",$year";
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User }
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User }
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User }
1368e4b34cef64604c874fcc40201c78e548714cTinderbox User}
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox Userclose(FILES);
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User
f132a836c4e386b1af045dd8fe7106ae61b90bffAutomatic Updateropen(NEWCOPYRIGHTS, ">util/newcopyrights") ||
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater die "can't open newcopyrights: $!";
c6a0f4ae1d7183a16ffb196b86b647f870694796Automatic Updaterforeach $file (sort(keys(%file_types))) {
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater print NEWCOPYRIGHTS "$file";
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User $len = length($file);
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User if ($len >= 48) {
269519eeb959d905ed125f96426e01d725c3b597Tinderbox User $tabs = 1;
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater } else {
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $needed = int (48 - $len);
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater $tabs = int ($needed / 8);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater if ($needed % 8 != 0) {
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater $tabs++;
9c446b72069d0ab9f710502f4d7048e50875fccbAutomatic Updater }
e85565067cf73f8cc21ee29b11761659f1d47ee9Automatic Updater }
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater for ($i = 0; $i < $tabs; $i++) {
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater printf NEWCOPYRIGHTS "\t";
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater }
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater printf NEWCOPYRIGHTS "%s\t%s\n", $file_types{$file}, $file_years{$file};
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater}
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterclose(NEWCOPYRIGHTS);
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater