2017-03-28 16:41:41 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
|
|
|
#
|
|
|
|
# \brief Tool for assembling a package archive
|
|
|
|
# \author Norman Feske
|
|
|
|
# \date 2017-03-17
|
|
|
|
#
|
|
|
|
|
|
|
|
define HELP_MESSAGE
|
|
|
|
|
|
|
|
Compress and sign depot content for publishing
|
|
|
|
|
|
|
|
usage:
|
|
|
|
|
2018-02-26 16:05:34 +00:00
|
|
|
$(firstword $(MAKEFILE_LIST)) <archive-path> {PUBLIC_DIR=<public>}
|
2017-03-28 16:41:41 +00:00
|
|
|
|
|
|
|
The <archive-path> denotes the archives (and implicitly their
|
|
|
|
dependencies) to publish from the depot to the public directory.
|
|
|
|
It must be given including the version number of the package archive.
|
|
|
|
|
|
|
|
This tool does not touch any Genode source repository. It solely
|
|
|
|
reads from the depot and writes to the public directory.
|
|
|
|
|
2018-02-26 16:05:34 +00:00
|
|
|
The optional 'PUBLIC_DIR' argument defines the location of the public
|
2017-03-28 16:41:41 +00:00
|
|
|
directory. If not specified, '<genode-dir>/public/' is used.
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../..)
|
|
|
|
|
2022-05-17 12:17:01 +00:00
|
|
|
PUBLIC_DIR ?= $(GENODE_DIR)/public
|
|
|
|
DEPOT_TOOL_DIR ?= $(GENODE_DIR)/tool/depot
|
2017-03-28 16:41:41 +00:00
|
|
|
|
2019-06-27 10:00:46 +00:00
|
|
|
XZ_THREADS ?= 1
|
|
|
|
|
2022-05-17 12:17:01 +00:00
|
|
|
include $(DEPOT_TOOL_DIR)/mk/front_end.inc
|
2017-03-28 16:41:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine dependencies, check for completeness
|
|
|
|
#
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),)
|
2022-05-17 12:17:01 +00:00
|
|
|
DEPENDENCIES_CMD := $(DEPOT_TOOL_DIR)/dependencies DEPOT_DIR="$(DEPOT_DIR)" \
|
|
|
|
DEPOT_TOOL_DIR="$(DEPOT_TOOL_DIR)" \
|
|
|
|
$(MAKECMDGOALS)
|
2017-03-28 16:41:41 +00:00
|
|
|
DEPENDENCIES_RESULT := $(shell $(DEPENDENCIES_CMD) 2> /dev/null || true)
|
|
|
|
endif
|
|
|
|
|
2018-02-01 16:56:57 +00:00
|
|
|
DEPENDENCIES_MISSING := $(sort $(foreach A, $(DEPENDENCIES_RESULT),\
|
|
|
|
$(if $(wildcard $(PUBLIC_DIR)/$A.tar.xz.sig),,$A)))
|
|
|
|
|
2017-03-28 16:41:41 +00:00
|
|
|
ifeq ($(filter Error:,$(DEPENDENCIES_RESULT)),)
|
2018-02-01 16:56:57 +00:00
|
|
|
ARCHIVES := $(DEPENDENCIES_MISSING)
|
2017-03-28 16:41:41 +00:00
|
|
|
else
|
|
|
|
ARCHIVES :=
|
|
|
|
$(MAKECMDGOALS): dependencies_error
|
|
|
|
endif
|
|
|
|
|
|
|
|
# re-execute the dependencies command to present the error to the user
|
|
|
|
dependencies_error:
|
|
|
|
@$(DEPENDENCIES_CMD)
|
|
|
|
|
2019-02-19 16:33:15 +00:00
|
|
|
TARGETS += $(addsuffix .tar.xz.sig,$(addprefix $(PUBLIC_DIR)/,$(ARCHIVES)))
|
|
|
|
|
2017-03-28 16:41:41 +00:00
|
|
|
|
|
|
|
#
|
2019-02-19 16:33:15 +00:00
|
|
|
# Determine to-be-published index files from MAKECMDGOALS
|
|
|
|
#
|
|
|
|
|
2023-01-20 09:14:43 +00:00
|
|
|
# sculpt index files at <user>/index/<sculpt-version>
|
2019-02-19 16:33:15 +00:00
|
|
|
INDEX_FILES := $(foreach A,$(MAKECMDGOALS),\
|
|
|
|
$(if $(call archive_has_type,$A,index),$A,))
|
|
|
|
|
2023-01-20 09:14:43 +00:00
|
|
|
# image index file at <user>/image/index
|
|
|
|
INDEX_FILES += $(foreach A,$(MAKECMDGOALS),\
|
|
|
|
$(if $(call archive_has_type,$A,image),\
|
|
|
|
$(if $(filter $(call path_element,3,$A),index),$A,),))
|
|
|
|
|
2019-02-19 16:33:15 +00:00
|
|
|
INDEX_FILES_MISSING := $(sort $(foreach I, $(INDEX_FILES),\
|
|
|
|
$(if $(wildcard $(DEPOT_DIR)/$I),,$I)))
|
|
|
|
|
|
|
|
ifneq ($(INDEX_FILES_MISSING),)
|
|
|
|
$(MAKECMDGOALS): index_missing_error
|
|
|
|
else
|
|
|
|
TARGETS += $(addsuffix .xz.sig,$(addprefix $(PUBLIC_DIR)/,$(INDEX_FILES)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
index_missing_error:
|
|
|
|
@echo "Error: missing depot content: $(INDEX_FILES_MISSING)"; false
|
|
|
|
|
|
|
|
|
2023-01-20 09:14:43 +00:00
|
|
|
#
|
|
|
|
# Determine to-be-published system images from MAKECMDGOALS
|
|
|
|
#
|
|
|
|
|
|
|
|
# system images at <user>/image/<name> (consider all names other than 'index')
|
|
|
|
SYSTEM_IMAGES := $(foreach A,$(MAKECMDGOALS),\
|
|
|
|
$(if $(call archive_has_type,$A,image),\
|
|
|
|
$(if $(filter $(call path_element,3,$A),index),,$A),))
|
|
|
|
|
|
|
|
SYSTEM_IMAGES_MISSING := $(sort $(foreach I, $(SYSTEM_IMAGES),\
|
|
|
|
$(if $(wildcard $(DEPOT_DIR)/$I),,$I) \
|
|
|
|
$(if $(wildcard $(DEPOT_DIR)/$I.img),,$I.img)))
|
|
|
|
|
|
|
|
ifneq ($(SYSTEM_IMAGES_MISSING),)
|
|
|
|
$(MAKECMDGOALS): system_images_missing_error
|
|
|
|
else
|
|
|
|
TARGETS += $(addsuffix .tar.xz.sig,$(addprefix $(PUBLIC_DIR)/,$(SYSTEM_IMAGES)))
|
|
|
|
TARGETS += $(addsuffix .img.xz.sig,$(addprefix $(PUBLIC_DIR)/,$(SYSTEM_IMAGES)))
|
|
|
|
TARGETS += $(addsuffix .zip.sig, $(addprefix $(PUBLIC_DIR)/,$(SYSTEM_IMAGES)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
system_images_missing_error:
|
|
|
|
@echo "Error: missing depot content: $(SYSTEM_IMAGES_MISSING)"; false
|
|
|
|
|
|
|
|
|
2019-02-19 16:33:15 +00:00
|
|
|
#
|
|
|
|
# Generate compressed and signed archives and index files
|
2017-03-28 16:41:41 +00:00
|
|
|
#
|
|
|
|
|
2022-05-17 12:17:01 +00:00
|
|
|
include $(DEPOT_TOOL_DIR)/mk/gpg.inc
|
2017-03-28 16:41:41 +00:00
|
|
|
|
|
|
|
MISSING_PUBKEY_FILES := $(sort \
|
|
|
|
$(foreach A,$(ARCHIVES),\
|
|
|
|
$(if $(call pubkey_path,$A),,\
|
2022-01-04 15:43:06 +00:00
|
|
|
$(call pubkey_filename,$A))))
|
2017-03-28 16:41:41 +00:00
|
|
|
|
2023-10-09 06:45:07 +00:00
|
|
|
_gpg_sign_target = $(GPG) --detach-sign --digest-algo SHA256 \
|
|
|
|
--batch --yes --no-tty --use-agent \
|
2023-05-03 08:59:54 +00:00
|
|
|
--local-user $(call pubkey_id,$*) --output $@ < $< || \
|
2023-01-20 09:14:43 +00:00
|
|
|
( rm -f $@; false )
|
|
|
|
|
2019-02-19 16:33:15 +00:00
|
|
|
$(PUBLIC_DIR)/%.xz.sig : $(PUBLIC_DIR)/%.xz
|
2023-01-20 09:14:43 +00:00
|
|
|
$(VERBOSE)$(_gpg_sign_target)
|
2017-03-28 16:41:41 +00:00
|
|
|
|
2023-01-20 09:14:43 +00:00
|
|
|
$(PUBLIC_DIR)/%.zip.sig : $(PUBLIC_DIR)/%.zip
|
|
|
|
$(VERBOSE)$(_gpg_sign_target)
|
|
|
|
|
|
|
|
.PRECIOUS: $(TARGETS:.xz.sig=.xz) $(TARGETS:.zip.sig=.zip)
|
2017-03-28 16:41:41 +00:00
|
|
|
|
2019-02-19 16:33:15 +00:00
|
|
|
# archive
|
2017-12-11 15:49:23 +00:00
|
|
|
$(PUBLIC_DIR)/%.tar.xz: $(DEPOT_DIR)/%
|
2017-03-28 16:41:41 +00:00
|
|
|
@$(ECHO) "$(DARK_COL)publish$(DEFAULT_COL) $@"
|
|
|
|
$(VERBOSE)test -e $(dir $@) || mkdir -p $(dir $@)
|
2019-06-27 10:00:46 +00:00
|
|
|
$(VERBOSE)tar cf - -C $(dir $<) $(notdir $<) | \
|
|
|
|
xz --threads=$(XZ_THREADS) > $@
|
2017-03-28 16:41:41 +00:00
|
|
|
|
2019-02-19 16:33:15 +00:00
|
|
|
# index file
|
|
|
|
$(PUBLIC_DIR)/%.xz: $(DEPOT_DIR)/%
|
|
|
|
@$(ECHO) "$(DARK_COL)publish$(DEFAULT_COL) $@"
|
|
|
|
$(VERBOSE)test -e $(dir $@) || mkdir -p $(dir $@)
|
2019-06-27 10:00:46 +00:00
|
|
|
$(VERBOSE)xz --threads=$(XZ_THREADS) <$< >$@
|
2019-02-19 16:33:15 +00:00
|
|
|
|
2023-01-20 09:14:43 +00:00
|
|
|
# ZIP archive of system image
|
|
|
|
$(PUBLIC_DIR)/%.zip: $(DEPOT_DIR)/%.img
|
|
|
|
@$(ECHO) "$(DARK_COL)publish$(DEFAULT_COL) $@"
|
|
|
|
$(VERBOSE)test -e $(dir $@) || mkdir -p $(dir $@)
|
|
|
|
$(VERBOSE)zip -jq $@ $<
|
|
|
|
|
2017-03-28 16:41:41 +00:00
|
|
|
ifneq ($(MISSING_PUBKEY_FILES),)
|
|
|
|
$(MAKECMDGOALS) $(TARGETS): missing_pubkey_files
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(MAKECMDGOALS): $(TARGETS)
|
|
|
|
@true
|
|
|
|
|