tool/run: use xmlcatalog for xsd file paths

With libxml2 >= 2.13, the `-path` argument can no longer be used for
setting search paths for xsd files. Instead, we use an XML catalog to
replace genode:// URIs with absolute paths.

Fixes #5248
This commit is contained in:
Johannes Schlatow 2024-06-14 20:38:09 +02:00 committed by Norman Feske
parent 5181d08d05
commit 16b863fc6e
16 changed files with 44 additions and 37 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:element name="config">
<xs:complexType>

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="timeout_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://timeout_types.xsd"/>
<xs:simpleType name="Repeat">
<xs:restriction base="xs:string">

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="timeout_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://timeout_types.xsd"/>
<xs:simpleType name="Trace_policy_name">
<xs:restriction base="xs:string">

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="timeout_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:include schemaLocation="genode://timeout_types.xsd"/>
<xs:element name="config">
<xs:complexType>

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="timeout_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:include schemaLocation="genode://timeout_types.xsd"/>
<xs:simpleType name="Protocol">
<xs:restriction base="xs:string">

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="timeout_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://timeout_types.xsd"/>
<xs:simpleType name="Trace_policy_name">
<xs:restriction base="xs:string">

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="virtio_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:include schemaLocation="genode://virtio_types.xsd"/>
<xs:simpleType name="RxBufferSize">
<xs:restriction base="xs:unsignedShort">

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:complexType name="template_service">
<xs:choice minOccurs="1" maxOccurs="3">

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:simpleType name="Policy">
<xs:restriction base="xs:string">

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:element name="config">
<xs:complexType>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:simpleType name="Interface_label">
<xs:restriction base="xs:string">

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="timeout_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:include schemaLocation="genode://timeout_types.xsd"/>
<xs:simpleType name="Domain_name">
<xs:restriction base="xs:string">

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:element name="config">
<xs:complexType>

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="net_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:include schemaLocation="genode://net_types.xsd"/>
<xs:simpleType name="Protocol">
<xs:restriction base="xs:string">

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="base_types.xsd"/>
<xs:include schemaLocation="genode://base_types.xsd"/>
<xs:element name="config">
<xs:complexType>

View File

@ -142,7 +142,7 @@ proc check_xml_syntax {xml_file} {
# configurations of children of the component
# \param nesting_level level of recursive calls of this procedure
#
proc check_config {bin xml_file xsd_file label avail_xsd_files xsd_inc nesting_level} {
proc check_config {bin xml_file xsd_file label avail_xsd_files nesting_level} {
# check prerequisites if this is not a recursive call
if {$nesting_level == 0} {
@ -157,7 +157,7 @@ proc check_config {bin xml_file xsd_file label avail_xsd_files xsd_inc nesting_l
# check the given component configuration itself
puts " CHECK $label"
if {[catch {exec xmllint --noout --path $xsd_inc -schema $xsd_file $xml_file} result]} {
if {[catch {exec xmllint --noout -schema $xsd_file $xml_file} result]} {
if {$result != "$xml_file validates"} {
@ -226,7 +226,7 @@ proc check_config {bin xml_file xsd_file label avail_xsd_files xsd_inc nesting_l
# call this procedure again on the child config file
set child_label "$label -> $child_name"
check_config $child_bin $child_xml_file $child_xsd_file \
$child_label $avail_xsd_files $xsd_inc \
$child_label $avail_xsd_files \
[expr $nesting_level+1]
# clean up
@ -317,16 +317,23 @@ proc build_boot_image { binaries } {
set init_xsd_file $xsd_file
}
}
# determine include directories that can be used by the XSD files
# create catalog file
set catalog [file join [run_dir] genode catalog.xml]
catch { exec xmlcatalog --noout --create $catalog }
# determine paths of additional XSD files and add to catalog
global repositories;
set xsd_inc ""
foreach repo $repositories {
if {[file exists $repo/xsd]} {
append xsd_inc "$repo/xsd " }
foreach xsd_path [glob -nocomplain -type f $repo/xsd/*.xsd] {
set xsd_name [file tail $xsd_path]
catch { exec xmlcatalog --noout --add "uri" "genode://$xsd_name" "$xsd_path" $catalog }
}
}
set ::env(XML_CATALOG_FILES) $catalog
# check configurations of init and its children
puts "checking configuration syntax"
check_config init [run_dir]/genode/config $init_xsd_file init $xsd_files $xsd_inc 0
check_config init [run_dir]/genode/config $init_xsd_file init $xsd_files 0
run_boot_dir $binaries
}