rt 4.2.13 ticket#13852
[freeside.git] / rt / devel / tools / license_tag
index de3bd3b..b66a753 100644 (file)
@@ -5,7 +5,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
 # those contributions and any derivatives thereof.
 #
 # END BPS TAGGED BLOCK }}}
+use strict;
+use warnings;
 my $LICENSE  = <<'EOL';
 
 COPYRIGHT:
 
-This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
                                          <sales@bestpractical.com>
 
 (Except where explicitly superseded by other copyright notices)
@@ -101,19 +103,22 @@ use File::Find;
 my @MAKE = qw(Makefile);
 
 File::Find::find({ no_chdir => 1, wanted => \&tag_pm}, 'lib');
-File::Find::find({ no_chdir => 1, wanted => \&tag_mason}, 'share/html');
-File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'sbin');
-File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'bin');
-File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'etc/upgrade');
-File::Find::find({ no_chdir => 1, wanted => \&tag_script}, 'devel/tools');
-tag_makefile ('Makefile.in');
+for my $masondir (qw( html share/html )) {
+    next unless -d $masondir;
+    File::Find::find({ no_chdir => 1, wanted => \&tag_mason}, $masondir);
+}
+for my $bindir (qw( sbin bin etc/upgrade devel/tools )) {
+    next unless -d $bindir;
+    File::Find::find({ no_chdir => 1, wanted => \&tag_script}, $bindir);
+}
+tag_makefile ('Makefile.in') if -f 'Makefile.in';
 tag_makefile ('README');
 
 
 sub tag_mason {
         my $pm = $_;
         return unless (-f $pm);
-        return if $pm =~ /images/ || $pm =~ /\.(?:png|jpe?g|gif)$/;
+        return if $pm =~ /\.(?:png|jpe?g|gif)$/;
         open( FILE, '<', $pm ) or die "Failed to open $pm";
         my $file = (join "", <FILE>);
         close (FILE);
@@ -123,16 +128,16 @@ sub tag_mason {
         my $pmlic = $LICENSE;
         $pmlic =~ s/^/%# /mg;
         $pmlic =~ s/\s*$//mg;
-        if ($file =~ /^%# BEGIN BPS TAGGED BLOCK {{{/ms) {
+        if ($file =~ /^%# BEGIN BPS TAGGED BLOCK \{\{\{/ms) {
                 print "has license section";
-             $file =~ s/^%# BEGIN BPS TAGGED BLOCK {{{(.*?)%# END BPS TAGGED BLOCK }}}/%# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n%# END BPS TAGGED BLOCK }}}/ms;
+             $file =~ s/^%# BEGIN BPS TAGGED BLOCK \{\{\{(.*?)%# END BPS TAGGED BLOCK \}\}\}/%# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n%# END BPS TAGGED BLOCK }}}/ms;
 
 
         } else {
                 print "no license section";
              $file ="%# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n%# END BPS TAGGED BLOCK }}}\n". $file;
         }
-        $file =~ s/%# END BPS TAGGED BLOCK }}}(\n+)/%# END BPS TAGGED BLOCK }}}\n/mg;
+        $file =~ s/%# END BPS TAGGED BLOCK \}\}\}(\n+)/%# END BPS TAGGED BLOCK }}}\n/mg;
         print "\n";
 
 
@@ -156,16 +161,16 @@ sub tag_makefile {
         my $pmlic = $LICENSE;
         $pmlic =~ s/^/# /mg;
         $pmlic =~ s/\s*$//mg;
-        if ($file =~ /^# BEGIN BPS TAGGED BLOCK {{{/ms) {
+        if ($file =~ /^# BEGIN BPS TAGGED BLOCK \{\{\{/ms) {
                 print "has license section";
-             $file =~ s/^# BEGIN BPS TAGGED BLOCK {{{(.*?)# END BPS TAGGED BLOCK }}}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}/ms;
+             $file =~ s/^# BEGIN BPS TAGGED BLOCK \{\{\{(.*?)# END BPS TAGGED BLOCK \}\}\}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}/ms;
 
 
         } else {
                 print "no license section";
              $file ="# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}\n". $file;
         }
-        $file =~ s/# END BPS TAGGED BLOCK }}}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg;
+        $file =~ s/# END BPS TAGGED BLOCK \}\}\}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg;
         print "\n";
 
 
@@ -180,7 +185,7 @@ sub tag_makefile {
 
 sub tag_pm {
         my $pm = $_;
-        next unless $pm =~ /\.pm/s;
+        return unless $pm =~ /\.pm/s;
         open( FILE, '<', $pm ) or die "Failed to open $pm";
         my $file = (join "", <FILE>);
         close (FILE);
@@ -190,16 +195,16 @@ sub tag_pm {
         my $pmlic = $LICENSE;
         $pmlic =~ s/^/# /mg;
         $pmlic =~ s/\s*$//mg;
-        if ($file =~ /^# BEGIN BPS TAGGED BLOCK {{{/ms) {
+        if ($file =~ /^# BEGIN BPS TAGGED BLOCK \{\{\{/ms) {
                 print "has license section";
-             $file =~ s/^# BEGIN BPS TAGGED BLOCK {{{(.*?)# END BPS TAGGED BLOCK }}}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}/ms;
+             $file =~ s/^# BEGIN BPS TAGGED BLOCK \{\{\{(.*?)# END BPS TAGGED BLOCK \}\}\}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}/ms;
 
 
         } else {
                 print "no license section";
              $file ="# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}\n". $file;
         }
-        $file =~ s/# END BPS TAGGED BLOCK }}}(\n+)/# END BPS TAGGED BLOCK }}}\n\n/mg;
+        $file =~ s/# END BPS TAGGED BLOCK \}\}\}(\n+)/# END BPS TAGGED BLOCK }}}\n\n/mg;
         print "\n";
 
 
@@ -224,9 +229,9 @@ sub tag_script {
         my $pmlic = $LICENSE;
         $pmlic =~ s/^/# /msg;
         $pmlic =~ s/\s*$//mg;
-        if ($file =~ /^# BEGIN BPS TAGGED BLOCK {{{/ms) {
+        if ($file =~ /^# BEGIN BPS TAGGED BLOCK \{\{\{/ms) {
                 print "has license section";
-             $file =~ s/^# BEGIN BPS TAGGED BLOCK {{{(.*?)# END BPS TAGGED BLOCK }}}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}/ms;
+             $file =~ s/^# BEGIN BPS TAGGED BLOCK \{\{\{(.*?)# END BPS TAGGED BLOCK \}\}\}/# BEGIN BPS TAGGED BLOCK {{{\n$pmlic\n# END BPS TAGGED BLOCK }}}/ms;
 
 
         } else {
@@ -238,7 +243,7 @@ sub tag_script {
 
                 }
         }
-        $file =~ s/# END BPS TAGGED BLOCK }}}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg;
+        $file =~ s/# END BPS TAGGED BLOCK \}\}\}(\n+)/# END BPS TAGGED BLOCK }}}\n/mg;
         print "\n";
 
 
@@ -252,7 +257,7 @@ sub another_license {
     my $name = shift;
     my $file = shift;
 
-    return 1 if ($name =~ /(?:FCKEditor|scriptaculous|superfish|tablesorter|farbtastic)/i);
+    return 1 if ($name =~ /(?:ckeditor|scriptaculous|superfish|tablesorter|farbtastic)/i);
 
     return 0 if $file =~ /Copyright\s+\(c\)\s+\d\d\d\d-\d\d\d\d Best Practical Solutions/i;
     return 1 if $file =~ /\b(copyright|GPL|Public Domain)\b/i; # common