Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <silbe@activitycentral.com>2011-04-02 17:20:04 (GMT)
committer Anish Mangal <anish@sugarlabs.org>2011-09-19 13:27:48 (GMT)
commitf65f73a0786dfaefc810cc217c1a5d78f1f5e711 (patch)
tree6204f0f059b62049bd859bcd7f421ff4be4cbd9f
parent8ddb4b8e5e57df8bb0bb94b6eac4bd79f4a30b7d (diff)
Add support for (non-recursively) including config files in the build config
This is useful for building several similar, but distinct images (e.g. XO-1 vs. XO-1.5, Gnome vs. no Gnome).
-rw-r--r--doc/README7
-rwxr-xr-xosbuilder.py36
2 files changed, 43 insertions, 0 deletions
diff --git a/doc/README b/doc/README
index 16e6d4f..a8b8d47 100644
--- a/doc/README
+++ b/doc/README
@@ -158,6 +158,13 @@ modules_<ANYTHING>
Additional modules to include (allowing you to append to the list of
modules in an additional configuration file)
+include
+
+ Additional config files to include (non-recursive). Except for
+ global.modules, your main config will override values set in the
+ included configs. You can use all values defined in the DEFAULT
+ sections of the included configs for interpolation.
+
In general, options need to be set with care. Aim to stick with the
values shown in the examples where possible. For example, if you were
diff --git a/osbuilder.py b/osbuilder.py
index 7fa7750..d00ba05 100755
--- a/osbuilder.py
+++ b/osbuilder.py
@@ -283,6 +283,17 @@ class OsBuilder(object):
os.path.dirname(self.build_config)})
self.cfg.read(self.build_config)
+ # read in additional config files included by the build config for
+ # module list interpolations
+ if self.cfg.has_option('global', 'include'):
+ for file_name in self.cfg.get('global', 'include').split(','):
+ file_name = file_name.strip()
+ if not file_name:
+ continue
+
+ self.cfg.read(os.path.join(os.path.dirname(self.build_config),
+ file_name))
+
# read in defaults specified on the command line
if self.additional_defaults is not None:
self.cfg.read(self.additional_defaults)
@@ -327,6 +338,10 @@ class OsBuilder(object):
def read_config(self):
"""Read and validate config (including module defaults)"""
+ includes = []
+ if self.cfg.has_option('global', 'include'):
+ includes = self.cfg.get('global', 'include').split(',')
+
# reset config since we want to load the module defaults first
self.cfg = SafeConfigParser({'oob_config_dir':
os.path.dirname(self.build_config)})
@@ -348,9 +363,30 @@ class OsBuilder(object):
if self.additional_defaults is not None:
self.cfg.read(self.additional_defaults)
+ # read in additional config files included by the build config
+ for file_name in includes:
+ file_name = file_name.strip()
+ if not file_name:
+ continue
+
+ self.cfg.read(os.path.join(os.path.dirname(self.build_config),
+ file_name))
+
# now load the users config, overriding other settings where specified
self.cfg.read(self.build_config)
+ # check that the modules list is the same as with the initial config
+ # file load order
+ modules = []
+ for option in self.cfg.options('global'):
+ if not option.startswith('modules_') and option != "modules":
+ continue
+ modules.extend([module.strip() for module in self.cfg.get('global', option).split(',')])
+
+ if set(modules) != set(self.modules):
+ raise OsBuilderException('List of modules depends on config file load order: %r != %r' % (
+ sorted(set(modules)), sorted(set(self.modules))))
+
for section in self.cfg.sections():
m = re.match(r"[A-Za-z_][A-Za-z0-9_]*$", section)
if not m: