aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/conf.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2014-08-08 15:53:52 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-11 10:53:12 +0100
commitd8f9d05baee3abd4feb0a5b2f2afe467e919c6b9 (patch)
treeedc6ba90a220ad5bbba41998c3c5c82e1e97760d /scripts/lib/wic/conf.py
parenta43c1f94205d95c6eb77af2f0a494b4143f9eaf8 (diff)
downloadopenembedded-core-contrib-d8f9d05baee3abd4feb0a5b2f2afe467e919c6b9.tar.gz
wic: Rename /mic to /wic
As well as any other stray instances of mic in the codebase that can be removed. We don't really need to carry around legacy naming, and the history is in git. (From OE-Core rev: 598b120406dc1d2b7e377bd1ab6f0acbef034b22) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/conf.py')
-rw-r--r--scripts/lib/wic/conf.py102
1 files changed, 102 insertions, 0 deletions
diff --git a/scripts/lib/wic/conf.py b/scripts/lib/wic/conf.py
new file mode 100644
index 0000000000..d5419f8e94
--- /dev/null
+++ b/scripts/lib/wic/conf.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python -tt
+#
+# Copyright (c) 2011 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import os, sys, re
+import ConfigParser
+
+from wic import msger
+from wic import kickstart
+from wic.utils import misc, runner, errors
+
+
+def get_siteconf():
+ wic_path = os.path.dirname(__file__)
+ eos = wic_path.find('scripts') + len('scripts')
+ scripts_path = wic_path[:eos]
+
+ return scripts_path + "/lib/image/config/wic.conf"
+
+class ConfigMgr(object):
+ DEFAULTS = {'common': {
+ "distro_name": "Default Distribution",
+ "plugin_dir": "/usr/lib/wic/plugins", # TODO use prefix also?
+ },
+ 'create': {
+ "tmpdir": '/var/tmp/wic',
+ "outdir": './wic-output',
+
+ "release": None,
+ "logfile": None,
+ "name_prefix": None,
+ "name_suffix": None,
+ },
+ }
+
+ # make the manager class as singleton
+ _instance = None
+ def __new__(cls, *args, **kwargs):
+ if not cls._instance:
+ cls._instance = super(ConfigMgr, cls).__new__(cls, *args, **kwargs)
+
+ return cls._instance
+
+ def __init__(self, ksconf=None, siteconf=None):
+ # reset config options
+ self.reset()
+
+ if not siteconf:
+ siteconf = get_siteconf()
+
+ # initial options from siteconf
+ self._siteconf = siteconf
+
+ if ksconf:
+ self._ksconf = ksconf
+
+ def reset(self):
+ self.__ksconf = None
+ self.__siteconf = None
+
+ # initialize the values with defaults
+ for sec, vals in self.DEFAULTS.iteritems():
+ setattr(self, sec, vals)
+
+ def __set_ksconf(self, ksconf):
+ if not os.path.isfile(ksconf):
+ msger.error('Cannot find ks file: %s' % ksconf)
+
+ self.__ksconf = ksconf
+ self._parse_kickstart(ksconf)
+ def __get_ksconf(self):
+ return self.__ksconf
+ _ksconf = property(__get_ksconf, __set_ksconf)
+
+ def _parse_kickstart(self, ksconf=None):
+ if not ksconf:
+ return
+
+ ks = kickstart.read_kickstart(ksconf)
+
+ self.create['ks'] = ks
+ self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0]
+
+ self.create['name'] = misc.build_name(ksconf,
+ self.create['release'],
+ self.create['name_prefix'],
+ self.create['name_suffix'])
+
+configmgr = ConfigMgr()