2012-05-15 21:19:04 +02:00
|
|
|
#!/usr/bin/perl
|
2011-08-19 19:50:39 +02:00
|
|
|
#################################################################
|
|
|
|
# copyright.pl -- update copyright notices throughout the source tree, idempotently.
|
|
|
|
#
|
2013-01-01 23:15:01 +01:00
|
|
|
# Copyright (c) 2011-2013, PostgreSQL Global Development Group
|
2011-08-19 19:50:39 +02:00
|
|
|
#
|
|
|
|
# src/tools/copyright.pl
|
|
|
|
#################################################################
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use File::Find;
|
2012-07-06 17:43:59 +02:00
|
|
|
use File::Basename;
|
2011-08-20 01:31:12 +02:00
|
|
|
use Tie::File;
|
2011-08-19 19:50:39 +02:00
|
|
|
|
|
|
|
my $pgdg = 'PostgreSQL Global Development Group';
|
2012-07-05 03:47:49 +02:00
|
|
|
my $cc = 'Copyright \(c\) ';
|
|
|
|
|
2011-08-19 19:50:39 +02:00
|
|
|
# year-1900 is what localtime(time) puts in element 5
|
2012-07-05 03:47:49 +02:00
|
|
|
my $year = 1900 + ${ [ localtime(time) ] }[5];
|
2011-08-19 19:50:39 +02:00
|
|
|
|
|
|
|
print "Using current year: $year\n";
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
find({ wanted => \&wanted, no_chdir => 1 }, '.');
|
|
|
|
|
|
|
|
sub wanted
|
|
|
|
{
|
2013-05-29 22:58:43 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
# prevent corruption of git indexes by ignoring any .git/
|
2012-07-06 17:43:59 +02:00
|
|
|
if (basename($_) eq '.git')
|
2012-07-05 03:47:49 +02:00
|
|
|
{
|
|
|
|
$File::Find::prune = 1;
|
|
|
|
return;
|
|
|
|
}
|
2012-01-01 23:56:51 +01:00
|
|
|
|
2013-05-29 22:58:43 +02:00
|
|
|
return if !-f $File::Find::name || -l $File::Find::name;
|
2012-07-05 03:47:49 +02:00
|
|
|
|
|
|
|
# skip file names with binary extensions
|
|
|
|
# How are these updated? bjm 2012-01-02
|
2012-07-05 03:58:48 +02:00
|
|
|
return if ($_ =~ m/\.(ico|bin)$/);
|
2011-08-19 19:50:39 +02:00
|
|
|
|
2012-07-05 03:58:48 +02:00
|
|
|
my @lines;
|
|
|
|
tie @lines, "Tie::File", $File::Find::name;
|
2011-08-19 19:50:39 +02:00
|
|
|
|
2012-07-05 03:58:48 +02:00
|
|
|
foreach my $line (@lines)
|
|
|
|
{
|
|
|
|
|
|
|
|
# We only care about lines with a copyright notice.
|
2012-07-06 16:57:08 +02:00
|
|
|
next unless $line =~ m/$cc.*$pgdg/;
|
2012-07-05 03:47:49 +02:00
|
|
|
|
2012-07-06 18:21:43 +02:00
|
|
|
# Skip line if already matches the current year; if not
|
|
|
|
# we get $year-$year, e.g. 2012-2012
|
|
|
|
next if $line =~ m/$cc$year, $pgdg/;
|
|
|
|
|
2012-07-06 17:58:55 +02:00
|
|
|
# We process all lines because some files have copyright
|
|
|
|
# strings embedded in them, e.g. src/bin/psql/help.c
|
|
|
|
$line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
|
|
|
|
$line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
|
2012-07-05 03:47:49 +02:00
|
|
|
}
|
|
|
|
untie @lines;
|
2011-08-19 19:50:39 +02:00
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
print
|
|
|
|
"Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too.\n";
|
|
|
|
print
|
|
|
|
"Also update ./COPYRIGHT and doc/src/sgml/legal.sgml in all back branches.\n";
|