This commit is contained in:
brent s 2017-03-08 07:48:29 -05:00
parent 130d5214e0
commit 459c48104b
2 changed files with 106 additions and 27 deletions

View File

@ -3,15 +3,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://aif.square-r00t.net aif.xsd"> xsi:schemaLocation="https://aif.square-r00t.net aif.xsd">
<storage> <storage>
<disk device="sda" type="gpt"> <disk device="/dev/sda" diskfmt="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/boot" order="2" /> <mount source="/dev/sda2" target="/mnt" order="1" />
<mount source="/dev/sda2" mountpt="/mnt" order="1" /> <mount source="/dev/sda1" target="/mnt/boot" order="2" />
</storage> </storage>
<network hostname="aiftest.square-r00t.net"> <network hostname="aiftest.square-r00t.net">
<iface name="auto" addressing="dhcp" /> <iface device="auto" address="auto" netproto="ipv4" />
</network> </network>
<system timezone="EST5EDT" locale="en_US.UTF-8" /> <system timezone="EST5EDT" locale="en_US.UTF-8" />
<user> <user>

125
aif.xsd
View File

@ -6,7 +6,7 @@
<!-- GLOBAL CUSTOM DATA TYPES --> <!-- GLOBAL CUSTOM DATA TYPES -->
<xs:simpleType name="diskdev"> <xs:simpleType name="diskdev">
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:pattern value="^/dev/[A-Za-z_/]+[0-9]+" /> <xs:pattern value="/dev/([A-Za-z0-9_]+/)?[A-Za-z0-9_]+[0-9]?" />
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>


@ -18,15 +18,42 @@


<xs:simpleType name="disksize"> <xs:simpleType name="disksize">
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:pattern value="^(\+|-)[0-9]+([KMGTP]|%)" /> <xs:pattern value="(\+|\-)?[0-9]+([KMGTP]|%)" />
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>


