diff options
author | Leah Rowe <leah@libreboot.org> | 2025-10-04 09:56:42 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-10-04 09:58:24 +0100 |
commit | 8969cc734f8f9855fa4bbfa92c18224adb9e5ddc (patch) | |
tree | cde221495640dfb1d782333e7311dd15b809cdd1 | |
parent | e9a910b33c7837b4b868e3abda18eb4810df7f02 (diff) |
xbmk: use sbase sha512sum, not host sha512sum
the --status flag seems to be a GNUism
as stated in the previous commit, i import sbase
suckless now, so as to have a consistent implementation
of sha512sum.
this ensures that its output is reliable, when i'm using
the output of this command within backticks.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r-- | include/get.sh | 3 | ||||
-rw-r--r-- | include/init.sh | 3 | ||||
-rw-r--r-- | include/lib.sh | 7 | ||||
-rw-r--r-- | include/tree.sh | 8 | ||||
-rw-r--r-- | include/vendor.sh | 10 |
5 files changed, 24 insertions, 7 deletions
diff --git a/include/get.sh b/include/get.sh index a0f7fb20..3c30b6d3 100644 --- a/include/get.sh +++ b/include/get.sh @@ -313,7 +313,8 @@ bad_checksum() return 0 fi - csum="$(x_ sha512sum "$2" | awk '{print $1}')" || \ + build_sbase + csum="$(x_ "$sha512sum" "$2" | awk '{print $1}')" || \ err "!sha512 '$2' $1" bad_checksum "$@" if [ "$csum" = "$1" ]; then diff --git a/include/init.sh b/include/init.sh index 0fd758c2..72af26c3 100644 --- a/include/init.sh +++ b/include/init.sh @@ -35,11 +35,14 @@ checkvarschk="" is_child="" basetmp="" +sha512sum="util/sbase/sha512sum" + xbmk_init() { xbmkpwd="`pwd || err "Cannot generate PWD"`" || err "!" xbmk_init "$@" xbmklock="$xbmkpwd/lock" basetmp="$xbmkpwd/xbmkwd" + sha512sum="$xbmkpwd/util/sbase/sha512sum" if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then x_ xbmkpkg "$@" diff --git a/include/lib.sh b/include/lib.sh index c888200c..3d205fa9 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -162,6 +162,13 @@ unpad_one_byte() x_ mv "$unpaddedfile" "$1" } +build_sbase() +{ + if [ ! -f "$sha512sum" ]; then + x_ make -C "$xbmkpwd/util/sbase" + fi +} + fx_() { xchk fx_ "$@" diff --git a/include/tree.sh b/include/tree.sh index 2b6c4b7f..254f738d 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -442,11 +442,13 @@ project_up_to_date() "$@" fi - fx_ "x_ sha512sum" find "$@" -type f -not -path "*/.git*/*" | awk \ - '{print $1}' > "$xbtmp/tmp.hash" || err "!h $project $hashdir" \ + build_sbase + fx_ "x_ util/sbase/sha512sum" find "$@" -type f -not -path \ + "*/.git*/*" | awk '{print $1}' > "$xbtmp/tmp.hash" || \ + err "!h $project $hashdir" \ "project_up_to_date" "$hashdir" "$hashname" "$badhashvar" "$@" - hash="$(x_ sha512sum "$xbtmp/tmp.hash" | awk '{print $1}' || \ + hash="$(x_ "$sha512sum" "$xbtmp/tmp.hash" | awk '{print $1}' || \ err)" || err "$hashname: Can't read sha512 of '$xbtmp/tmp.hash'" \ "project_up_to_date" "$hashdir" "$hashname" "$badhashvar" "$@" diff --git a/include/vendor.sh b/include/vendor.sh index 99884bfb..a0806dd8 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -602,11 +602,13 @@ prep() mksha512() { + build_sbase + if [ "${1%/*}" != "$1" ]; then x_ cd "${1%/*}" fi - x_ sha512sum ./"${1##*/}" >> "$2" || \ + x_ "$sha512sum" ./"${1##*/}" >> "$2" || \ err "!sha512sum \"$1\" > \"$2\"" "mksha512" "$@" } @@ -711,11 +713,13 @@ vfile() # must be called from a subshell check_vendor_hashes() { + build_sbase + x_ cd "$tmpromdir" if [ "$has_hashes" != "n" ] && [ "$nuke" != "nuke" ]; then - sha512sum --status -c "$hashfile" || x_ sha1sum --status \ - -c "$hashfile" + ( x_ "$sha512sum" -c "$hashfile" ) || \ + x_ sha1sum -c "$hashfile" fi x_ rm -f "$hashfile" |