Commit 328ee5e6 authored by Jakub Jirutka's avatar Jakub Jirutka

githooks: fix checksum comparison in pre-commit hook

The previous method didn't work for larger files.
parent 65010e4e
......@@ -57,22 +57,23 @@ check_local_sources() {
local apkbuild="$1"
local startdir="${apkbuild%/*}"
local status=0
local checksum content filename line sources
local checksum_act checksum_exp content filename line sources
sources=$(abuild_local_sources "$apkbuild")
for line in $sources; do
filename=${line%%:*}
checksum=${line#*:}
checksum_exp=${line#*:}
content=$(git show ":$startdir/$filename" 2>/dev/null) || {
if ! git cat-file -e ":$startdir/$filename" 2>/dev/null; then
error "$startdir: missing file \"$filename\""
status=1
continue
}
[ "$(printf '%s\n' "$content" | sha512sum)" = "$checksum -" ] || {
fi
checksum_act=$(git show ":$startdir/$filename" | sha512sum)
if [ "$checksum_act" != "$checksum_exp -" ]; then
error "$startdir: bad checksum for file \"$filename\" (hint: run abuild checksum)"
status=1
}
fi
done
return $status
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment