This is useful for building several similar, but distinct images (e.g. XO-1 vs. XO-1.5, Gnome vs. no Gnome).
Signed-off-by: Sascha Silbe <si...@activitycentral.com> --- doc/README | 7 +++++++ osbuilder.py | 36 ++++++++++++++++++++++++++++++++++++ 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: -- 1.7.4.1 _______________________________________________ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel