summaryrefslogtreecommitdiffstats
path: root/src/build/tools/addCopyright
diff options
context:
space:
mode:
authorZane Shelley <zshelle@us.ibm.com>2016-08-30 11:53:48 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-09-02 14:40:31 -0400
commit3eb247207ba4a30e21f472492398f9404716487a (patch)
tree50e0fd5bd68d7fb75da2b0e8d33bad92d19e154e /src/build/tools/addCopyright
parent686a247c821239799a1b436d46b083672ff391d0 (diff)
downloadtalos-hostboot-3eb247207ba4a30e21f472492398f9404716487a.tar.gz
talos-hostboot-3eb247207ba4a30e21f472492398f9404716487a.zip
restored legacy copyright year support in addCopyright tool
Change-Id: I0f9b5bbae4143d1140e56e00ee326e3d2fa45373 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/28990 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/build/tools/addCopyright')
-rwxr-xr-xsrc/build/tools/addCopyright78
1 files changed, 31 insertions, 47 deletions
diff --git a/src/build/tools/addCopyright b/src/build/tools/addCopyright
index 356d47666..324c0e707 100755
--- a/src/build/tools/addCopyright
+++ b/src/build/tools/addCopyright
@@ -6,7 +6,7 @@
#
# OpenPOWER HostBoot Project
#
-# Contributors Listed Below - COPYRIGHT 2011,2014
+# Contributors Listed Below - COPYRIGHT 2011,2016
# [+] International Business Machines Corp.
# [+] Google Inc.
#
@@ -30,7 +30,7 @@
# Author: Mark Jerde (mjerde@us.ibm.com) #
# Date: Fri Mar 19 17:40:32 2010 UTC #
# #
-# addCopyright will automatically insert appropriate copyright statements #
+# addCopyright will automatically insert appropriate copyright statements #
# in source files following the IBM copyright guidelines (and templates) #
# referenced below : #
# FSP ClearCase Architecture #
@@ -47,8 +47,8 @@
# make clean # remove autogenerated files #
# find src -path 'src/build' -prune -o ! -type d -print | tr '\n' ' ' #
# #
-# addCopyright does not support piping, but you can send these #
-# to a file, add "addCopyright update" to the beginning of the line, #
+# addCopyright does not support piping, but you can send these #
+# to a file, add "addCopyright update" to the beginning of the line, #
# and run the file to update all #
###############################################################################
@@ -72,8 +72,6 @@ my $copyrightSymbol = "";
# set by environment variable in project env.bash
my $projectName = $ENV{'PROJECT_NAME'};
-my $copyrightPrefix = "Contributors Listed Below - ";
-my $copyrightStr = $copyrightPrefix."COPYRIGHT";
my $projectRoot = $ENV{'PROJECT_ROOT'};
# Relative path of import tree from project root
my $importPrefix = $ENV{'IMPORT_REL_PATH'}."/";
@@ -128,7 +126,7 @@ my $opt_logfile = "";
my $DelimiterBegin = "";
my $CopyrightBlock = "";
my $DelimiterEnd = "";
-my $CopyRightString = "";
+my @CopyRightYears = ();
my $copyright_check = 0;
my $TempFile = "";
@@ -223,7 +221,7 @@ foreach ( @Files )
$DelimiterBegin = "";
$CopyrightBlock = "";
$DelimiterEnd = "";
- $CopyRightString = "";
+ @CopyRightYears = ();
$rc = 0;
@@ -593,14 +591,16 @@ sub extractCopyrightBlock
# Critical to remove newline for validate step
chomp($prolog);
- ## As long as we're here extract the copyright string within the block
- ## and save it to a global var
- $CopyRightString = $1 if ( $prolog =~ /(^.*$copyrightStr.*$)/m );
+ # While we have the current prolog, extract the current copyright years.
+ # Note that we must use the common word 'COPYRIGHT' to find the copyright
+ # line because some older prologs (i.e. CMVC prologs), do not have the same
+ # text that is inserted into newer prologs.
+ my $tmp = (grep(/COPYRIGHT/, split('\n', $prolog)))[0];
+ @CopyRightYears = ( $tmp =~ /([0-9]{4})/g ) if ( $tmp );
return $prolog;
}
-
#######################################
## Check Copyright Block
##
@@ -651,26 +651,17 @@ sub checkCopyrightBlock
return 0;
}
-sub createYearString
+sub createYearString($)
{
- my ( $filename ) = @_;
- my $yearstr = "";
- my @years = ();
-
- ## Analyse the CopyRightString for begin and end years - this is for old
- ## files that are checked in from FSP. In this case the earliest
- ## year will be before it was checked into git . We have to construct
- ## a yearstring based on the earliest year.
- if ( $CopyRightString =~ m/$copyrightStr/ )
- {
- @years = ( $CopyRightString =~ /([0-9]{4})/g );
- }
- push @years, $ReleaseYear; # Add the current year.
+ my ( $filename ) = @_;
+
+ # The list of years starts with the years in the current prolog and the
+ # current release year.
+ my @years = ( @CopyRightYears, $ReleaseYear );
- ##
## Make a call to git to find the earliest commit date of the file
## new files will not have a log, so the "git log" call above will
- # return nothing.
+ ## return nothing.
## Push any year we find onto the @years array
my $cmd = "git log -- $filename | grep Date: | tail -n 1";
## print "run $cmd\n";
@@ -682,26 +673,19 @@ sub createYearString
push @years, $logstrings[5] ;
}
- ## sort and remove duplicates by loading it into a hash
- my %temphash;
- @temphash{@years} = ();
- my @outyears = sort keys %temphash;
+ # Get a unique list of years and sort the list.
+ my %tmp = map { $_, 1 } @years;
+ @years = sort( keys %tmp );
if ( $opt_debug )
- { print STDERR __LINE__, ": years: ", join( ',', @outyears ), "\n"; }
+ { print STDERR __LINE__, ": years: ", join( ',', @years ), "\n"; }
- ## lowest year, which may be the only one.
- $yearstr = $outyears[0] ;
+ # Get the fist and last years in the list.
+ my $year_str = "";
+ $year_str = shift @years;
+ $year_str .= ',' . pop @years if ( @years );
- ## if there is more than one index then also output the highest one.
- if ( $#outyears > 0 )
- {
- # A '-' is preferred but CMVC uses ',' so using ','.
- $yearstr .= ",$outyears[$#outyears]";
- }
-
-
- return $yearstr;
+ return $year_str;
}
###################################
@@ -940,7 +924,9 @@ sub genCopyrightBlock
{
my ($filename, $filetype) = @_;
- my $copyrightYear = createYearString( $filename );
+ # Get the copyright data that is required in the license file.
+ my $copyrightStr = "Contributors Listed Below - COPYRIGHT";
+ my $copyrightYear = createYearString( $filename );
# Get copyright contributors based on hash so no duplicates
my %fileContributors = getFileContributors( $filename );
@@ -1036,8 +1022,6 @@ sub fillinEmptyCopyrightBlock
{
my ( $filename, $filetype ) = @_;
- my $copyrightYear = createYearString( $filename );
-
## define the final copyright block template here.
my $IBMCopyrightBlock = genCopyrightBlock($filename,$filetype);
OpenPOWER on IntegriCloud