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.
|
|
|
|
#
|
2012-01-01 23:56:51 +01:00
|
|
|
# Copyright (c) 2011-2012, PostgreSQL Global Development Group
|
2011-08-19 19:50:39 +02:00
|
|
|
#
|
|
|
|
# src/tools/copyright.pl
|
|
|
|
#################################################################
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use File::Find;
|
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';
|
2011-08-19 23:45:10 +02:00
|
|
|
my $cc = 'Copyright \(c\) ';
|
2011-08-19 19:50:39 +02:00
|
|
|
# year-1900 is what localtime(time) puts in element 5
|
|
|
|
my $year = 1900 + ${[localtime(time)]}[5];
|
|
|
|
|
|
|
|
print "Using current year: $year\n";
|
|
|
|
|
|
|
|
find({wanted => \&wanted, no_chdir => 1}, '.');
|
|
|
|
|
|
|
|
sub wanted {
|
2012-01-02 04:27:27 +01:00
|
|
|
# prevent corruption of git indexes by ignoring any .git/
|
2012-01-02 01:47:24 +01:00
|
|
|
if ($_ eq '.git')
|
2012-01-01 23:56:51 +01:00
|
|
|
{
|
2012-01-01 23:59:44 +01:00
|
|
|
$File::Find::prune = 1;
|
|
|
|
return;
|
2012-01-01 23:56:51 +01:00
|
|
|
}
|
|
|
|
|
2011-08-20 01:31:12 +02:00
|
|
|
return if ! -f $File::Find::name || -l $File::Find::name;
|
2012-01-02 14:48:59 +01:00
|
|
|
# skip file names with binary extensions
|
|
|
|
# How are these updated? bjm 2012-01-02
|
2012-01-02 01:36:10 +01:00
|
|
|
return if ($_ =~ m/\.(ico|bin)$);
|
2011-08-19 19:50:39 +02:00
|
|
|
|
2011-08-20 01:31:12 +02:00
|
|
|
my @lines;
|
|
|
|
tie @lines, "Tie::File", $File::Find::name;
|
2011-08-19 19:50:39 +02:00
|
|
|
|
2011-08-20 01:31:12 +02:00
|
|
|
foreach my $line (@lines) {
|
2011-08-19 19:50:39 +02:00
|
|
|
# We only care about lines with a copyright notice.
|
|
|
|
next unless $line =~ m/$cc.*$pgdg/;
|
|
|
|
# We stop when we've done one substitution. This is both for
|
|
|
|
# efficiency and, at least in the case of this program, for
|
|
|
|
# correctness.
|
|
|
|
last if $line =~ m/$cc.*$year.*$pgdg/;
|
|
|
|
last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
|
|
|
|
last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
|
|
|
|
}
|
2011-08-20 01:31:12 +02:00
|
|
|
untie @lines;
|
2011-08-19 19:50:39 +02:00
|
|
|
}
|
|
|
|
|
2012-07-03 18:01:38 +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";
|
2011-08-19 19:50:39 +02:00
|
|
|
|