prepare_port: simple cache for downloads

Fixes 
This commit is contained in:
Tomasz Gajewski 2021-02-19 23:51:04 +01:00 committed by Norman Feske
parent ba567f4ba8
commit de62582905
2 changed files with 13 additions and 1 deletions

@ -188,16 +188,24 @@ _svn_dir = $(call _assert,$(DIR($1)),Missing declaration of DIR($*))
_file_name = $(call _prefer,$(NAME($1)),$(notdir $(URL($1))))
#
# Some downloads are available via HTTPS only, but wget < 3.14 does not support
# server-name identification, which is used by some sites. So, we disable
# certificate checking in wget and check the validity of the download via SIG
# or SHA.
#
# Successful and integrity-checked downloads are cached at the
# GENODE_CONTRIB_CACHE directory. The combination of 'cp' and 'mv' when
# populating the cache prevents corrupted files in the cache when the disk is
# full.
#
%.file:
$(VERBOSE)test -n "$(URL($*))" ||\
($(ECHO) "Error: Undefined URL for $(call _file_name,$*)"; false);
$(VERBOSE)mkdir -p $(dir $(call _file_name,$*))
$(VERBOSE)name=$(call _file_name,$*);\
$(VERBOSE)name=$(call _file_name,$*); cached_name=$(GENODE_CONTRIB_CACHE)/$(SHA($*))_$$name; \
(test -f $$name || ! test -f $$cached_name || cp $$cached_name $$name); \
(test -f $$name || $(MSG_DOWNLOAD)$(URL($*))); \
(test -f $$name || wget --quiet --no-check-certificate $(URL($*)) -O $$name) || \
($(ECHO) Error: Download for $* failed; false)
@ -205,6 +213,9 @@ _file_name = $(call _prefer,$(NAME($1)),$(notdir $(URL($1))))
($(ECHO) "$(SHA($*)) $(call _file_name,$*)" |\
sha256sum -c > /dev/null 2> /dev/null) || \
($(ECHO) Error: Hash sum check for $* failed; false)
$(VERBOSE)name=$(call _file_name,$*); cached_name=$(GENODE_CONTRIB_CACHE)/$(SHA($*))_$$name; \
mkdir -p $(GENODE_CONTRIB_CACHE); \
(test -f $$cached_name || (cp $$name $$cached_name.tmp && mv $$cached_name.tmp $$cached_name))
##

@ -9,6 +9,7 @@
# 'create_builddir' tool within the Genode source tree
#
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../../..)
export GENODE_CONTRIB_CACHE ?= $(GENODE_DIR)/contrib/cache
include $(GENODE_DIR)/tool/ports/mk/front_end.inc
include $(GENODE_DIR)/tool/ports/mk/check_port_arg.inc