summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-08-10 14:50:32 +0100
committerLeah Rowe <leah@libreboot.org>2025-08-10 14:50:32 +0100
commit41945a222005d94e0e51adb1ba8ceb869b110bae (patch)
treedbd75d8eb6fbde99ff53ae087d4dfd739f685299 /include
parentd44c143846c15ba2032340db085f2ec31365182b (diff)
tree.sh: Delete files *before* updating hashesHEADmaster
The current logic deletes old project files e.g. sources, but *after* updating the project hash. This means that if a deletion fails, and the directory is still there (e.g. src/coreboot/default/) afterward, it's now a tainted archive, yet the hash has been updated, so subsequent runs of the build system will cause unknown errors. This patch fixes that, by first copying the new hash to a temporary file. *Then*, deletions are handled, and the final hash file is updated afterward. The code is now a bit more bloated as a result, but this will reduce the risk of tainted sources being handled under fault conditions. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/tree.sh13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/tree.sh b/include/tree.sh
index ef1e4caa..5edddf23 100644
--- a/include/tree.sh
+++ b/include/tree.sh
@@ -177,10 +177,15 @@ delete_old_project_files()
{
project_up_to_date hash "$tree" badhash "$datadir" "$configdir/$tree" \
"$mdir" || x_ rm -Rf "src/$project/$tree" "elf/$project/$tree"; :
+ x_ cp "$xbtmp/new.hash" "$XBMK_CACHE/hash/$project$tree"
- singletree "$project" || [ -z "$target" ] || [ "$target" = "$tree" ] \
- || project_up_to_date tghash "$target" badtghash \
+ singletree "$project" && return 0
+ [ -z "$target" ] && return 0
+ [ "$target" = "$tree" ] && return 0
+
+ project_up_to_date tghash "$target" badtghash \
"$configdir/$target" || x_ rm -Rf "elf/$project/$tree/$target"; :
+ x_ cp "$xbtmp/new.hash" "$XBMK_CACHE/tghash/$project$target"
}
project_up_to_date()
@@ -207,8 +212,8 @@ project_up_to_date()
[ -f "$XBMK_CACHE/$hashdir/$project$hashname" ] || \
eval "$badhashvar=\"y\""
- printf "%s\n" "$hash" > "$XBMK_CACHE/$hashdir/$project$hashname" || \
- err "!mk $XBMK_CACHE/$hashdir/$project$hashname"
+ printf "%s\n" "$hash" > "$xbtmp/new.hash" || \
+ err "!mkhash $xbtmp/new.hash ($hashdir $hashname $badhashvar)"
eval "[ \"\$$badhashvar\" = \"y\" ] && return 1"; :
}