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.
This commit is contained in:
Norman Feske 2023-04-05 12:17:49 +02:00 committed by Christian Helmuth
parent 22836e3e0f
commit 595660fb84

View File

@ -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)