From 2f311fe0914db8f9e324fc4f1d37365df416cd14 Mon Sep 17 00:00:00 2001 From: Matthew Raybuck Date: Wed, 19 Jun 2019 08:16:31 -0500 Subject: Replace chomp function with platform neutral end-of-line stripping regex 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 Reviewed-by: Matt Derksen Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/build/buildpnor/buildBpmFlashImages.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/build/buildpnor/buildBpmFlashImages.pl b/src/build/buildpnor/buildBpmFlashImages.pl index ba65dab0a..a2ad7c438 100755 --- a/src/build/buildpnor/buildBpmFlashImages.pl +++ b/src/build/buildpnor/buildBpmFlashImages.pl @@ -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") @@ -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"; -- cgit v1.2.1