genode/tool/depot/mk/extract_src_archive
Norman Feske 4b0b4928f5 tool/depot: rm binary archives if versions collide
This patch handles version collisions of binary archives. If a binary
archive for an (automatically) updated src-archive version already
exists in the depot, the extract tool removes the binary archive because
its existing content may stem from another src content (a version from a
different topic branch). This ensures that the new version is always
built, not skipped, when 'UPDATE_VERSIONS=1 REBUILD=' is specified.

Fixes #3267
2019-04-01 19:33:52 +02:00

106 lines
2.9 KiB
Makefile
Executable File

#!/usr/bin/make -f
#
# \brief Tool for assembling a source archive
# \author Norman Feske
# \date 2016-05-13
#
define HELP_MESSAGE
Tool for assembling a source archive
usage:
$(firstword $(MAKEFILE_LIST)) <src-name> USER=<user>
<src-name> name of the source archive
<user> identity of the archive creator
endef
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../../..)
include $(GENODE_DIR)/tool/depot/mk/front_end.inc
#
# The target is the name of the archive
#
ARCHIVE := $(TARGET)
TAG_FILE := LICENSE
ifeq ($(USER),)
$(error USER undefined)
endif
#
# Define location of recipe and the exported archive
#
RECIPE_DIR := $(call recipe_dir,src/$(ARCHIVE))
REP_DIR := $(RECIPE_DIR:/recipes/src/$(ARCHIVE)=)
DEPOT_SUB_DIR := $(DEPOT_DIR)/$(USER)/src
#
# Customize command executed whenever an archive version is automatically
# updated. Whenever the version of a src archive is automatically increased,
# make sure that the depot is void of any binary archives matching the new
# version number.
#
VERSION_UPDATED_CMD = ( cd $(DEPOT_DIR); \
for stale in $(USER)/bin/*/$(ARCHIVE)/$(RECIPE_VERSION); do \
echo "removing stale binary archive $$stale"; \
rm -rf $$stale; \
done )
#
# Include common archive-creation steps
#
include $(GENODE_DIR)/tool/depot/mk/extract.inc
include $(GENODE_DIR)/tool/depot/mk/extract_content.inc
#
# Add used_apis information, supplemented with the current API hashes
#
ifneq ($(wildcard $(RECIPE_DIR)/used_apis),)
$(DEPOT_ARCHIVE_DIR).hash: $(DEPOT_ARCHIVE_DIR)/used_apis
endif
$(DEPOT_ARCHIVE_DIR)/used_apis: $(DEPOT_ARCHIVE_DIR)
$(DEPOT_ARCHIVE_DIR)/used_apis: $(RECIPE_DIR)/used_apis
$(VERBOSE) \
for api in $(shell cat $<); do \
hash_file=$(GENODE_DIR)/repos/**/recipes/api/$$api/hash; \
if [ ! -f $$hash_file ]; then \
echo "Error: archive $(ARCHIVE) depends on nonexisting API '$$api',"; \
echo " expected $$hash_file"; \
rm -r $(DEPOT_ARCHIVE_DIR); \
result=false; \
break; \
fi; \
hash_file_content=$$(< $$hash_file); \
version=$${hash_file_content%% *}; \
echo "$$api/$$version" >> $@; \
done; $$result
#
# If the archive is a library, add the hash of its implemented API
#
ifneq ($(wildcard $(RECIPE_DIR)/api),)
$(DEPOT_ARCHIVE_DIR).hash: $(DEPOT_ARCHIVE_DIR)/api
endif
$(DEPOT_ARCHIVE_DIR)/api: $(DEPOT_ARCHIVE_DIR)
$(DEPOT_ARCHIVE_DIR)/api: $(RECIPE_DIR)/api
$(VERBOSE) \
api=$$(< $<); \
hash_file=$(GENODE_DIR)/repos/**/recipes/api/$$api/hash; \
if [ ! -f $$hash_file ]; then \
echo "Error: library '$(ARCHIVE)' implements unknown API '$$api',"; \
echo " expected $$hash_file"; \
rm -r $(DEPOT_ARCHIVE_DIR); \
exit -1; \
fi; \
hash_file_content=$$(< $$hash_file); \
version=$${hash_file_content%% *}; \
echo "$$api/$$version" >> $@;