diff options
author | Stephen Cprek <smcprek@us.ibm.com> | 2015-12-10 12:56:10 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-12-17 15:56:57 -0600 |
commit | aa8d169e4569d7ecf243194e404fc6db7216cf78 (patch) | |
tree | 6dcdf5ad048b0440fd6a184ea3fac0226e4bcdd5 /src/build | |
parent | 4ea62ca340c8da822515bb4cac7d9bda3c19efa8 (diff) | |
download | talos-hostboot-aa8d169e4569d7ecf243194e404fc6db7216cf78.tar.gz talos-hostboot-aa8d169e4569d7ecf243194e404fc6db7216cf78.zip |
Fix copyright script to handle mirrored files
Change-Id: Ieaa34a747b1cfbea678586e54f8cfa950244e98b
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/22763
Tested-by: Jenkins Server
Reviewed-by: PRACHI GUPTA <pragupta@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: WILLIAM G. HOFFA <wghoffa@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/build')
-rwxr-xr-x | src/build/tools/addCopyright.pl | 55 | ||||
-rwxr-xr-x | src/build/tools/verify-commit | 13 |
2 files changed, 63 insertions, 5 deletions
diff --git a/src/build/tools/addCopyright.pl b/src/build/tools/addCopyright.pl index af97800b1..195d2c387 100755 --- a/src/build/tools/addCopyright.pl +++ b/src/build/tools/addCopyright.pl @@ -72,8 +72,11 @@ my $copyrightSymbol = ""; # set by environment variable in project env.bash my $projectName = $ENV{'PROJECT_NAME'}; -my $copyrightStr = "Contributors Listed Below - COPYRIGHT"; +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'}."/"; ## note that these use single ticks so that the escape chars are NOT evaluated yet. my $OLD_DELIMITER_END = 'IBM_PROLOG_END'; @@ -302,6 +305,12 @@ foreach ( @Files ) } while ($path ne $projectRoot); ## extract the existing copyright block + # Check if file from EKB in import tree + if (mirrored_file($_)) + { + # Remove copyright prefix as EKB does not have it + $copyrightStr =~ s/$copyrightPrefix//; + } $CopyrightBlock = extractCopyrightBlock( $_ ); ## @@ -370,6 +379,43 @@ sub usage } ####################################### +## checks if file was mirrored from EKB +## param[in] $filename to check +## returns 1 mirrored from EKB +####################################### +sub mirrored_file +{ + my $filename = shift; + + if ($filename =~ m/^$importPrefix/) + { + # Import tree expects to have EKB in the prolog + $projectName = "EKB"; + return 1; + } + return 0; +} + +####################################### +## Converts mirrored filename to match its original in EKB +## Mirroring prefixes the name with the import tree. +## param[in] $filename to check +## returns new $filename with prefix removed +####################################### +sub convert_mirror_file +{ + my $filename = shift; + + if (mirrored_file($filename)) + { + # Remove $importPrefix as EKB does not have it + $filename =~ s/^$importPrefix//; + } + + return $filename +} + +####################################### ## validate the file ## param[in] $filename to validate ## returns 0 success, nonzero failure @@ -386,7 +432,8 @@ sub validate return RC_NO_COPYRIGHT_BLOCK; } - $rc = checkCopyrightBlock( $CopyrightBlock, $filename); + my $converted_file = convert_mirror_file($filename); + $rc = checkCopyrightBlock( $CopyrightBlock, $converted_file); # good file return $rc; @@ -943,6 +990,7 @@ sub genCopyrightBlock # Get copyright contributors based on hash so no duplicates my %fileContributors = getFileContributors( $filename ); my $copyright_Contributors = ""; + foreach my $key (sort keys %fileContributors) { $copyright_Contributors .= "[+] ".$key."\n"; @@ -1036,7 +1084,8 @@ sub fillinEmptyCopyrightBlock my $copyrightYear = createYearString( $filename ); ## define the final copyright block template here. - my $IBMCopyrightBlock = genCopyrightBlock($filename,$filetype); + my $converted_file = convert_mirror_file($filename); + my $IBMCopyrightBlock = genCopyrightBlock($converted_file,$filetype); ## Modify file in place with temp file Perl Cookbook 7.8 my $savedbgfile = "$filename.fillin"; diff --git a/src/build/tools/verify-commit b/src/build/tools/verify-commit index f4218293a..0ce44a286 100755 --- a/src/build/tools/verify-commit +++ b/src/build/tools/verify-commit @@ -30,6 +30,8 @@ my $issueFound = 0; my $errorFound = 0; my $projectName = $ENV{'PROJECT_NAME'}; +# Relative path of import tree from project root +my $importPrefix = $ENV{'IMPORT_REL_PATH'}."/"; verifyPatchSet(); # Verify the patch contents. verifyCommitMsg(); # Verify the commit message. @@ -124,6 +126,13 @@ sub verifyFileLine { my ($file,$line,$count) = @_; + # Check if file was mirrored + my $mirror = 0; + if ($file =~ m/^$importPrefix/) + { + $mirror = 1; + } + # Check line length. if (length($line) > 80) { @@ -180,8 +189,8 @@ sub verifyFileLine "NOMERGE tag found."); } - # Check for "Confidential". - if ($line =~ m/Confidential/i && $projectName =~ m/HostBoot/i) + # Check for "Confidential", unless it's a mirrored commit + if ($line =~ m/Confidential/i && $projectName =~ m/HostBoot/i && !$mirror) { unless (($file =~ m/verify-commit/) || ($file =~ m/addCopyright.pl/)) |