diff options
Diffstat (limited to 'xml')
-rw-r--r-- | xml/Makefile.am | 85 | ||||
-rw-r--r-- | xml/README.md | 1 | ||||
-rw-r--r-- | xml/api/crm_node-2.32.rng | 53 | ||||
-rw-r--r-- | xml/version-diff.sh.in | 60 |
4 files changed, 149 insertions, 50 deletions
diff --git a/xml/Makefile.am b/xml/Makefile.am index 70dc8ea..6acb338 100644 --- a/xml/Makefile.am +++ b/xml/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004-2022 the Pacemaker project contributors +# Copyright 2004-2023 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -56,10 +56,11 @@ version_pairs_last = $(wordlist \ # Names of API schemas that form the choices for pacemaker-result content API_request_base = command-output \ crm_attribute \ - crm_error \ - crm_mon \ + crm_error \ + crm_mon \ + crm_node \ crm_resource \ - crm_rule \ + crm_rule \ crm_shadow \ crm_simulate \ crmadmin \ @@ -69,7 +70,14 @@ API_request_base = command-output \ version # Names of CIB schemas that form the choices for cib/configuration content -CIB_cfg_base = options nodes resources constraints fencing acls tags alerts +CIB_cfg_base = options \ + nodes \ + resources \ + constraints \ + fencing \ + acls \ + tags \ + alerts # Names of all schemas (including top level and those included by others) API_base = $(API_request_base) \ @@ -86,7 +94,13 @@ API_base = $(API_request_base) \ resources \ status \ subprocess-output -CIB_base = cib $(CIB_cfg_base) status score rule nvset + +CIB_base = cib \ + $(CIB_cfg_base) \ + status \ + score \ + rule \ + nvset # Static schema files and transforms (only CIB has transforms) # @@ -103,7 +117,7 @@ MON_abs_files = $(abs_srcdir)/crm_mon.rng API_files = $(foreach base,$(API_base),$(wildcard $(srcdir)/api/$(base)-*.rng)) CIB_files = $(foreach base,$(CIB_base),$(wildcard $(srcdir)/$(base).rng $(srcdir)/$(base)-*.rng)) CIB_xsl = $(srcdir)/upgrade-1.3.xsl \ - $(srcdir)/upgrade-2.10.xsl \ + $(srcdir)/upgrade-2.10.xsl \ $(wildcard $(srcdir)/upgrade-*enter.xsl) \ $(wildcard $(srcdir)/upgrade-*leave.xsl) MON_files = $(srcdir)/crm_mon.rng @@ -130,7 +144,9 @@ MON_build_copies = $(foreach f,$(MON_abs_files),$(subst $(abs_srcdir),$(abs_bui # Dynamically generated schema files API_generated = api/api-result.rng $(foreach base,$(API_versions),api/api-result-$(base).rng) -CIB_generated = pacemaker.rng $(foreach base,$(CIB_versions),pacemaker-$(base).rng) versions.rng +CIB_generated = pacemaker.rng \ + $(foreach base,$(CIB_versions),pacemaker-$(base).rng) \ + versions.rng MON_generated = crm_mon.rng CIB_version_pairs = $(call version_pairs,${CIB_numeric_versions}) @@ -138,7 +154,8 @@ CIB_version_pairs_cnt = $(words ${CIB_version_pairs}) CIB_version_pairs_last = $(call version_pairs_last,${CIB_version_pairs_cnt},${CIB_version_pairs}) dist_API_DATA = $(API_files) -dist_CIB_DATA = $(CIB_files) $(CIB_xsl) +dist_CIB_DATA = $(CIB_files) \ + $(CIB_xsl) nodist_API_DATA = $(API_generated) nodist_CIB_DATA = $(CIB_generated) @@ -159,10 +176,12 @@ EXTRA_DIST = README.md \ test-2-leave \ test-2-roundtrip +.PHONY: cib-versions cib-versions: @echo "Max: $(CIB_max)" @echo "Available: $(CIB_versions)" +.PHONY: api-versions api-versions: @echo "Max: $(API_max)" @echo "Available: $(API_versions)" @@ -253,56 +272,24 @@ versions.rng: pacemaker-$(CIB_max).rng Makefile.am $(AM_V_at)echo ' </start>' >> $@ $(AM_V_SCHEMA)echo '</grammar>' >> $@ -# diff fails with ec=2 if no predecessor is found; -# this uses '=' GNU extension to sed, if that's not available, -# one can use: hline=`echo "$${p}" | grep -Fn "$${hunk}" | cut -d: -f1`; -# XXX: use line information from hunk to avoid "not detected" for ambiguity -version_diff = \ - @for p in $(1); do \ - set `echo "$${p}" | tr '-' ' '`; \ - echo "\#\#\# *-$$2.rng vs. predecessor"; \ - for v in *-$$2.rng; do \ - echo "\#\#\#\# $${v} vs. predecessor"; b=`echo "$${v}" | cut -d- -f1`; \ - old=`./best-match.sh $${b} $$1`; \ - p=`diff -u "$${old}" "$${v}" 2>/dev/null`; \ - case $$? in \ - 1) echo "$${p}" | sed -n -e '/^@@ /!d;=;p' \ - -e ':l;n;/^\([- ]\|+.*<[^ />]\+\([^/>]\+="ID\|>$$\)\)/bl;s/^[+ ]\(.*\)/\1/p' \ - | while read hline; do \ - read h && read i || break; \ - iline=`grep -Fn "$${i}" "$${v}" | cut -d: -f1`; \ - ctxt="(not detected)"; \ - if test `echo "$${iline}" | wc -l` -eq 1; then \ - ctxt=`{ sed -n -e "1,$$(($${iline}-1))p" "$${v}"; \ - echo "<inject id=\"GOAL\"/>$${i}"; \ - sed -n -e "$$(($${iline}+1)),$$ p" "$${v}"; \ - } | $(XSLTPROC) --param skip 1 context-of.xsl -`; \ - fi; \ - echo "$${p}" | sed -n -e "$$(($${hline}-2)),$${hline}!d" \ - -e '/^\(+++\|---\)/p'; \ - echo "$${h} context: $${ctxt}"; \ - echo "$${p}" | sed -n -e "1,$${hline}d" \ - -e '/^\(---\|@@ \)/be;p;d;:e;n;be'; \ - done; \ - ;; \ - 2) echo "\#\#\#\#\# $${v} has no predecessor";; \ - esac; \ - done; \ - done - +.PHONY: diff diff: best-match.sh @echo "# Comparing changes in + since $(CIB_max)" - $(call version_diff,${CIB_version_pairs_last}) + @./version-diff.sh ${CIB_version_pairs_last} +.PHONY: fulldiff fulldiff: best-match.sh @echo "# Comparing all changes across all the subsequent increments" - $(call version_diff,${CIB_version_pairs}) + @./version-diff.sh ${CIB_version_pairs} -CLEANFILES = $(API_generated) $(CIB_generated) $(MON_generated) +CLEANFILES = $(API_generated) \ + $(CIB_generated) \ + $(MON_generated) # Remove pacemaker schema files generated by *any* source version. This allows # "make -C xml clean" to have the desired effect when checking out an earlier # revision in a source tree. +.PHONY: clean-local clean-local: if [ "x$(srcdir)" != "x$(builddir)" ]; then \ rm -f $(API_build_copies) $(CIB_build_copies) $(MON_build_copies); \ diff --git a/xml/README.md b/xml/README.md index e32edc2..a3a1973 100644 --- a/xml/README.md +++ b/xml/README.md @@ -112,7 +112,6 @@ itself, allowing for more sophistication down the road. 4. If required, add an XSLT file, and update `xslt\_SCRIPTS` in `xml/Makefile.am`. 5. Commit. 6. Run `make -C xml clean; make -C xml` to rebuild the schemas in the local -6. Run `make -C xml clean; make -C xml` to rebuild the schemas in the local source directory. 7. The CIB validity and upgrade regression tests will break after the schema is updated. Run `cts/cts-cli -s` to make the expected outputs reflect the diff --git a/xml/api/crm_node-2.32.rng b/xml/api/crm_node-2.32.rng new file mode 100644 index 0000000..402c761 --- /dev/null +++ b/xml/api/crm_node-2.32.rng @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<grammar xmlns="http://relaxng.org/ns/structure/1.0" + datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + + <!-- Output of the crm_node command --> + <start> + <ref name="element-crm-node" /> + </start> + + <define name="element-crm-node"> + <choice> + <ref name="cluster-info" /> + <ref name="node-info" /> + <ref name="node-list" /> + </choice> + </define> + + <define name="cluster-info"> + <element name="cluster-info"> + <attribute name="quorum"> <data type="boolean" /> </attribute> + </element> + </define> + + <define name="node-info"> + <element name="node-info"> + <attribute name="nodeid"> <data type="nonNegativeInteger" /> </attribute> + <optional> + <attribute name="uname"> <text/> </attribute> + </optional> + </element> + </define> + + <define name="node-list"> + <element name="nodes"> + <oneOrMore> + <ref name="element-node" /> + </oneOrMore> + </element> + </define> + + <define name="element-node"> + <element name="node"> + <attribute name="id"> <data type="nonNegativeInteger" /> </attribute> + <optional> + <attribute name="name"> <text/> </attribute> + </optional> + <optional> + <attribute name="state"> <text/> </attribute> + </optional> + </element> + </define> + +</grammar> diff --git a/xml/version-diff.sh.in b/xml/version-diff.sh.in new file mode 100644 index 0000000..1ece3b3 --- /dev/null +++ b/xml/version-diff.sh.in @@ -0,0 +1,60 @@ +#!@BASH_PATH@ +# +# Copyright 2016-2023 the Pacemaker project contributors +# +# The version control history for this file may have further details. +# +# This source code is licensed under the GNU General Public License version 2 +# or later (GPLv2+) WITHOUT ANY WARRANTY. +# + +# diff fails with ec=2 if no predecessor is found; +# this uses '=' GNU extension to sed, if that's not available, +# one can use: hline=`echo "$${p}" | grep -Fn "$${hunk}" | cut -d: -f1`; +# XXX: use line information from hunk to avoid "not detected" for ambiguity +for p in $*; do + set $(echo "$p" | tr '-' ' ') + echo "### *-$2.rng vs. predecessor" + + for v in *-"$2".rng; do + echo "#### $v vs. predecessor" + + b=$(echo "$v" | cut -d- -f1) + old=$(./best-match.sh "$b" "$1") + p=$(diff -u "$old" "$v" 2>/dev/null) + + case $? in + 1) + echo "$p" | sed -n -e '/^@@ /!d;=;p' -e ':l;n;/^\([- ]\|+.*<[^ />]\+\([^/>]\+="ID\|>$$\)\)/bl;s/^[+ ]\(.*\)/\1/p' | + while read -r hline; do + if read -r h; then + read -r i + else + break + fi + + iline=$(grep -Fn "$i" "$v" | cut -d: -f1) + + if [ "$(echo "$iline" | wc -l)" = "1" ]; then + ctxt=$({ sed -n -e "1,$((iline - 1))p" "$v" + echo "<inject id=\"GOAL\"/>$i" + sed -n -e "$((iline + 1)),$ p" "$v" + } | xsltproc --param skip 1 context-of.xsl -) + else + ctxt="(not detected)" + fi + + echo "$p" | sed -n -e "$((hline - 2)),$hline!d" -e '/^\(+++\|---\)/p' + echo "$h context: $ctxt" + echo "$p" | sed -n -e "1,${hline}d" -e '/^\(---\|@@ \)/be;p;d;:e;n;be' + done + + ;; + + 2) + echo "##### $v has no predecessor" + ;; + + esac + done +done |