From 62feaab756de692118c5ce0e81cf5298ae2af4b9 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer <mschiffer@universe-factory.net> Date: Tue, 13 May 2014 18:34:25 +0200 Subject: [PATCH] Add "portable" md5sum and sha512sum scripts --- Makefile | 5 ++++- scripts/md5sum.sh | 18 ++++++++++++++++++ scripts/sha512sum.sh | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 scripts/md5sum.sh create mode 100755 scripts/sha512sum.sh diff --git a/Makefile b/Makefile index b20da8f16..3634d9705 100644 --- a/Makefile +++ b/Makefile @@ -213,6 +213,9 @@ dirclean: FORCE export GLUON_GENERATE := $(GLUONDIR)/scripts/generate.sh export GLUON_CONFIGURE := $(GLUONDIR)/scripts/configure.pl +export MD5SUM := $(GLUONDIR)/scripts/md5sum.sh +export SHA512SUM := $(GLUONDIR)/scripts/sha512sum.sh + download: FORCE +$(SUBMAKE) tools/download @@ -342,7 +345,7 @@ manifest: FORCE [ -e "$$file" ] && echo \ '$(GLUON_$(profile)_MODEL_$(model))' \ "$$(echo "$$file" | sed -n -r -e 's/^gluon-$(call regex-escape,$(GLUON_SITE_CODE))-(.*)-$(call regex-escape,$(GLUON_$(profile)_MODEL_$(model)))-sysupgrade\.bin$$/\1/p')" \ - "$$(sha512sum "$$file" | awk '{print $$1}')" \ + "$$($(SHA512SUM) "$$file")" \ "$$file" && break; \ done; \ ) \ diff --git a/scripts/md5sum.sh b/scripts/md5sum.sh new file mode 100755 index 000000000..616005836 --- /dev/null +++ b/scripts/md5sum.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +check_command() { + which $1 >/dev/null 2>&1 +} + +if check_command md5sum; then + ret="$(md5sum "$@")" +elif check_command md5; then + ret="$(md5 -q "$@")" +else + echo "$0: no suitable md5sum implementation was found" >&1 + exit 1 +fi + +[ "$?" -eq 0 ] || exit 1 + +echo "$ret" | awk '{ print $1 }' diff --git a/scripts/sha512sum.sh b/scripts/sha512sum.sh new file mode 100755 index 000000000..921e5c6c6 --- /dev/null +++ b/scripts/sha512sum.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +check_command() { + which $1 >/dev/null 2>&1 +} + +if check_command sha512sum; then + ret="$(sha512sum "$@")" +elif check_command shasum; then + ret="$(shasum -a 512 "$@")" +elif check_command cksum; then + ret="$(cksum -q -a sha512 "$@")" +else + echo "$0: no suitable sha512sum implementation was found" >&1 + exit 1 +fi + +[ "$?" -eq 0 ] || exit 1 + +echo "$ret" | awk '{ print $1 }' -- GitLab