From df2bf0250c3dc29b33ecf988ae3277dffdaa3db1 Mon Sep 17 00:00:00 2001 From: Josh Curtiss Date: Thu, 11 Sep 2025 10:04:30 -0500 Subject: [PATCH] fix: Improve build hash to be consistent between systems The build hash was including some files that were not intended, and not sorting the files in a consistent way, so this led to inconsistent hashes between systems. Both `exp` and `.github` directories were allowed to be included in the hash calculation, even though these directories are not part of the live code. Incidentally, different locales would handle sorting `.github` differently, leading to different hashes. So, we prune those directories from the file search, and we set `LC_ALL=C` to ensure consistent sorting. Additionally, we were not considering symlinks when identifying files and directories to include in the hash calculation. This wasn't causing a problem but it could result in unchanged hashes even when symlinks are changed or omitted. So, we improve the file search to include symlinks in the hash calculation. --- init.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/init.sh b/init.sh index 273a9e7..2dacadc 100755 --- a/init.sh +++ b/init.sh @@ -37,8 +37,14 @@ function yorn() { function display_version() { echo -n "Docker Host version $version build " - find "$dir" -type f \( -name '*.sh' -o -name '*.yml' \) -not -path '*/node_modules/*' | \ - sort | xargs cat | sha256sum | cut -c1-8 + # To calculate a build hash, we hash all of the sorted files according to these rules: + # - Exclude node_modules, exp, and hidden files/directories (using -prune) + # - Include symlinks, both files (-type f and -type l) and directories (-L) + # - Include only .sh and .yml files + find -L "$dir" \ + \( -path '*/node_modules' -o -path '*/exp' -o -path '*/.*' \) -prune -o \ + \( \( -type f -o -type l \) -a \( -name '*.sh' -o -name '*.yml' \) \) -print0 | \ + LC_ALL=C sort -z | xargs -0 cat | sha256sum | cut -c1-8 } # Title for the script