<xs:simpleType name="fstype"> <xs:simpleType name="fstype">
<xs:restriction base="xs:token"> <xs:restriction base="xs:token">
<xs:pattern value="^[a-z0-9]+$" /> <xs:pattern value="[a-z0-9]+" />
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="mntopts">
<xs:restriction base="xs:token">
<xs:pattern value="[A-Za-z0-9_\.\-]+(,[A-Za-z0-9_\.\-]+)*" />
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="iface">
<xs:restriction base="xs:token">
<!-- https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c#L20 lines 30-47. i have no idea if this will work. TODO: simplify, validate in-code. -->
<xs:pattern value="(auto|((en|sl|wl|ww)(b[0-9]+|c[a-z0-9]|o[0-9]+(n.*(d.*)?)?|s[0-9]+(f.*)?((n|d).*)?|x([A-Fa-f0-9]:){5}[A-Fa-f0-9]|(P.*)?p[0-9]+s[0-9]+(((f|n|d).*)|u.*)?)))" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="netaddress">
<xs:restriction base="xs:string">
<!-- this is a REALLY LAZY regex. matching IPv4 and IPv6 in regex is ugly as heck, so we do that in-code. this is just a gatekeeper. -->
<xs:pattern value="(auto|[0-9\.]+/[0-9]{,2}|([A-Za-z0-9:]+)/[0-9]+)" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="netproto">
<xs:restriction base="xs:token">
<xs:pattern value="(both|ipv4|ipv6)" />
</xs:restriction>
</xs:simpleType>
<!-- ROOT --> <!-- ROOT -->
<xs:element name="aif"> <xs:element name="aif">
<xs:complexType> <xs:complexType>
@ -35,42 +62,94 @@
<xs:element name="storage" minOccurs="1"> <xs:element name="storage" minOccurs="1">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<!-- BEGIN DISK -->
<xs:element name="disk" maxOccurs="unbounded" minOccurs="1"> <xs:element name="disk" maxOccurs="unbounded" minOccurs="1">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="part" minOccurs="1"> <xs:element name="part" minOccurs="1" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="num" type="xs:positiveInteger" /> <xs:attribute name="num" type="xs:positiveInteger" use="required" />
<xs:attribute name="name" type="xs:token" /> <xs:attribute name="name" type="xs:token" />
<xs:attribute name="size" type="disksize" /> <xs:attribute name="size" type="disksize" use="required" />
<xs:attribute name="fstype" type="fstype" /> <xs:attribute name="fstype" type="fstype" use="required" />
</xs:complexType> </xs:complexType>
<xs:unique name="unique-partnum"> <xs:unique name="unique-partnum">
<xs:selector xpath="part"/> <xs:selector xpath="part" />
<xs:field xpath="@num"/> <xs:field xpath="@num" />
</xs:unique> </xs:unique>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute name="device" type="diskdev" /> <xs:attribute name="device" type="diskdev" use="required" />
<xs:attribute name="diskfmt" type="diskfmt" /> <xs:attribute name="diskfmt" type="diskfmt" use="required" />
</xs:complexType> </xs:complexType>
<xs:unique name="unique-diskdev"> <xs:unique name="unique-diskdev">
<xs:selector xpath="disk"/> <xs:selector xpath="disk" />
<xs:field xpath="@device"/> <xs:field xpath="@device" />
</xs:unique> </xs:unique>
</xs:element> </xs:element>
<!-- BEGIN MOUNT -->
<xs:element name="mount" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="order" type="xs:integer" use="required" />
<xs:attribute name="source" type="diskdev" use="required" />
<xs:attribute name="target" type="xs:token" use="required" />
<xs:attribute name="fstype" type="fstype" />
<xs:attribute name="opts" type="mntopts" />
</xs:complexType>
<xs:unique name="unique-mnts">
<xs:selector xpath="mount" />
<xs:field xpath="@order" />
<xs:field xpath="@source" />
<xs:field xpath="@target" />
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- END MOUNT -->
<!-- END STORAGE -->
<!-- BEGIN NETWORK -->
<xs:element name="network" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="iface" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="device" type="iface" use="required" />
<xs:attribute name="address" type="netaddress" use="required" />
<xs:attribute name="netproto" type="netproto" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="hostname" type="xs:token" use="required" />
</xs:complexType>
<xs:unique name="unique-iface">
<xs:selector xpath="iface" />
<xs:field xpath="@address" />
<xs:field xpath="@netproto" />
</xs:unique>
</xs:element>
<!-- END NETWORK -->
<!--- BEGIN SCRIPTS -->
<xs:element name="scripts" maxOccurs="1" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="script" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="uri" type="scripturi" use="required" />
<xs:attribute name="lang" type="devlang" />
<xs:attribute name="order" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> <xs:unique name="unique-script">
<!-- END STORAGE --> <xs:selector xpath="script" />
<!-- <xs:field xpath="@order" />

</xs:unique>
<xs:element ref="mount" maxOccurs="unbounded" minOccurs="1" /> </xs:element>
<xs:element ref="network" maxOccurs="unbounded" minOccurs="1" /> <!-- END SCRIPTS -->
<xs:element ref="scripts" maxOccurs="unbounded" minOccurs="0" />
-->
</xs:all> </xs:all>
</xs:complexType><!-- </xs:complexType>
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element ref="system" maxOccurs="1" minOccurs="1" /> <xs:element ref="system" maxOccurs="1" minOccurs="1" />
@ -78,6 +157,6 @@
<xs:element ref="pacman" maxOccurs="1" minOccurs="1" /> <xs:element ref="pacman" maxOccurs="1" minOccurs="1" />
<xs:element ref="bootloader" maxOccurs="1" minOccurs="1" /> <xs:element ref="bootloader" maxOccurs="1" minOccurs="1" />
</xs:sequence> </xs:sequence>
</xs:complexType>--> </xs:complexType>
</xs:element> </xs:element>
</xs:schema> </xs:schema>