validate-diameter-xml.sh: do not hard-code temporary directory
In the event that validation fails, the hard-coded temporary directory would remain present. Use of a fixed hard-coded directory also prevents concurrent runs. Change-Id: I29f09dc004b1ab3578b4a9c51ea7e1a5b526159f Reviewed-on: https://code.wireshark.org/review/30231 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
This commit is contained in:
parent
3d6bf1fe00
commit
ca50195f11
|
@ -37,24 +37,27 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if ! tmpdir=$(mktemp -d); then
|
||||
echo "Could not create temporary directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
|
||||
# First edit all the AVP names that start with "3GPP" to indicate "TGPP".
|
||||
# XML doesn't allow ID's to start with a digit but:
|
||||
# 1) We don't *really* care if it's valid XML
|
||||
# 2) (but) we do want to use xmllint to find problems
|
||||
# 3) (and) users see the AVP names. Showing them "TGPP" instead of "3GPP"
|
||||
# is annoying enough to warrant this extra work.
|
||||
mkdir /tmp/diameter || exit 1
|
||||
cp diameter/dictionary.dtd /tmp/diameter || exit 1
|
||||
cp diameter/dictionary.dtd "$tmpdir" || exit 1
|
||||
for f in diameter/*.xml
|
||||
do
|
||||
sed 's/name="3GPP/name="TGPP/g' $f > /tmp/$f || exit 1
|
||||
sed 's/name="3GPP/name="TGPP/g' "$f" > "$tmpdir/${f##*/}" || exit 1
|
||||
done
|
||||
|
||||
xmllint --noout --noent --postvalid /tmp/diameter/dictionary.xml &&
|
||||
xmllint --noout --noent --postvalid "$tmpdir/dictionary.xml" &&
|
||||
echo "Diameter dictionary is (mostly) valid XML."
|
||||
|
||||
rm -rf /tmp/diameter
|
||||
|
||||
#
|
||||
# Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue