mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[#1077] check-hashes.sh -a now amends hashes
This commit is contained in:
committed by
Tomek Mrugalski
parent
338a0c6c5a
commit
7f1371ae27
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/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
|
# 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
|
# 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)
|
script_path=$(cd "$(dirname "${0}")" && pwd)
|
||||||
cd "${script_path}/.."
|
cd "${script_path}/.."
|
||||||
|
|
||||||
|
amend=false
|
||||||
|
if test "${1-}" = '-a' || test "${1-}" = '--amend'; then
|
||||||
|
amend=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit_code=0
|
||||||
for m in *.yang
|
for m in *.yang
|
||||||
do
|
do
|
||||||
hash1=$(yanglint -f yin "${m}" | openssl dgst -sha256 | sed 's/(stdin)= //')
|
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}"
|
if test -f "${h}"
|
||||||
then
|
then
|
||||||
hash2=$(cat "${h}")
|
hash2=$(cat "${h}")
|
||||||
if test "$hash1" != "$hash2"
|
if test "$hash1" != "$hash2"
|
||||||
then
|
then
|
||||||
|
exit_code=$((exit_code | 1))
|
||||||
printf 'hash mismatch on %s expected %s in %s\n' "${m}" "${hash1}" "${h}"
|
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
|
fi
|
||||||
else
|
else
|
||||||
|
exit_code=$((exit_code | 2))
|
||||||
printf 'missing hash file %s for %s\n' "${h}" "${m}"
|
printf 'missing hash file %s for %s\n' "${h}" "${m}"
|
||||||
exit 2
|
if "${amend}"; then
|
||||||
|
printf '%s\n' "${hash1}" > "${h}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
exit "${exit_code}"
|
||||||
|
Reference in New Issue
Block a user