diff --git a/xml/Makefile.am b/xml/Makefile.am
index 4584d60262..d21b45cef7 100644
--- a/xml/Makefile.am
+++ b/xml/Makefile.am
@@ -1,228 +1,233 @@
#
# Copyright 2004-2019 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
MAINTAINERCLEANFILES = Makefile.in
-APIdir = $(CRM_SCHEMA_DIRECTORY)/api
-RNGdir = $(CRM_SCHEMA_DIRECTORY)
-
-xsltdir = $(RNGdir)
-dist_xslt_DATA = $(top_srcdir)/xml/upgrade-1.3.xsl \
- $(top_srcdir)/xml/upgrade-2.10.xsl \
- $(top_srcdir)/xml/upgrade-*enter.xsl \
- $(top_srcdir)/xml/upgrade-*leave.xsl
+# Pacemaker has 3 schemas: the CIB schema, the API schema (for command-line
+# tool XML output), and a legacy schema for crm_mon --as-xml.
+#
+# See Readme.md for details on updating CIB schema files (API is similar)
-# See Readme.md for details on updating schema files
+# The CIB and crm_mon schemas are installed directly in CRM_SCHEMA_DIRECTORY
+# for historical reasons, while the API schema is installed in a subdirectory.
+APIdir = $(CRM_SCHEMA_DIRECTORY)/api
+CIBdir = $(CRM_SCHEMA_DIRECTORY)
+MONdir = $(CRM_SCHEMA_DIRECTORY)
-# Sorted list of available numeric RNG versions,
-# extracted from filenames like NAME-MAJOR[.MINOR][.MINOR-MINOR].rng
+# Extract a sorted list of available numeric schema versions
+# from filenames like NAME-MAJOR[.MINOR][.MINOR-MINOR].rng
numeric_versions = $(shell ls -1 $(1) \
| sed -n -e 's/^.*-\([0-9][0-9.]*\).rng$$/\1/p' \
| sort -u -t. -k 1,1n -k 2,2n -k 3,3n)
version_pairs = $(join \
$(1),$(addprefix \
-,$(wordlist \
2,$(words $(1)),$(1) \
) next \
) \
)
version_pairs_last = $(wordlist \
$(words \
$(wordlist \
2,$(1),$(2) \
) \
),$(1),$(2) \
)
-API_numeric_versions = $(call numeric_versions,${API_files})
-RNG_numeric_versions = $(call numeric_versions,${RNG_files})
+# Names of API schemas that form the choices for pacemaker-result content
+API_request_base = command-output stonith_admin version
-# The highest numeric version
-API_max ?= $(lastword $(API_numeric_versions))
-RNG_max ?= $(lastword $(RNG_numeric_versions))
+# Names of CIB schemas that form the choices for cib/configuration content
+CIB_cfg_base = options nodes resources constraints fencing acls tags alerts
-# A sorted list of all API and RNG versions (numeric and "next")
-API_versions = next $(API_numeric_versions)
-API_request_base = command-output stonith_admin version
+# Names of all schemas (including top level and those included by others)
API_base = $(API_request_base) item status
-API_files = $(foreach base,$(API_base),$(wildcard api/$(base)*.rng))
+CIB_base = cib $(CIB_cfg_base) status score rule nvset
+
+# All static schema files
+API_files = $(foreach base,$(API_base),$(wildcard api/$(base)*.rng))
+CIB_files = $(foreach base,$(CIB_base),$(wildcard $(base).rng $(base)-*.rng))
+MON_files = crm_mon.rng
+
+# Sorted lists of all numeric schema versions
+API_numeric_versions = $(call numeric_versions,${API_files})
+CIB_numeric_versions = $(call numeric_versions,${CIB_files})
-RNG_versions = next $(RNG_numeric_versions)
-RNG_version_pairs = $(call version_pairs,${RNG_numeric_versions})
-RNG_version_pairs_cnt = $(words ${RNG_version_pairs})
-RNG_version_pairs_last = $(call version_pairs_last,${RNG_version_pairs_cnt},${RNG_version_pairs})
+# The highest numeric schema version
+API_max ?= $(lastword $(API_numeric_versions))
+CIB_max ?= $(lastword $(CIB_numeric_versions))
-API_generated = api/api-result.rng $(foreach base,$(API_versions),api/api-result-$(base).rng)
-RNG_generated = pacemaker.rng $(foreach base,$(RNG_versions),pacemaker-$(base).rng) versions.rng
+# Sorted lists of all schema versions (including "next")
+API_versions = next $(API_numeric_versions)
+CIB_versions = next $(CIB_numeric_versions)
-RNG_cfg_base = options nodes resources constraints fencing acls tags alerts
-RNG_base = cib $(RNG_cfg_base) status score rule nvset
-RNG_files = $(foreach base,$(RNG_base),$(wildcard $(base).rng $(base)-*.rng))
+# 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
-# List of non-Pacemaker RNGs
-RNG_extra = crm_mon.rng
+CIB_version_pairs = $(call version_pairs,${CIB_numeric_versions})
+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_RNG_DATA = $(RNG_files) $(RNG_extra)
-nodist_API_DATA = $(API_generated)
-nodist_RNG_DATA = $(RNG_generated)
+dist_API_DATA = $(API_files)
+dist_CIB_DATA = $(CIB_files) \
+ upgrade-1.3.xsl \
+ upgrade-2.10.xsl \
+ $(wildcard $(srcdir)/upgrade-*enter.xsl) \
+ $(wildcard $(srcdir)/upgrade-*leave.xsl)
+dist_MON_DATA = $(MON_files)
+
+nodist_API_DATA = $(API_generated)
+nodist_CIB_DATA = $(CIB_generated)
EXTRA_DIST = Readme.md \
best-match.sh \
cibtr-2.rng \
context-of.xsl \
ocf-meta2man.xsl \
regression.sh \
upgrade-2.10-roundtrip.xsl \
upgrade-detail.xsl \
xslt_cibtr-2.rng \
assets \
test-2 \
test-2-enter \
test-2-leave \
test-2-roundtrip
-versions:
- echo "Max: $(RNG_max)"
- echo "Available: $(RNG_versions)"
+cib-versions:
+ @echo "Max: $(CIB_max)"
+ @echo "Available: $(CIB_versions)"
api-versions:
- echo "Max: $(API_max)"
- echo "Available: $(API_versions)"
-
-versions.rng: Makefile.am
- echo " RNG $@"
- echo '' > $@
- echo '' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' none' >> $@
- echo ' pacemaker-0.6' >> $@
- echo ' transitional-0.6' >> $@
- echo ' pacemaker-0.7' >> $@
- echo ' pacemaker-1.1' >> $@
- for rng in $(RNG_versions); do echo " pacemaker-$$rng" >> $@; done
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo ' ' >> $@
- echo '' >> $@
+ @echo "Max: $(API_max)"
+ @echo "Available: $(API_versions)"
+# Dynamically generated top-level API schema
api/api-result.rng: api/api-result-$(API_max).rng
echo " RNG $@"
cp $(top_builddir)/xml/$< $@
-pacemaker.rng: pacemaker-$(RNG_max).rng
- echo " RNG $@"
- cp $(top_builddir)/xml/$< $@
-
-api/api-result-%.rng: $(API_files) Makefile.am
+api/api-result-%.rng: $(API_files) best-match.sh Makefile.am
echo " RNG $@"
echo '' > $@
echo '' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
- for rng in $(API_request_base); do $(top_srcdir)/xml/best-match.sh api/$$rng $(*) $(@) " " || :; done
+ for rng in $(API_request_base); do $(srcdir)/best-match.sh api/$$rng $(*) $(@) " " || :; done
echo ' ' >> $@
echo ' ' >> $@
- $(top_srcdir)/xml/best-match.sh api/status $(*) $(@) " " || :
+ $(srcdir)/best-match.sh api/status $(*) $(@) " " || :
echo ' ' >> $@
echo ' ' >> $@
echo '' >> $@
-pacemaker-%.rng: $(RNG_files) best-match.sh Makefile.am
+# Dynamically generated top-level CIB schema
+pacemaker.rng: pacemaker-$(CIB_max).rng
+ echo " RNG $@"
+ cp $(top_builddir)/xml/$< $@
+
+pacemaker-%.rng: $(CIB_files) best-match.sh Makefile.am
echo " RNG $@"
echo '' > $@
echo '' >> $@
echo ' ' >> $@
echo ' ' >> $@
- $(top_srcdir)/xml/best-match.sh cib $(*) $(@) " "
+ $(srcdir)/best-match.sh cib $(*) $(@) " "
echo ' ' >> $@
echo ' ' >> $@
- for rng in $(RNG_cfg_base); do $(top_srcdir)/xml/best-match.sh $$rng $(*) $(@) " " || :; done
+ for rng in $(CIB_cfg_base); do $(srcdir)/best-match.sh $$rng $(*) $(@) " " || :; done
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
- $(top_srcdir)/xml/best-match.sh status $(*) $(@) " "
+ $(srcdir)/best-match.sh status $(*) $(@) " "
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo ' ' >> $@
echo '' >> $@
+# Dynamically generated CIB schema listing all pacemaker versions
+versions.rng: Makefile.am
+ echo " RNG $@"
+ echo '' > $@
+ echo '' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' none' >> $@
+ echo ' pacemaker-0.6' >> $@
+ echo ' transitional-0.6' >> $@
+ echo ' pacemaker-0.7' >> $@
+ echo ' pacemaker-1.1' >> $@
+ for rng in $(CIB_versions); do echo " pacemaker-$$rng" >> $@; done
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo ' ' >> $@
+ echo '' >> $@
+
# 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 "$${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
diff: best-match.sh
- @echo "# Comparing changes in + since $(RNG_max)"
- $(call version_diff,${RNG_version_pairs_last})
+ @echo "# Comparing changes in + since $(CIB_max)"
+ $(call version_diff,${CIB_version_pairs_last})
fulldiff: best-match.sh
@echo "# Comparing all changes across all the subsequent increments"
- $(call version_diff,${RNG_version_pairs})
+ $(call version_diff,${CIB_version_pairs})
-CLEANFILES = $(API_generated) $(RNG_generated)
+CLEANFILES = $(API_generated) $(CIB_generated)