Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F4624346
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
16 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/xml/Makefile.am b/xml/Makefile.am
index 5db32a6de5..e05166a546 100644
--- a/xml/Makefile.am
+++ b/xml/Makefile.am
@@ -1,147 +1,171 @@
#
# Copyright (C) 2004 Andrew Beekhof
#
# 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.
#
MAINTAINERCLEANFILES = Makefile.in
dtddir = $(CRM_DTD_DIRECTORY)
dtd_SCRIPTS = crm.dtd crm-transitional.dtd
xsltdir = $(dtddir)
xslt_SCRIPTS = upgrade06.xsl upgrade-*.xsl
RNGdir = $(dtddir)
# See Readme.md for details on updating schema files
# Sorted list of available numeric RNG versions,
# extracted from filenames like NAME-MAJOR[.MINOR][.MINOR-MINOR].rng
RNG_numeric_versions = $(shell ls -1 *.rng \
| sed -E -n -e 's/^.*-([0-9.]+).rng$$/\1/p' \
| sort -u -t. -k 1,1n -k 2,2n -k 3,3n)
# The highest numeric version
RNG_max ?= $(lastword $(RNG_numeric_versions))
-# The previous numeric version before $(RNG_max)
-RNG_last ?= $(shell ls -1 *.rng \
- | sed -n -e 's/^.*-\([0-9.]\+\).rng$$/\1/p' \
- | sort -u -t. -k 1,1nr -k 2,2nr -k 3,3nr \
- | head -n 2 | tail -n 1)
-
# A sorted list of all RNG versions (numeric and "next")
RNG_versions = next $(RNG_numeric_versions)
RNG_version_pairs = $(join \
${RNG_numeric_versions},$(addprefix \
-,$(wordlist \
2,$(words ${RNG_numeric_versions}),${RNG_numeric_versions} \
) next \
) \
)
+RNG_version_pairs_cnt = $(words ${RNG_version_pairs})
+RNG_version_pairs_last = $(wordlist \
+ $(words \
+ $(wordlist \
+ 2,${RNG_version_pairs_cnt},${RNG_version_pairs} \
+ ) \
+ ),${RNG_version_pairs_cnt},${RNG_version_pairs} \
+ )
RNG_generated = pacemaker.rng $(foreach base,$(RNG_versions),pacemaker-$(base).rng) versions.rng
RNG_cfg_base = options nodes resources constraints fencing acls tags
RNG_base = cib $(RNG_cfg_base) status score rule nvset
RNG_files = $(foreach base,$(RNG_base),$(wildcard $(base)*.rng))
# List of non-Pacemaker RNGs
RNG_extra = crm_mon.rng
RNG_SCRIPTS = $(RNG_files) $(RNG_generated) $(RNG_extra)
EXTRA_DIST = best-match.sh
-best_match = $(shell $(top_srcdir)/xml/best-match.sh $(1) $(2))
-
versions:
echo "Max: $(RNG_max)"
echo "Available: $(RNG_versions)"
versions.rng: Makefile.am
echo " RNG $@"
echo "<?xml version='1.0' encoding='UTF-8'?>" > $@
echo "<grammar xmlns='http://relaxng.org/ns/structure/1.0' datatypeLibrary='http://www.w3.org/2001/XMLSchema-datatypes'>" >> $@
echo " <start>" >> $@
echo " <interleave>" >> $@
echo " <optional>" >> $@
echo " <attribute name='validate-with'>" >> $@
echo " <choice>" >> $@
echo " <value>none</value>" >> $@
echo " <value>pacemaker-0.6</value>" >> $@
echo " <value>transitional-0.6</value>" >> $@
echo " <value>pacemaker-0.7</value>" >> $@
echo " <value>pacemaker-1.1</value>" >> $@
for rng in $(RNG_versions); do echo " <value>pacemaker-$$rng</value>" >> $@; done
echo " </choice>" >> $@
echo " </attribute>" >> $@
echo " </optional>" >> $@
echo " <attribute name='admin_epoch'><data type='nonNegativeInteger'/></attribute>" >> $@
echo " <attribute name='epoch'><data type='nonNegativeInteger'/></attribute>" >> $@
echo " <attribute name='num_updates'><data type='nonNegativeInteger'/></attribute>" >> $@
echo " </interleave>" >> $@
echo " </start>" >> $@
echo "</grammar>" >> $@
pacemaker.rng: pacemaker-$(RNG_max).rng
echo " RNG $@"
cp $(top_builddir)/xml/$< $@
pacemaker-%.rng: $(RNG_files) best-match.sh Makefile.am
echo " RNG $@"
echo "<?xml version='1.0' encoding='UTF-8'?>" > $@
echo "<grammar xmlns='http://relaxng.org/ns/structure/1.0' datatypeLibrary='http://www.w3.org/2001/XMLSchema-datatypes'>" >> $@
echo " <start>" >> $@
echo " <element name='cib'>" >> $@
- $(top_srcdir)/xml/best-match.sh cib $(*) $(@) " "
+ ./best-match.sh cib $(*) $(@) " "
echo " <element name='configuration'>" >> $@
echo " <interleave>" >> $@
- for rng in $(RNG_cfg_base); do $(top_srcdir)/xml/best-match.sh $$rng $(*) $(@) " "; done
+ for rng in $(RNG_cfg_base); do ./best-match.sh $$rng $(*) $(@) " " || :; done
echo " </interleave>" >> $@
echo " </element>" >> $@
echo " <element name='status'>" >> $@
- $(top_srcdir)/xml/best-match.sh status $(*) $(@) " "
+ ./best-match.sh status $(*) $(@) " "
echo " </element>" >> $@
echo " </element>" >> $@
echo " </start>" >> $@
echo "</grammar>" >> $@
-files_next = $(shell echo $(wildcard *-next.rng) | sed 's/-next.rng//g')
-files_max = $(shell echo $(wildcard *-$(RNG_max).rng) | sed 's/-[0-9][0-9.]*.rng//g')
-
-diff:
- echo "# Comparing changes in: $(RNG_max)"
- -for rng in $(files_max); do echo "### $${rng}"; diff -u `$(top_srcdir)/xml/best-match.sh $${rng} $(RNG_last)` $${rng}-$(RNG_max).rng; done
- echo -e "\n\n\n# Comparing changes since: $(RNG_max)"
- -for rng in $(files_next); do echo "### $${rng}"; diff -u `$(top_srcdir)/xml/best-match.sh $${rng} $(RNG_max)` $${rng}-next.rng; done
-
-# diff fails with ec=2 if no predecessor is found
-fulldiff:
+# 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
+
+diff: best-match.sh
+ @echo "# Comparing changes in + since $(RNG_max)"
+ $(call version_diff,${RNG_version_pairs_last})
+
+fulldiff: best-match.sh
@echo "# Comparing all changes across all the subsequent increments"
- @for p in ${RNG_version_pairs}; do \
- set `echo "$$p" | tr '-' ' '`; echo "### *-$$1.rng vs. predecessor"; \
- for v in *-$$2.rng; do \
- echo "#### $${v} vs. predecessor"; b=`echo "$${v}" | cut -d'-' -f1`; \
- diff -u `$(top_srcdir)/xml/best-match.sh $${b} $$1` "$${v}" 2>/dev/null; \
- test $$? -le 1 || echo "##### $${v} has no predecessor"; \
- done; \
- done
+ $(call version_diff,${RNG_version_pairs})
sync:
git rm -f $(wildcard *-next.rng)
make pacemaker-next.rng
CLEANFILES = $(RNG_generated)
diff --git a/xml/Readme.md b/xml/Readme.md
index 30e7934f08..b78e13d26b 100644
--- a/xml/Readme.md
+++ b/xml/Readme.md
@@ -1,51 +1,53 @@
# Updating schema files #
## Experimental features ##
Experimental features go into `${base}-next.rng`
Create from the most recent `${base}-${X}.${Y}.rng` if it does not already exist
## Stable features ##
The current stable version is determined at runtime when
__xml_build_schema_list() interrogates the CRM_DTD_DIRECTORY.
It will have the form `pacemaker-${X}.${Y}` and the highest
`${X}.${Y}` wins.
### Simple Additions
When the new syntax is a simple addition to the previous one, create a
new entry with `${Y} = ${Yold} + 1`
### Feature Removal or otherwise Incompatible Changes
When the new syntax is not a simple addition to the previous one,
create a new entry with `${X} = ${Xold} + 1` and `${Y} = 0`.
An XSLT file is also required that converts an old syntax to the new
one and must be named `upgrade-${Xold}.${Yold}.xsl`.
See `xml/upgrade06.xsl` for an example.
### General Proceedure
1. Copy the most recent version of `${base}-*.rng` to `${base}-${X}.${Y}.rng`
1. Commit the copy, eg. `"Clone the latest ${base} schema in preparation for changes"`.
This way the actual change will be obvious in the commit history.
1. Modify `${base}-${X}.${Y}.rng` as required
1. Add an XSLT file if required and update `xslt_SCRIPTS` in `xml/Makefile.am`
1. Commit
## Admin Tasks
New features will not be available until the admin
1. Updates all the nodes
1. Runs the equivalent of `cibadmin --upgrade`
## Random Notes
From the source directory, run `make -C xml diff` to see the changes
in the current schema (compared to the previous ones) and also the
pending changes in `pacemaker-next`.
+Alternatively, if the intention is to grok the overall historical schema
+evolution, use `make -C xml fulldiff`.
diff --git a/xml/best-match.sh b/xml/best-match.sh
index 6d9ffb7219..2ba062532e 100755
--- a/xml/best-match.sh
+++ b/xml/best-match.sh
@@ -1,46 +1,58 @@
#!/bin/sh
base=$1; shift
target=$1; shift
destination=$1; shift
prefix=$1; shift
best="0.0"
-candidates=$(ls -1 ${base}-*.rng 2>/dev/null)
-for rng in $candidates; do
- case $rng in
- ${base}-${target}.rng)
- best=${target}
- break
- ;;
- *next*)
- : skipping $rng
- ;;
- *)
- v=$(echo $rng | sed -e "s/${base}-//" -e 's/.rng//')
- : comparing $v with $target
+candidates=$(ls -1 "${base}.rng" "${base}"-*.rng 2>/dev/null)
+for rng in ${candidates}; do
+ case ${rng} in
+ ${base}-${target}.rng)
+ best=${target}
+ break
+ ;;
+ *next*)
+ : skipping ${rng}
+ ;;
+ *)
+ if [ "${rng}" = "${base}.rng" ]; then
+ # special case for nvset.rng, no -0.1 around anyway
+ v=0.1
+ else
+ v=$(echo ${rng} | sed -e "s/${base}-//" -e 's/.rng//')
+ fi
+ : comparing ${v} with ${target}
- echo | awk -v n1="$v" -v n2="${best}" '{if (n1>n2) printf ("true"); else printf ("false");}' | grep -q "true"
- if [ $? -eq 0 ]; then
- : $v beats the previous ${best} for $target
- if [ ${target} = next ]; then
- best=$v
- else
- echo | awk -v n1="$v" -v n2="${target}" '{if (n1<n2) printf ("true"); else printf ("false");}' | grep -q "true"
- if [ $? -eq 0 ]; then
- : $v is still less than $target, using
- best=$v
- fi
- fi
- fi
- ;;
+ echo | awk -v n1="${v}" -v n2="${best}" '{if (n1>n2) printf ("true"); else printf ("false");}' | grep -q "true"
+ if [ $? -eq 0 ]; then
+ : ${v} beats the previous ${best} for ${target}
+ if [ "${target}" = "next" ]; then
+ best=${v}
+ else
+ echo | awk -v n1="${v}" -v n2="${target}" '{if (n1<n2) printf ("true"); else printf ("false");}' | grep -q "true"
+ if [ $? -eq 0 ]; then
+ : ${v} is still less than ${target}, using
+ best=${v}
+ fi
+ fi
+ fi
+ ;;
esac
done
-if [ "x${best}" != "x0.0" ]; then
- if [ "x$destination" = x ]; then
- echo ${base}-${best}.rng
+[ "${best}" != "0.0" ]; ec=$?
+if [ ${ec} -eq 0 ]; then
+ if [ "${best}" = "0.1" ]; then
+ found=${base}.rng
else
- echo "$prefix<externalRef href=\"${base}-${best}.rng\"/>" >> ${destination}
+ found=${base}-${best}.rng
+ fi
+ if [ "x${destination}" = "x" ]; then
+ echo "${found}"
+ else
+ echo "${prefix}<externalRef href=\"${found}\"/>" >> "${destination}"
fi
fi
+ret () { return $1; }; ret ${ec}
diff --git a/xml/context-of.xsl b/xml/context-of.xsl
new file mode 100644
index 0000000000..96b8c17332
--- /dev/null
+++ b/xml/context-of.xsl
@@ -0,0 +1,83 @@
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text"/>
+<xsl:param name="goal-name" select="'id'"/>
+<xsl:param name="goal-value" select="'GOAL'"/>
+<xsl:param name="style" select="'rng'"/>
+<xsl:param name="skip" select="0"/>
+
+<xsl:template match="/">
+ <xsl:choose>
+ <xsl:when test="not(.//@*[
+ name() = $goal-name
+ and
+ . = $goal-value
+ ])">
+ <xsl:message terminate="yes">NOTFOUND</xsl:message>
+ </xsl:when>
+ <xsl:when test="$style = 'xml'">
+ <xsl:call-template name="xpath-xml-elem">
+ <xsl:with-param name="terminal-elem"
+ select=".//@*[
+ name() = $goal-name
+ and
+ . = $goal-value
+ ]/.."/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$style = 'rng'">
+ <xsl:call-template name="xpath-rng-elem">
+ <xsl:with-param name="terminal-elem"
+ select=".//@*[
+ name() = $goal-name
+ and
+ . = $goal-value
+ ]/.."/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">BADSTYLE</xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="xpath-xml-elem">
+ <xsl:param name="terminal-elem"/>
+ <xsl:variable name="TotalCount"
+ select="count($terminal-elem/ancestor-or-self::*)"/>
+ <xsl:for-each select="$terminal-elem/ancestor-or-self::*">
+ <xsl:if test="$TotalCount - position() >= $skip">
+ <xsl:value-of select="concat('/', name())"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:value-of select="'
'"/>
+</xsl:template>
+
+<xsl:template name="xpath-rng-elem">
+ <xsl:param name="terminal-elem"/>
+ <xsl:variable name="TotalCount"
+ select="count($terminal-elem/ancestor-or-self::*)"/>
+ <xsl:for-each select="$terminal-elem/ancestor-or-self::*">
+ <xsl:if test="$TotalCount - position() >= $skip">
+ <xsl:choose>
+ <xsl:when test="name() = 'attribute'">
+ <xsl:value-of select="concat('/@', @name)"/>
+ </xsl:when>
+ <xsl:when test="name() = 'define'">
+ <xsl:value-of select="concat('/<', @name, '>')"/>
+ </xsl:when>
+ <xsl:when test="name() = 'element'">
+ <xsl:value-of select="concat('/', @name)"/>
+ </xsl:when>
+ <xsl:when test="name() = 'grammar'">
+ <xsl:if test="$TotalCount < 3">
+ <xsl:value-of select="concat('<', name(), '>')"/>
+ </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:value-of select="'
'"/>
+</xsl:template>
+
+</xsl:stylesheet>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jul 8, 6:16 PM (17 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1988176
Default Alt Text
(16 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment