fetch file support

This commit is contained in:
Lance Vick 2023-06-09 16:08:03 -07:00
parent a8c0099576
commit 42f1d5850c
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 19 additions and 1 deletions

View File

@ -35,7 +35,7 @@ VERSION := $(shell TZ=UTC0 git show --quiet --date='format-local:%Y.%m.%d' --for
DIST_DIR := dist DIST_DIR := dist
CONFIG_DIR := config CONFIG_DIR := config
CACHE_DIR_ROOT := cache CACHE_DIR_ROOT := cache
FETCH_DIR := $(CACHE_DIR_ROOT)/fetch FETCH_DIR := fetch
ifeq ($(TARGET),$(ARCH)) ifeq ($(TARGET),$(ARCH))
CACHE_DIR := $(CACHE_DIR_ROOT)/$(TARGET) CACHE_DIR := $(CACHE_DIR_ROOT)/$(TARGET)
else else
@ -141,6 +141,8 @@ $(OUT_DIR):
mkdir -p $@ mkdir -p $@
$(CACHE_DIR_ROOT)/make.env $(CACHE_DIR_ROOT)/container.env: \ $(CACHE_DIR_ROOT)/make.env $(CACHE_DIR_ROOT)/container.env: \
$(CONFIG_DIR)/global.env \
$(CONFIG_DIR)/toolchain.env \
$(CACHE_DIR_ROOT)/toolchain.state $(CACHE_DIR_ROOT)/toolchain.state
env > $(CACHE_DIR)/bootstrap.env env > $(CACHE_DIR)/bootstrap.env
docker run \ docker run \
@ -189,6 +191,22 @@ $(OUT_DIR)/release.env: | $(OUT_DIR)
check_executables := $(foreach exec,$(executables),\$(if \ check_executables := $(foreach exec,$(executables),\$(if \
$(shell which $(exec)),some string,$(error "No $(exec) in PATH"))) $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
define sha256_file
$$(openssl sha256 $(1) | awk '{ print $$2}')
endef
define fetch_file
bash -c " \
echo \"Fetching $(1)\" \
&& curl \
--location $(1) \
--output $(CACHE_DIR)/$(notdir $@) \
&& [[ "\""$(call sha256_file,$(CACHE_DIR)/$(notdir $@))"\"" == "\""$(2)"\"" ]] \
|| { echo 'Error: Hash check failed'; exit 1; } \
&& mv $(CACHE_DIR)/$(notdir $@) $@; \
"
endef
define git_clone define git_clone
[ -d $(1) ] || \ [ -d $(1) ] || \
mkdir -p $(FETCH_DIR) && \ mkdir -p $(FETCH_DIR) && \