From 595660fb847df00d2d5290bb5fb5cfec5b67bd06 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 5 Apr 2023 12:17:49 +0200 Subject: [PATCH] tool/depot: sanity check for presence of port hash If a content.mk file wrongly refers to a non-existing directory in a call of the 'port_dir' function, the 'content_env_missing_ports.mk' gets stuck while invoking 'cat' without argument, which makes such mistakes difficult to diagnose. This patch adds a sanity check for the existence of the port hash file at the specified location before attempting to 'cat' the hash-file content. --- tool/depot/mk/content_env_missing_ports.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tool/depot/mk/content_env_missing_ports.mk b/tool/depot/mk/content_env_missing_ports.mk index c09b3a8d19..f96436cb87 100644 --- a/tool/depot/mk/content_env_missing_ports.mk +++ b/tool/depot/mk/content_env_missing_ports.mk @@ -25,6 +25,18 @@ disable_shell = $(eval SHELL:=true) # $(disable_shell) +# +# Check for the existance of a port's hash file +# +# \param $1 path to hash file +# +# This check may fail whenever a 'port_dir' call in a content.mk file refers to +# a wrong repository. +# +_assert_hash_exists = $(if $(wildcard $1).hash,,\ + $(error missing hash file for port '$(notdir $1)'\ + (expected at $1))) + # # If a port is missing, append its name to the missing ports file # @@ -37,7 +49,7 @@ _assert = $(if $1,$1,$(shell echo $2 >> $(MISSING_PORTS_FILE))) # # $(call port_dir,$(GENODE_DIR)/repos/libports/ports/libpng) # -_port_hash = $(shell cat $(call _assert,$(wildcard $1.hash),$(notdir $1))) +_port_hash = $(_assert_hash_exists)$(shell cat $(call _assert,$(wildcard $1.hash),$(notdir $1))) _port_dir = $(wildcard $(CONTRIB_DIR)/$(notdir $1)-$(call _port_hash,$1)) port_dir = $(call enable_shell)$(call _assert,$(call _port_dir,$1),$(notdir $1))$(call disable_shell)