Compare commits

...

No commits in common. "c8s" and "c8-beta" have entirely different histories.
c8s ... c8-beta

6 changed files with 217 additions and 8 deletions

2
.clufter.metadata Normal file
View File

@ -0,0 +1,2 @@
a8e2a4aeed9ec51b267f59e66f4011d22d434cbd SOURCES/clufter-0.77.1-tests.tar.xz
8dbcaa596a15ed926a2cb93c3cad8a6ae4eb473d SOURCES/clufter-0.77.1.tar.gz

6
.gitignore vendored
View File

@ -1,4 +1,2 @@
/clufter-*.tar.gz SOURCES/clufter-0.77.1-tests.tar.xz
/clufter-*-tests.tar.xz SOURCES/clufter-0.77.1.tar.gz
/fix-jing-simplified-rng.xsl
/pacemaker-borrow-schemas

View File

@ -0,0 +1,142 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns="http://relaxng.org/ns/structure/1.0"
exclude-result-prefixes="rng">
<xsl:output format="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="filename-or-version" select="'99.99'"/>
<xsl:variable name="version">
<xsl:variable name="version-local">
<xsl:choose>
<xsl:when test="starts-with($filename-or-version, 'pacemaker-')">
<xsl:variable name="version-tail"
select="substring-after($filename-or-version, 'pacemaker-')"/>
<xsl:choose>
<xsl:when test="contains(substring-after($version-tail, '.'), '.')">
<xsl:value-of select="substring(
$version-tail,
1,
string-length($version-tail)
-
1
-
string-length(
substring-after(
substring-after(
$version-tail,
'.'
),
'.'
)
)
)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$version-tail"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$filename-or-version"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="number($version-local) = number('NaN')">
<xsl:message terminate="yes">
<xsl:value-of select="concat('Wrong number specification: ', $version-local)"/>
</xsl:message>
</xsl:if>
<xsl:value-of select="$version-local"/>
</xsl:variable>
<xsl:variable name="version-major">
<xsl:choose>
<xsl:when test="contains($version, '.')">
<xsl:value-of select="number(substring-before($version, '.'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($version)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="version-minor">
<xsl:value-of select="number(concat('0', substring-after($version, '.')))"/>
</xsl:variable>
<xsl:template match="/rng:grammar">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="datatypeLibrary">
<xsl:value-of select="'http://www.w3.org/2001/XMLSchema-datatypes'"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<!-- drop these -->
<xsl:template match="@ns[. = '']"/>
<xsl:template match="@datatypeLibrary[
. = ''
or
. = 'http://www.w3.org/2001/XMLSchema-datatypes'
]"/>
<!-- limit highest schema version in /cib/@validate-with to that
of the file processed -->
<xsl:template match="rng:attribute[@name = 'validate-with']/rng:choice/rng:value">
<xsl:choose>
<xsl:when test="starts-with(text(), 'pacemaker-')
and
(
number(
substring-before(substring-after(text(), 'pacemaker-'), '.')
) &gt; $version-major
or
(
number(
substring-before(substring-after(text(), 'pacemaker-'), '.')
) = $version-major
and
number(
concat('0', substring-after(substring-after(text(), 'pacemaker-'), '.'))
) &gt; $version-minor
)
)"/>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ensure "status" section is optional; see also:
- https://github.com/ClusterLabs/pacemaker/commit/89f5177
- https://pagure.io/clufter/c/a3985ec -->
<xsl:template match="*[name() != 'optional']/rng:ref[@name = 'status']">
<optional>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</optional>
</xsl:template>
<!-- ensure neither "score-attribute" nor "score-attribute-mangle" attributes
of rsc_colocation are supported; see also:
- https://github.com/ClusterLabs/pacemaker/commit/30383cc
- https://pagure.io/clufter/c/abd2d45 (+ 53b8215) -->
<xsl:template match="rng:element[@name = 'rsc_colocation']//rng:choice[
rng:attribute[@name = 'score']
]">
<xsl:apply-templates select="rng:attribute[@name = 'score']"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,71 @@
#!/bin/sh
# Copyright 2017 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
# A helper for "borrow validation schemas from pacemaker" process.
die() { echo; echo "$@"; exit 1; }
# $1 ... input directory with original pacemaker schemas
# $2 ... output directory with consolidated schemas
# $3 ... schemas to skip (as posix-egrep expression)
# $4 ... postprocess XSLT
# $5 ... clobber existing files? (true if set and non-null)
consolidate() {
inputdir="${1}"; outputdir="${2}"; skipschemas="${3}"; postprocess="${4}"
test "${#}" -lt 5 || clobber="${5}"
mkdir -p -- "${outputdir}"
# for all the schema versions at the boundary of the "major" bump,
# except for the lower boundary of the first one (i.e. pacemaker-1.0)
# -- the versions in between are not interesting from validation POV
for base in $(
find "${inputdir}" -regextype posix-egrep -regex "${skipschemas}" -prune \
-o -name 'pacemaker-*.rng' -printf '%P\n' | sort -V \
| sed -e 'N;/^\(pacemaker-[0-9]\)\.\([0-9][0-9]*\)\.rng\n\1\.\([0-9][0-9]*\)\.rng$/!p;D'); do
f="${inputdir}/${base}"
printf "processing: ${f} ... "
test -f "${f}" || continue
sentinel=10; old=/dev/null; new="${f}"
# until the jing output converged (simplification gets idempotent)
# as prescribed by did-size-change heuristic (or sentinel is hit)
while [ "$(stat -c '%s' "${old}")" != "$(stat -c '%s' "${new}")" ]; do
[ "$((sentinel -= 1))" -gt 0 ] || break
[ "${old}" = "${f}" ] && old="${outputdir}/${base}";
[ "${new}" = "${f}" ] \
&& { old="${f}"; new="${outputdir}/${base}.new"; } \
|| cp -f "${new}" "${old}"
jing -is "${old}" > "${new}"
#printf "(%d -> %d) " "$(stat -c '%s' "${old}")" "$(stat -c '%s' "${new}")"
done
printf "%d iterations" "$((10 - ${sentinel}))"
test -z "${clobber-}" && test -s "${old}" && die "file ${old} already exists" || :
if [ -z "${postprocess}" ]; then
mv "${new}" "${old}"
printf ", moved\n"
else
# xmllint drops empty lines caused by the applied transformation
xsltproc --stringparam filename-or-version "${base}" \
"${postprocess}" "${new}" \
| xmllint --format - > "${old}"
rm -f -- "${new}"
printf ", postprocessed\n"
fi
done
}
which jing >/dev/null 2>&1 || die "jing (from jing-trang project) required"
: "${INPUTDIR=$(pkg-config --variable schemadir pacemaker)}"
test -n "${INPUTDIR}" || die "Input dir with pacemaker schemas not known"
: "${OUTPUTDIR=schemas-consolidated}"
test -n "${OUTPUTDIR}" || die "Output dir for consolidated schemas not known"
: "${POSTPROCESS=$(dirname "${0}")/fix-jing-simplified-rng.xsl}"
# skip non-defaults of upstream releases
#: "${SKIPSCHEMAS=.*/pacemaker-(1\.0|2\.[126]).rng}"
: "${SKIPSCHEMAS=".*/pacemaker-next\.rng"}" # only skip WIP schema by default
consolidate "${INPUTDIR}" "${OUTPUTDIR}" "${SKIPSCHEMAS}" "${POSTPROCESS}" "${@}"

View File

@ -1,4 +0,0 @@
SHA512 (clufter-0.77.1.tar.gz) = 29a7ececfa05573e595741da234ad26d49085bb3a7a91d930c62998e9e8568d56f77d357a9628b6c1b045616acf70de9a8dc41b11757e73004b2380e254c8303
SHA512 (clufter-0.77.1-tests.tar.xz) = 9c05e9f93a035b4e4fdcb28fa72fc063ed07e36438d40d4313218c3df7e7d1008a78eb29f362d854685c4ce4fa54951324c499e718229076ac4d7ced3a794877
SHA512 (fix-jing-simplified-rng.xsl) = a937c01f76556aee2884fb6eed520d21abe9b5d51a6a43faee0f2592376e79813b8d6cdf9fddf820864ba3c009fd61c2b83328a75f2d567a366c163751ffb03a
SHA512 (pacemaker-borrow-schemas) = 97fbe8a0f3722182cfa65f5c0ab466f2a0f923c6fac3a1cc3dccf819f02d31e738f2129cf88bd8533ac4c4e324c5896e9d447703bc21b64b60e48516282f98e6