Skip to content

Commit db4e3af

Browse files
committed
fixup! pkg,dist/tools: repl. DOWNLOAD_TO_FILE with DLCACHE
1 parent de46643 commit db4e3af

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

dist/tools/dlcache/dlcache.sh

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@ else
3333
}
3434
fi
3535

36-
if [ "$(uname)" = Darwin ]; then
37-
MD5="md5 -r"
38-
else
39-
MD5=md5sum
40-
fi
36+
# shasum is supported on Linux and Darwin
37+
SHA512="shasum -a 512"
4138

42-
calcmd5() {
39+
calcsha512() {
4340
local file="$1"
44-
local md5="$2"
45-
local file_md5
46-
file_md5=$(${MD5} "$file" | cut -d\ -f1)
41+
local sha512="$2"
42+
local file_sha512
43+
file_sha512=$(${SHA512} "$file" | cut -d\ -f1)
4744

48-
test "$md5" = "$file_md5"
45+
test "$sha512" = "$file_sha512"
4946
}
5047

5148
downloader() {
@@ -61,24 +58,24 @@ downloader() {
6158

6259
download() {
6360
local url="$2"
64-
local _md5="$3"
61+
local _sha512="$3"
6562
local basename_url
6663
basename_url="$(basename "${url}")"
6764
local target="${1:-"${basename_url}"}"
6865

69-
if [ -f "$target" ] && [ -n "$_md5" ]; then
70-
# if our target file exists and an MD5 sum was given, check it's MD5
71-
calcmd5 "$target" "$_md5" && {
72-
_echo "$0: target exists, md5 matches."
66+
if [ -f "$target" ] && [ -n "$_sha512" ]; then
67+
# if our target file exists and an SHA512 sum was given, check it's SHA512
68+
calcsha512 "$target" "$_sha512" && {
69+
_echo "$0: target exists, SHA512 matches."
7370
exit 0
7471
}
7572
fi
7673

7774
local filename
7875
filename="$(basename "$url")"
7976
[ -f "$DLCACHE_DIR/$filename" ] && {
80-
# if the file exists in cache, check it's md5 and possibly remove it.
81-
if calcmd5 "$DLCACHE_DIR/$filename" "$_md5"; then
77+
# if the file exists in cache, check it's SHA512 and possibly remove it.
78+
if calcsha512 "$DLCACHE_DIR/$filename" "$_sha512"; then
8279
_echo "$0: getting \"$url\" from cache"
8380
else
8481
_echo "$0: \"$DLCACHE_DIR/$filename\" has wrong or no checksum, re-downloading"
@@ -96,8 +93,8 @@ download() {
9693
}
9794

9895
# only try to calculate the checksum if a checksum was given
99-
if [ -n "$_md5" ]; then
100-
calcmd5 "$DLCACHE_DIR/$filename" "$_md5" || {
96+
if [ -n "$_sha512" ]; then
97+
calcsha512 "$DLCACHE_DIR/$filename" "$_sha512" || {
10198
_echo "$0: checksum mismatch!"
10299
exit 1
103100
}

makefiles/mcuboot.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SIGN_BINFILE = $(BINDIR)/signed-$(APPLICATION).bin
88
MCUBOOT_KEYFILE ?= $(BINDIR)/key.pem
99
MCUBOOT_BIN ?= $(BINDIR)/mcuboot.bin
1010
MCUBOOT_BIN_URL ?= http://download.riot-os.org/mynewt.mcuboot.bin
11-
MCUBOOT_BIN_MD5 ?= 0c71a0589bd3709fc2d90f07a0035ce7
11+
MCUBOOT_BIN_SHA512 ?=
1212

1313
export IMAGE_HDR_SIZE ?= 512
1414

@@ -37,7 +37,7 @@ mcuboot: mcuboot-create-key link
3737
@$(COLOR_ECHO)
3838

3939
$(MCUBOOT_BIN):
40-
$(Q)$(DLCACHE) $@ $(MCUBOOT_BIN_URL) $(MCUBOOT_BIN_MD5)
40+
$(Q)$(DLCACHE) $@ $(MCUBOOT_BIN_URL) $(MCUBOOT_BIN_SHA512)
4141

4242
.PHONY: mcuboot-flash-bootloader mcuboot-flash
4343

0 commit comments

Comments
 (0)