From: Lady Date: Sun, 15 Sep 2024 17:31:34 +0000 (-0400) Subject: Allow empty archives X-Git-Tag: 0.12.5~2 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/c00f24956715156ae739772cefd04849c3db721b?ds=inline;hp=06b2ae9f95a0505031127bfe954451fa399cea5d Allow empty archives Previously, when an archive was empty, it would cause Make to endlessly restart. This was especially a problem for archives generated from includes, as if the include was missing (or an empty folder), the archive would have no members and Make would get stuck in a retry loop. This commit provides the necessary adjustments to ensure archive code continues working even when the archive is empty: The archive index file is always written, and the archive files folder is made to exist before attempting to `cd` into it. --- diff --git a/GNUmakefile b/GNUmakefile index 105b403..94f5efa 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -752,10 +752,13 @@ $(BUILDDIR)/extractor.xslt : $(SRC) $(THISDIR)/lib/archive2extractor.xslt # Use the extractor transform to extract the archive source file out into its components. # # This target sleeps for 1 second to ensure the resulting index will always be newer than this make·file. +# +# If the archive is empty, the index will not be written by `xsltproc´ and will need to be manually created. $(BUILDDIR)/index : $(BUILDDIR)/extractor.xslt $(SRC) $(call inform,$(PRINTF) '%s\n' $(call quote,Extracting components for …) >&2) $(silent)$(SLEEP) 1 $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --writesubtree $(call quote,$(dir $@)) $(call quote,$<) $(call quote,$(SRC)) + $(silent)if $(TEST) ! -e $(call quote,$@); then $(TOUCH) $(call quote,$@); fi # All archive components are extracted alongside the index. $(foreach file,$(archivefiles),$(BUILDDIR)/extracted/$(file)) : $(BUILDDIR)/index ; @@ -774,7 +777,8 @@ $(DESTDIR)/% : $(SRC) $(foreach file,$(archivefiles),$(BUILDDIR)/files/$(file)) $(call inform,$(PRINTF) '%s\n' $(call quote,Archiving …) >&2) $(silent)$(call ensuredirectory,$(dir $@)) $(silent)$(RM) -f -R $(call quote,$@) - $(silent)$(CD) $(call quote,$(BUILDDIR)/files); if $(call xpath,/*/@*[local-name()="expanded" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$(abspath $<)); then $(MKDIR) -p $(call quote,$(abspath $@)); $(PRINTF) '%s\n' $(foreach file,$(archivefiles),$(call quote,$(file))) | $(PAX) -r -w $(call quote,$(abspath $@)); else $(PRINTF) '%s\n' $(foreach file,$(archivefiles),$(call quote,$(file))) | $(PAX) -w -x ustar >|$(call quote,$(abspath $@)); fi + $(silent)$(call ensuredirectory,$(BUILDDIR)/files) + $(silent)$(CD) $(call quote,$(BUILDDIR)/files); if $(call xpath,/*/@*[local-name()="expanded" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$(abspath $<)); then $(MKDIR) -p $(call quote,$(abspath $@)); $(PRINTF) '$(if $(archivefiles),%s\n,)' $(foreach file,$(archivefiles),$(call quote,$(file))) | $(PAX) -r -w $(call quote,$(abspath $@)); else $(PRINTF) '$(if $(archivefiles),%s\n,)' $(foreach file,$(archivefiles),$(call quote,$(file))) | $(PAX) -w -x ustar >|$(call quote,$(abspath $@)); fi # ━ § BEGIN TWO‐STEP MAKE·FILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━