1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00
libvirt/tools/virt-xml-validate.in
Thomas Huth 803a73980a tools/virt-xml-validate: Fix GPL information
The tools/virt-xml-validate.in file is licensed under the terms of
the GPL, but then says "You should have received a copy of the
GNU *Lesser* General Public License". Thus scratch the "Lesser" here.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-01-25 14:04:19 +01:00

107 lines
2.3 KiB
Bash

#!/bin/sh
#
# 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, see <http://www.gnu.org/licenses/>.
set -e
case $1 in
-h | --h | --he | --hel | --help)
cat <<EOF
Usage:
$0 XML-FILE [SCHEMA-NAME]
$0 OPTION
Options:
-h | --help Display program help
-V | --version Display program version
EOF
exit ;;
-V | --v | --ve | --ver | --vers | --versi | --versio | --version)
cat <<EOF
$0 (libvirt) @VERSION@
EOF
exit ;;
--) shift ;;
-*)
echo "$0: unrecognized option '$1'" >&2
exit 1 ;;
esac
XMLFILE="$1"
TYPE="$2"
if [ -z "$XMLFILE" ]; then
echo "syntax: $0 XMLFILE [TYPE]" >&2
exit 1
fi
if [ ! -f "$XMLFILE" ]; then
echo "$0: document $XMLFILE does not exist" >&2
exit 2
fi
if [ -z "$TYPE" ]; then
ROOT=`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 " | awk '{ print $3 }'`
case "$ROOT" in
*domainsnapshot*) # Must come first, since *domain* is a substring
TYPE="domainsnapshot"
;;
*domain*)
TYPE="domain"
;;
*network*)
TYPE="network"
;;
*pool*)
TYPE="storagepool"
;;
*volume*)
TYPE="storagevol"
;;
*capabilities*)
TYPE="capability"
;;
*device*)
TYPE="nodedev"
;;
*filterbinding*)
TYPE="nwfilterbinding"
;;
*filter*)
TYPE="nwfilter"
;;
*secret*)
TYPE="secret"
;;
*interface*)
TYPE="interface"
;;
*)
echo "$0: cannot determine schema type for $XMLFILE" >&2
exit 3
esac
fi
SCHEMA="@schemadir@/${TYPE}.rng"
if [ ! -f "$SCHEMA" ]; then
echo "$0: schema $SCHEMA does not exist" >&2
exit 4
fi
xmllint --noout --relaxng "$SCHEMA" "$XMLFILE"
exit