restructure this a bit, and timezone done

This commit is contained in:
brent s. 2019-12-07 00:16:46 -05:00
parent 782ed08a3c
commit c7ce23ff0f
5 changed files with 31 additions and 6 deletions

View File

@ -1058,9 +1058,7 @@
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="timezone" type="aif:t_nonempty" use="required"/>
<xs:attribute name="chrootPath" type="aif:t_filepath" use="required"/>
<xs:attribute name="reboot" type="xs:boolean" use="optional" default="0"/>
<xs:attribute name="timezone" type="aif:t_nonempty" use="optional" default="UTC"/>
</xs:complexType>
</xs:element>
<!-- END SYSTEM -->
@ -1165,6 +1163,8 @@
<!-- END SCRIPTS -->
</xs:all>
<xs:attribute name="version" type="aif:t_nonempty" use="optional" default="master"/>
<xs:attribute name="chrootPath" type="aif:t_filepath" use="required"/>
<xs:attribute name="reboot" type="xs:boolean" use="optional" default="false"/>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -2,3 +2,7 @@ from . import locales
from . import console
from . import users
from . import services


def main(system_xml):
pass

View File

@ -105,3 +105,23 @@ class Locale(object):
os.chmod(cfg, 0o0644)
os.chown(cfg, 0, 0)
return()


class Timezone(object):
def __init__(self, timezone):
self.tz = timezone.strip().replace('.', '/')

def _verify(self, chroot_base):
tzfilebase = os.path.join('usr', 'share', 'zoneinfo', self.tz)
tzfile = os.path.join(chroot_base, tzfilebase)
if not os.path.isfile(tzfile):
raise ValueError('Invalid timezone')
return(tzfilebase)

def apply(self, chroot_base):
tzsrcfile = os.path.join('/', self._verify(chroot_base))
tzdestfile = os.path.join(chroot_base, 'etc', 'localtime')
if os.path.isfile(tzdestfile):
os.remove(tzdestfile)
os.symlink(tzsrcfile, tzdestfile)
return()

View File

@ -1 +0,0 @@
# TODO

View File

@ -2,7 +2,9 @@
<aif xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://aif-ng.io/"
xsi:schemaLocation="http://aif-ng.io/ http://aif-ng.io/aif.xsd"
version="v2_rewrite"><!-- When we release, this should match the tagged release (e.g. 0.2.0) -->
version="v2_rewrite"
chrootPath="/mnt/aif"
reboot="false"><!-- When we release, this should match the tagged release (e.g. 0.2.0) -->
<storage>
<blockDevices>
<disk id="sda" device="/dev/sda" diskFormat="gpt">
@ -162,7 +164,7 @@
</encryption>
</wireless>
</network>
<system timezone="EST5EDT" chrootPath="/mnt/aif" reboot="0">
<system timezone="EST5EDT">
<rootPassword>
<passwordPlain>1ns3cur3p4ssw0rd</passwordPlain>
</rootPassword>