2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#1077] check-hashes.sh -a now amends hashes

This commit is contained in:
Andrei Pavel 2021-07-15 15:04:16 +03:00 committed by Tomek Mrugalski
parent 338a0c6c5a
commit 7f1371ae27

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
@ -21,20 +21,34 @@ set -eu
script_path=$(cd "$(dirname "${0}")" && pwd)
cd "${script_path}/.."
amend=false
if test "${1-}" = '-a' || test "${1-}" = '--amend'; then
amend=true
fi
exit_code=0
for m in *.yang
do
hash1=$(yanglint -f yin "${m}" | openssl dgst -sha256 | sed 's/(stdin)= //')
h="hashes/$(basename "${m}").hash"
h="hashes/$(basename "${m}" .yang).hash"
if test -f "${h}"
then
hash2=$(cat "${h}")
if test "$hash1" != "$hash2"
then
exit_code=$((exit_code | 1))
printf 'hash mismatch on %s expected %s in %s\n' "${m}" "${hash1}" "${h}"
exit 1
if "${amend}"; then
printf '%s\n' "${hash1}" > "${h}"
fi
fi
else
exit_code=$((exit_code | 2))
printf 'missing hash file %s for %s\n' "${h}" "${m}"
exit 2
if "${amend}"; then
printf '%s\n' "${hash1}" > "${h}"
fi
fi
done
exit "${exit_code}"