From: Lady <redacted>
Date: Sun, 4 Feb 2024 00:47:40 +0000 (-0500)
Subject: Provide source checksums to parsers and transforms
X-Git-Tag: 0.5.3~3
X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/795e986a74f14006d2ae4d09198e65e195712b5c

Provide source checksums to parsers and transforms
---

diff --git a/GNUmakefile b/GNUmakefile
index 8306fc1..d760073 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -16,6 +16,7 @@ override define makefileinfo
 ║│                                                            │║
 ║│ • awk                                                      │║
 ║│ • cat                                                      │║
+║│ • cksum                                                    │║
 ║│ • cp                                                       │║
 ║│ • date                                                     │║
 ║│ • echo                                                     │║
@@ -89,6 +90,7 @@ endef
 # If these are not installed on your computer, or you need to use a different implementation, you can override the appropriate variable.
 AWK := awk
 CAT := cat
+CKSUM := cksum
 CP := cp
 DATE := date
 ECHO := echo
@@ -480,7 +482,7 @@ $(BUILDDIR)/parser.xslt: $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2parse
 $(call parsed,$(sourcefiles) $(sourceincludes)) : % : $$(call unparsed,$$@) $(typeupdates)
 	@$(PRINTF) '%s\n' $(call quote,Processing `$<´…)
 	$(silent)$(call ensuredirectory,$(dir $@))
-	$(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) > $(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(CAT) $(call quote,$<)) | $(XSLTPROC) -o $(call quote,$@) --stringparam BUILDTIME $$(TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME $$(TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call unparsed,$@)))$(if $(GENERATOR), --stringparam GENERATOR $(call quote,$(GENERATOR)))$(if $(VERSION), --stringparam VERSION $(call quote,$(VERSION)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
+	$(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) > $(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(CAT) $(call quote,$<)) | $(XSLTPROC) -o $(call quote,$@) --stringparam BUILDTIME $$(TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME $$(TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$<)) --stringparam CKSUM $$($(CKSUM) $(call quote,$<) | $(SED) 's/[ ].*//')$(if $(GENERATOR), --stringparam GENERATOR $(call quote,$(GENERATOR)))$(if $(VERSION), --stringparam VERSION $(call quote,$(VERSION)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
 
 # Generate a catalog of all parsed files, for use when processing includes.
 #
@@ -516,7 +518,7 @@ $(BUILDDIR)/transform.xslt : $(BUILDDIR)/transform.catalog $(THISDIR)/lib/catalo
 $(call compiled,$(compilablefiles)) : $(BUILDDIR)/public/% : $$(call parsed,$$(call uncompiled,$$@)) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@)))
 	$(silent)$(call ensuredirectory,$(dir $@))
 	@$(PRINTF) '%s\n' $(call quote,Compiling </$*>…)
-	$(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME $$(TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME $$(TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*)$(if $(GENERATOR), --stringparam GENERATOR $(call quote,$(GENERATOR)))$(if $(VERSION), --stringparam VERSION $(call quote,$(VERSION)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
+	$(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME $$(TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME $$(TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*) --stringparam CKSUM $$($(CKSUM) $(call quote,$(call uncompiled,$@)) | $(SED) 's/[ ].*//')$(if $(GENERATOR), --stringparam GENERATOR $(call quote,$(GENERATOR)))$(if $(VERSION), --stringparam VERSION $(call quote,$(VERSION)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
 $(call compiled,$(filter $(assetfiles),$(sourcefiles))) : $(BUILDDIR)/public/% : $$(call uncompiled,$$@)
 	@$(PRINTF) '%s\n' $(call quote,Compiling </$*>…)
 	$(silent)$(call ensuredirectory,$(dir $@))
diff --git a/README.markdown b/README.markdown
index 573fb86..e0a143e 100644
--- a/README.markdown
+++ b/README.markdown
@@ -102,6 +102,7 @@ In every case, you may supply your own implementation by overriding the
 
 - `awk`
 - `cat`
+- `cksum`
 - `cp`
 - `date`
 - `echo`
@@ -431,6 +432,9 @@ The following params are made available globally in parsers and
 - **`BUILDTIME`:**
   The current time.
 
+- **`CKSUM`:**
+  The checksum of the source file (⅌ `cksum`).
+
 - **`GENERATOR`:**
   The value of the `GENERATOR` variable (if present).
 
diff --git a/lib/catalog2parser.xslt b/lib/catalog2parser.xslt
index 1d8ad5d..eb35e80 100644
--- a/lib/catalog2parser.xslt
+++ b/lib/catalog2parser.xslt
@@ -23,6 +23,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 	<template match="/">
 		<xslt:transform version="1.0">
 			<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
+			<xslt:param name="CKSUM" select="false"/>
 			<xslt:param name="GENERATOR" select="false"/>
 			<xslt:param name="SRCREV" select="false"/>
 			<xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
diff --git a/lib/catalog2transform.xslt b/lib/catalog2transform.xslt
index 40e4072..5b7183e 100644
--- a/lib/catalog2transform.xslt
+++ b/lib/catalog2transform.xslt
@@ -26,6 +26,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 	<template match="/">
 		<xslt:transform exclude-result-prefixes="catalog exsl exslstr" version="1.0">
 			<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
+			<xslt:param name="CKSUM" select="false"/>
 			<xslt:param name="CATALOG" select="'catalog'"/>
 			<xslt:param name="GENERATOR" select="false"/>
 			<xslt:param name="PATH" select="'/unknown'"/>