2023-05-25 19:46:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# This function logs the archive checksum and, if provided, compares it with
|
|
|
|
# the deposited checksum
|
|
|
|
#
|
2023-05-27 16:58:28 +00:00
|
|
|
# $1 is the package name e.g. 'acorn', 'ada', 'base64' etc. See the file
|
|
|
|
# https://github.com/nodejs/node/blob/main/doc/contributing/maintaining/maintaining-dependencies.md
|
2023-05-25 19:46:07 +00:00
|
|
|
# for a complete list of package name
|
|
|
|
# $2 is the downloaded archive
|
|
|
|
# $3 (optional) is the deposited sha256 cheksum. When provided, it is checked
|
|
|
|
# against the checksum generated from the archive
|
|
|
|
log_and_verify_sha256sum() {
|
|
|
|
package_name="$1"
|
|
|
|
archive="$2"
|
|
|
|
checksum="$3"
|
|
|
|
bsd_formatted_checksum=$(sha256sum --tag "$archive")
|
|
|
|
if [ -z "$3" ]; then
|
|
|
|
echo "$bsd_formatted_checksum"
|
|
|
|
else
|
|
|
|
archive_checksum=$(sha256sum "$archive")
|
|
|
|
if [ "$checksum" = "$archive_checksum" ]; then
|
|
|
|
echo "Valid $package_name checksum"
|
|
|
|
echo "$bsd_formatted_checksum"
|
|
|
|
else
|
|
|
|
echo "ERROR - Invalid $package_name checksum:"
|
|
|
|
echo "deposited: $checksum"
|
|
|
|
echo "generated: $archive_checksum"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|