]> Lady’s Gitweb - Shushe/commitdiff
Allow empty archives
authorLady <redacted>
Sun, 15 Sep 2024 17:31:34 +0000 (13:31 -0400)
committerLady <redacted>
Sun, 15 Sep 2024 20:01:25 +0000 (16:01 -0400)
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.

GNUmakefile

index 105b403510b9fe98fc60b935af5ab4d48d2aec97..94f5efa26f5f4a33cbc62a59d406da3ce08e3ed8 100644 (file)
@@ -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 </$(NAME)>…) >&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 </$(NAME)>…) >&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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
This page took 0.031575 seconds and 4 git commands to generate.