From 1b518965cc010ee26ef43cc2ff049194b08535cb Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 19 Feb 2019 17:33:15 +0100 Subject: [PATCH] depot/sculpt: support for index files The input for the pkg index is located at gems/run/sculpt/index. The sculpt.run script uses this input for generating the depot index file at depot//index/. The tool/depot/publish tool support arguments of the form /index/ where corresponds to the Sculpt version. Issue #3172 --- repos/gems/run/sculpt.run | 46 ++++++++++++++++++++++++++++--------- repos/gems/run/sculpt/index | 27 ++++++++++++++++++++++ tool/depot/publish | 37 +++++++++++++++++++++++++---- 3 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 repos/gems/run/sculpt/index diff --git a/repos/gems/run/sculpt.run b/repos/gems/run/sculpt.run index e454c3e89..f7217f45f 100644 --- a/repos/gems/run/sculpt.run +++ b/repos/gems/run/sculpt.run @@ -500,17 +500,6 @@ puts $fd "[sculpt_version]" close $fd -# -# Assemble 'depot_users.tar' with the keys and download locations of the -# depot user found at genode/depot/. -# -set depot_users_files [exec sh -c "cd [genode_dir]; \ - find depot -maxdepth 3 -name pubkey \ - -or -name download"] -exec sh -c "tar cf [run_dir]/genode/depot_users.tar -C [genode_dir] \ - [join $depot_users_files]" - - # # Depot packages to be included in the default installation # @@ -599,6 +588,41 @@ exec tar cf [run_dir]/genode/launcher.tar -C [run_dir]/genode launcher exec rm -r [run_dir]/genode/launcher +# +# Generate depot index from gems/run/sculpt/index +# +set fd [open [genode_dir]/repos/gems/run/sculpt/index r] +set pkg_index [read $fd] +close $fd + +# filter 'pkg' attribute +set pattern {(\]+?path=")([^/]+)(")} +while {[regexp $pattern $pkg_index dummy head pkg tail]} { + set pkg_path [depot_user]/pkg/[current_pkg $pkg] + regsub $pattern $pkg_index "$head$pkg_path$tail" pkg_index +} + +# write filtered pkg index into the depot +file mkdir [depot_dir]/[depot_user]/index +set fd [open [depot_dir]/[depot_user]/index/[sculpt_version] w] +puts $fd $pkg_index +close $fd + + +# +# Assemble 'depot_users.tar' with the keys and download locations of the +# depot user found at genode/depot/. +# +# Add current depot index of [depot_user] as generated above. +# +set depot_users_files [exec sh -c "cd [genode_dir]; \ + find depot -maxdepth 3 -name pubkey \ + -or -name download"] +exec sh -c "tar cf [run_dir]/genode/depot_users.tar -C [genode_dir] \ + [join $depot_users_files] \ + depot/[depot_user]/index/[sculpt_version]" + + # # Create boot image # diff --git a/repos/gems/run/sculpt/index b/repos/gems/run/sculpt/index new file mode 100644 index 000000000..73226db7b --- /dev/null +++ b/repos/gems/run/sculpt/index @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tool/depot/publish b/tool/depot/publish index d5b96a135..ac27fedb3 100755 --- a/tool/depot/publish +++ b/tool/depot/publish @@ -56,9 +56,31 @@ endif dependencies_error: @$(DEPENDENCIES_CMD) +TARGETS += $(addsuffix .tar.xz.sig,$(addprefix $(PUBLIC_DIR)/,$(ARCHIVES))) + # -# Generate compressed and signed archives +# Determine to-be-published index files from MAKECMDGOALS +# + +INDEX_FILES := $(foreach A,$(MAKECMDGOALS),\ + $(if $(call archive_has_type,$A,index),$A,)) + +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 + + +# +# Generate compressed and signed archives and index files # include $(GENODE_DIR)/tool/depot/mk/gpg.inc @@ -68,20 +90,25 @@ MISSING_PUBKEY_FILES := $(sort \ $(if $(call pubkey_path,$A),,\ $(DEPOT_DIR)/$(call pubkey_filename,$A)))) -TARGETS := $(addsuffix .tar.xz.sig,$(addprefix $(PUBLIC_DIR)/,$(ARCHIVES))) - -$(PUBLIC_DIR)/%.tar.xz.sig : $(PUBLIC_DIR)/%.tar.xz +$(PUBLIC_DIR)/%.xz.sig : $(PUBLIC_DIR)/%.xz $(VERBOSE)rm -f $@; $(VERBOSE)$(GPG) --detach-sign --digest-algo SHA256 --no-tty --use-agent \ --local-user $(call pubkey_id,$*) - < $< > $@ -.PRECIOUS: $(TARGETS:.tar.xz.sig=.tar.xz) +.PRECIOUS: $(TARGETS:.xz.sig=.xz) +# archive $(PUBLIC_DIR)/%.tar.xz: $(DEPOT_DIR)/% @$(ECHO) "$(DARK_COL)publish$(DEFAULT_COL) $@" $(VERBOSE)test -e $(dir $@) || mkdir -p $(dir $@) $(VERBOSE)tar cJf $@ -C $(dir $<) $(notdir $<) +# index file +$(PUBLIC_DIR)/%.xz: $(DEPOT_DIR)/% + @$(ECHO) "$(DARK_COL)publish$(DEFAULT_COL) $@" + $(VERBOSE)test -e $(dir $@) || mkdir -p $(dir $@) + $(VERBOSE)xz <$< >$@ + ifneq ($(MISSING_PUBKEY_FILES),) $(MAKECMDGOALS) $(TARGETS): missing_pubkey_files endif