Skip to content

Commit

Permalink
Use perl for sha1sum
Browse files Browse the repository at this point in the history
  • Loading branch information
cfconrad committed Jul 17, 2019
1 parent b85b5da commit a51e683
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/serial_terminal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use Exporter;
use bmwqemu ();
use version_utils qw(is_sle is_leap);
use Mojo::Util qw(b64_encode b64_decode sha1_sum trim);
use Mojo::File 'path';
use File::Basename;
use File::Temp 'tempfile';

Expand Down Expand Up @@ -101,6 +102,11 @@ sub serial_term_prompt {
return $serial_term_prompt;
}

sub local_sha1sum {
my $filename = shift;

return sha1_sum(path($filename)->slurp());
}

=head2 download_file
Expand Down Expand Up @@ -149,7 +155,7 @@ sub download_file {
}
close($fh);
my $sha1_remote = script_output("sha1sum $result_file | cut -d ' ' -f 1", undef, quiet => 1);
my $sha1 = trim(`sha1sum $src | cut -d ' ' -f 1`);
my $sha1 = file_sha1sum($src);
die("Failed to transfer file $src - final checksum mismatch") if ($sha1_remote ne $sha1);
assert_script_run("mv $result_file '$dst'", quiet => 1);
assert_script_run("rmdir $tmpdir", quiet => 1);
Expand Down Expand Up @@ -193,8 +199,7 @@ sub upload_file {
} while ($sha1 ne $sha1_remote);
print $fh b64_decode($b64);
}
my $sha1 = trim(`sha1sum $tmpfilename 2>&1 | cut -d ' ' -f 1`);
croak ("Failed to run sha1sum on $tmpfilename\noutput:$sha1") if ($?);
my $sha1 = file_sha1sum($tmpfilename);
my $sha1_remote = script_output("sha1sum $src | cut -d ' ' -f 1", undef, quiet => 1);
die("Failed to upload file $src - final checksum mismatch") if ($sha1_remote ne $sha1);
system('mkdir -p ulogs/') == 0 or die('Failed to create ulogs/ directory');
Expand Down

0 comments on commit a51e683

Please sign in to comment.