extract_utils: Use shasum on macOS

macOS doesn't have sha1sum but instead shasum, so use that
if 'uname -s' returns Darwin

Change-Id: I1ab8721327a561e8df78562bbc0b12e884cc4a93
This commit is contained in:
Rashed Abdel-Tawab 2016-11-23 23:00:37 -05:00 committed by Rashed Abdel-Tawab
parent 73a3965995
commit 5b38c4fb34

View file

@ -858,13 +858,21 @@ function extract() {
if [ ! -f "$DEST" ]; then
KEEP="1"
else
local DEST_HASH=$(sha1sum "$DEST" | awk '{print $1}' )
if [ "$(uname)" == "Darwin" ]; then
local DEST_HASH=$(shasum "$DEST" | awk '{print $1}' )
else
local DEST_HASH=$(sha1sum "$DEST" | awk '{print $1}' )
fi
if [ "$DEST_HASH" != "$HASH" ]; then
KEEP="1"
fi
fi
if [ "$KEEP" = "1" ]; then
local TMP_HASH=$(sha1sum "$TMP" | awk '{print $1}' )
if [ "$(uname)" == "Darwin" ]; then
local TMP_HASH=$(shasum "$TMP" | awk '{print $1}' )
else
local TMP_HASH=$(sha1sum "$TMP" | awk '{print $1}' )
fi
if [ "$TMP_HASH" = "$HASH" ]; then
printf ' + (keeping pinned file with hash %s)\n' "$HASH"
cp -p "$TMP" "$DEST"