From c7ce23ff0fa5ee0cb9b5299b08164ff6816ff793 Mon Sep 17 00:00:00 2001 From: brent s Date: Sat, 7 Dec 2019 00:16:46 -0500 Subject: [PATCH] restructure this a bit, and timezone done --- aif.xsd | 6 +++--- aif/system/__init__.py | 4 ++++ aif/system/locales.py | 20 ++++++++++++++++++++ aif/system/main.py | 1 - examples/aif.xml | 6 ++++-- 5 files changed, 31 insertions(+), 6 deletions(-) delete mode 100644 aif/system/main.py diff --git a/aif.xsd b/aif.xsd index 5320c07..57bc91e 100644 --- a/aif.xsd +++ b/aif.xsd @@ -1058,9 +1058,7 @@ - - - + @@ -1165,6 +1163,8 @@ + + diff --git a/aif/system/__init__.py b/aif/system/__init__.py index e91eeb7..0a0bb0a 100644 --- a/aif/system/__init__.py +++ b/aif/system/__init__.py @@ -2,3 +2,7 @@ from . import locales from . import console from . import users from . import services + + +def main(system_xml): + pass diff --git a/aif/system/locales.py b/aif/system/locales.py index 2d85d39..9cc424e 100644 --- a/aif/system/locales.py +++ b/aif/system/locales.py @@ -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() diff --git a/aif/system/main.py b/aif/system/main.py deleted file mode 100644 index 4640904..0000000 --- a/aif/system/main.py +++ /dev/null @@ -1 +0,0 @@ -# TODO diff --git a/examples/aif.xml b/examples/aif.xml index 86d74c6..85e7844 100644 --- a/examples/aif.xml +++ b/examples/aif.xml @@ -2,7 +2,9 @@ + version="v2_rewrite" + chrootPath="/mnt/aif" + reboot="false"> @@ -162,7 +164,7 @@ - + 1ns3cur3p4ssw0rd