From 1bbdeda59961f6cff5f8ccb4c32360027d86313b Mon Sep 17 00:00:00 2001 From: Karl Rister Date: Fri, 21 Jun 2024 08:20:57 -0500 Subject: [PATCH] remove extraneous information (including filenames) from the image tag calculations - most of the extraneous information is harmless, but the filenames can actually vary from one installation to another if the pathing is not the same (installed somewhere besides /opt/crucible, CI environment, etc.) - since the paths are not important, but the file contents are, they are being removed from the hash calculation to avoid simple path differences from resulting in different image tags --- rickshaw-run | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rickshaw-run b/rickshaw-run index b14f4a41..bcd20b01 100755 --- a/rickshaw-run +++ b/rickshaw-run @@ -505,17 +505,14 @@ sub calc_image_md5 { my $item; # First is the Initial hash calc on workshop reqs - $item = $item_header . "Workshop Config Output:\n" . join("", @config_analysis_output) . "\n"; - $md5->add($item); - print $tag_fh $item; + print $tag_fh $item_header . "Workshop Config Output:\n" . join("", @config_analysis_output) . "\n"; + $md5->add(join("", @config_analysis_output)); # Second is the hashing contents of files for my $file (sort @files) { debug_log(sprintf "calc_image_md5(): adding '%s' to hash\n", $file); - $item = $item_header . "File: " . $file . "\nFile Contents:\n"; - $md5->add($item); - print $tag_fh $item; + print $tag_fh $item_header . "File: " . $file . "\nFile Contents:\n"; open(my $fh, $file); while(<$fh>) { @@ -526,14 +523,13 @@ sub calc_image_md5 { binmode($fh); $md5->addfile($fh); - $md5->add("\n"); close($fh); } my $base_hash = $md5->hexdigest; - print $tag_fh $item_header . "Hash: " . $base_hash . "\n"; - close($tag_fh); my $full_hash = $base_hash . "_" . $arch_suffix; + print $tag_fh $item_header . "Hash: " . $full_hash . "\n"; + close($tag_fh); debug_log(sprintf "calc_image_md5(): returning '%s'\n", $full_hash); return $full_hash;