temporary checkin... switching gears to another project for a bit
This commit is contained in:
parent
608a50ce8f
commit
fbf92367d5
8
aif.xml
8
aif.xml
@ -1,11 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<aif xmlns="https://aif.square-r00t.net/aif.xsd">
|
<aif xmlns="http://aif.square-r00t.net/aif.xsd">
|
||||||
<storage>
|
<storage>
|
||||||
<disk name="sda" type="gpt">
|
<disk name="sda" type="gpt">
|
||||||
<part num="1" size="10%" fstype="ef00" />
|
<part num="1" size="10%" fstype="ef00" />
|
||||||
<part num="2" size="90%" fstype="8300" />
|
<part num="2" size="90%" fstype="8300" />
|
||||||
</disk>
|
</disk>
|
||||||
<mount source="/dev/sda1" mountpt="/mnt" />
|
<mount source="/dev/sda1" mountpt="/mnt/boot" order="2" />
|
||||||
|
<mount source="/dev/sda2" mountpt="/mnt" order="1" />
|
||||||
</storage>
|
</storage>
|
||||||
<network hostname="aiftest.square-r00t.net">
|
<network hostname="aiftest.square-r00t.net">
|
||||||
<iface name="auto" addressing="dhcp" />
|
<iface name="auto" addressing="dhcp" />
|
||||||
@ -72,7 +73,8 @@
|
|||||||
<package name="sed" repo="core" />
|
<package name="sed" repo="core" />
|
||||||
</software>
|
</software>
|
||||||
</pacman>
|
</pacman>
|
||||||
<bootloader>
|
<bootloader efi="true">
|
||||||
<type>GRUB</type>
|
<type>GRUB</type>
|
||||||
|
<where>/boot</where>
|
||||||
</bootloader>
|
</bootloader>
|
||||||
</aif>
|
</aif>
|
9
aif.xsd
9
aif.xsd
@ -14,6 +14,7 @@
|
|||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="mount"><!-- mountpoint -->
|
<xs:element name="mount"><!-- mountpoint -->
|
||||||
|
<xs:element name="order" /><!-- optional. the "weight" to give this mount point. -->
|
||||||
<xs:element name="source" /><!-- the device to mount, e.g. /dev/sda1 -->
|
<xs:element name="source" /><!-- the device to mount, e.g. /dev/sda1 -->
|
||||||
<xs:element name="mountpt" /><!-- where to mount, e.g. /boot -->
|
<xs:element name="mountpt" /><!-- where to mount, e.g. /boot -->
|
||||||
<xs:element name="type" /><!-- the filesystem type. optional; should normally be auto-detected. -->
|
<xs:element name="type" /><!-- the filesystem type. optional; should normally be auto-detected. -->
|
||||||
@ -126,10 +127,18 @@
|
|||||||
<!-- BEGIN BOOTLOADER -->
|
<!-- BEGIN BOOTLOADER -->
|
||||||
<xs:element name="bootloader">
|
<xs:element name="bootloader">
|
||||||
<xs:element name="type" /><!-- the type of bootloader. one of "grub", "lilo", "syslinux"... -->
|
<xs:element name="type" /><!-- the type of bootloader. one of "grub", "lilo", "syslinux"... -->
|
||||||
|
<xs:element name="efi" /><!-- boolean. UEFI support. if false, strictly MBR. -->
|
||||||
|
<xs:element name="where" /><!-- if efi is true, the mountpoint for the ESP (from within the chroot). if false, the device (or partition) to install the bootloader on. -->
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<!-- END BOOTLOADER -->
|
<!-- END BOOTLOADER -->
|
||||||
|
|
||||||
<!-- BEGIN CUSTOM SCRIPT -->
|
<!-- BEGIN CUSTOM SCRIPT -->
|
||||||
|
<xs:element name="scripts">
|
||||||
|
<xs:element name="script">
|
||||||
|
<xs:element name="uri" /><!-- a URI where to find the file. http://, https://, ftp://, file://, etc. -->
|
||||||
|
<xs:element name="lang" /><!-- optional. the language of the script. "bash", "python3", "python2", "awk" (if you're insane), etc. -->
|
||||||
|
</xs:element>
|
||||||
|
</xs:element>
|
||||||
<!-- END CUSTOM SCRIPT -->
|
<!-- END CUSTOM SCRIPT -->
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:schema>
|
</xs:schema>
|
62
aifverify.py
Executable file
62
aifverify.py
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import io
|
||||||
|
from lxml import etree
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
# Validate in the form of file:XSD/namespace.
|
||||||
|
xmlfiles = {}
|
||||||
|
#xmlfiles['aif.xml'] = 'https://aif.square-r00t.net/aif.xsd'
|
||||||
|
xmlfiles['aif.xml'] = 'aif.xsd'
|
||||||
|
|
||||||
|
def validXSD(xsdfile):
|
||||||
|
print("Checking XSD: ", xsdfile)
|
||||||
|
webres = False
|
||||||
|
if re.match('^(https?|ftp)', xsdfile, re.IGNORECASE):
|
||||||
|
webres = True
|
||||||
|
if not webres:
|
||||||
|
with open('{0}/{1}'.format(cwd, xsdfile), 'rb') as f:
|
||||||
|
xsd_in = f.read()
|
||||||
|
else:
|
||||||
|
with urlopen(xsdfile) as f:
|
||||||
|
xsd_in = f.read()
|
||||||
|
xsd = False
|
||||||
|
try:
|
||||||
|
xsd_in = io.BytesIO(xsd_in)
|
||||||
|
xmlschema_doc = etree.parse(xsd_in)
|
||||||
|
xsd = etree.XMLSchema(xmlschema_doc)
|
||||||
|
except:
|
||||||
|
print('XSD: {0} failed.'.format(xsdfile))
|
||||||
|
return(xsd)
|
||||||
|
|
||||||
|
def validXML(xml, xsd):
|
||||||
|
print("Checking XML: ", xml)
|
||||||
|
xmlfile = xml
|
||||||
|
with open('{0}/{1}'.format(cwd, xml), 'rb') as f:
|
||||||
|
xml_in = f.read()
|
||||||
|
valid = False
|
||||||
|
try:
|
||||||
|
xml_in = io.BytesIO(xml_in)
|
||||||
|
xml = etree.parse(xml_in)
|
||||||
|
valid = xsd.validate(xml)
|
||||||
|
except:
|
||||||
|
print('XML: {0} failed.'.format(xmlfile))
|
||||||
|
return(valid)
|
||||||
|
|
||||||
|
def allValidXML(xmlfiles):
|
||||||
|
for key,value in xmlfiles.items():
|
||||||
|
xmlfile = key
|
||||||
|
xsdfile = xmlfiles[xmlfile]
|
||||||
|
xml = False
|
||||||
|
xsdobj = validXSD(xsdfile)
|
||||||
|
xml = validXML(xmlfile, xsdobj)
|
||||||
|
return(xml)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
allValidXML(xmlfiles)
|
Loading…
Reference in New Issue
Block a user