diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
commit | 46651ce6fe013220ed397add242004d764fc0153 (patch) | |
tree | 6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/tools/copyright.pl | |
parent | Initial commit. (diff) | |
download | postgresql-14-46651ce6fe013220ed397add242004d764fc0153.tar.xz postgresql-14-46651ce6fe013220ed397add242004d764fc0153.zip |
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/copyright.pl')
-rwxr-xr-x | src/tools/copyright.pl | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/tools/copyright.pl b/src/tools/copyright.pl new file mode 100755 index 0000000..a55e643 --- /dev/null +++ b/src/tools/copyright.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl +################################################################# +# copyright.pl -- update copyright notices throughout the source tree, idempotently. +# +# Copyright (c) 2011-2021, PostgreSQL Global Development Group +# +# src/tools/copyright.pl +# +# FYI, Tie adds a trailing newline on the last line if missing. +################################################################# + +use strict; +use warnings; + +use File::Find; +use File::Basename; +use Tie::File; + +my $pgdg = 'PostgreSQL Global Development Group'; +my $cc = 'Copyright \(c\)'; +my $ccliteral = 'Copyright (c)'; + +# 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 +{ + + # prevent corruption of git indexes by ignoring any .git/ + if (basename($_) eq '.git') + { + $File::Find::prune = 1; + return; + } + + return if !-f $File::Find::name || -l $File::Find::name; + + # skip file names with binary extensions + # How are these updated? bjm 2012-01-02 + return if ($_ =~ m/\.(ico|bin|po|key)$/); + + my @lines; + tie @lines, "Tie::File", $File::Find::name; + + foreach my $line (@lines) + { + + # We only care about lines with a copyright notice. + next unless $line =~ m/$cc.*$pgdg/i; + + # 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/i; + + # 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})-\d{4}, $pgdg/$ccliteral $1-$year, $pgdg/i; + $line =~ s/$cc (\d{4}), $pgdg/$ccliteral $1-$year, $pgdg/i; + } + untie @lines; + return; +} + +print "Manually update:\n"; +print " ./doc/src/sgml/legal.sgml in head and back branches\n"; +print " ./COPYRIGHT in back branches\n"; |