Skip to content

Commit

Permalink
Replace chomp function with platform neutral end-of-line stripping regex
Browse files Browse the repository at this point in the history
There was an uncaught issue where after the BPM images were put into
CMVC they would have their end-of-line characters converted to linux
from windows. This commit provides a platform neutral way of stipping
both line endings from the image files.

Change-Id: If13565ea85c8c929c8a91029d01602f4797ab158
RTC:210367
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/79181
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Matt Derksen <mderkse1@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
MRaybuck authored and dcrowell77 committed Jun 20, 2019
1 parent 432870d commit 2f311fe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/build/buildpnor/buildBpmFlashImages.pl
Expand Up @@ -146,14 +146,17 @@ sub generateFirmwareImage
# the payload is 16 bytes
use constant MAXIMUM_DATA_BYTES_FOR_PAYLOAD => 16;

# images use carriage return which by default chomp doesn't remove so update
# local $/ to remove that character.
local $/ = "\r\n";
# Ensure that the diamond operator ( <> ) is searching for \n to determine
# where the end of a line is in the image file.
local $/ = "\n";

my $blocks = undef;
while (my $line = <$inputFileHandle>)
{
chomp($line);
# Strip off the end-of-line character \n and optionally \r if it exists.
# Since the image files were created on a windows OS and this script
# runs on linux this will not be handled properly by chomp.
$line =~ s/\r?\n$//;

# The end of the firmware data section is marked by a 'q'
if (substr($line, 0, 1) eq "q")
Expand Down Expand Up @@ -239,6 +242,11 @@ sub generateFirmwareImage
print "number of blocks: $numberOfBlocks\n";
}

if (!defined($blocks))
{
die "Unable to process image file: $i_fileName";
}

# Write the version information to the file.
print $outputFileHandle pack("(H2)*", @version)
or die "Failed to write to output file: $imageFile";
Expand Down

0 comments on commit 2f311fe

Please sign in to comment.