From da373bd9b44392fa6795921ff6148216ff02550b Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 27 Oct 2009 16:10:49 +0100 Subject: [PATCH] [molecule] add support for outer_chroot_script_after (to be executed after inner chroot script) --- molecule/specs/plugins/builtin.py | 28 +++++++++++++++++++++++++--- molecule/specs/plugins/remaster.py | 4 ++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/molecule/specs/plugins/builtin.py b/molecule/specs/plugins/builtin.py index ca6bc03..0272594 100644 --- a/molecule/specs/plugins/builtin.py +++ b/molecule/specs/plugins/builtin.py @@ -209,6 +209,24 @@ class ChrootHandler(GenericExecutionStep): ) ) + # run outer chroot script + exec_script = self.metadata.get('outer_chroot_script') + if exec_script: + os.environ['CHROOT_DIR'] = self.source_dir + self.Output.updateProgress("[%s|%s] %s: %s" % ( + blue("ChrootHandler"),darkred(self.spec_name), + _("spawning"),[exec_script], + ) + ) + rc = molecule.utils.exec_cmd([exec_script]) + if rc != 0: + self.Output.updateProgress("[%s|%s] %s: %s" % ( + blue("ChrootHandler"),darkred(self.spec_name), + _("outer chroot hook failed"),rc, + ) + ) + return rc + # run inner chroot script exec_script = self.metadata.get('inner_chroot_script') if exec_script: @@ -241,8 +259,8 @@ class ChrootHandler(GenericExecutionStep): ) return rc - # run outer chroot script - exec_script = self.metadata.get('outer_chroot_script') + # run outer chroot script after + exec_script = self.metadata.get('outer_chroot_script_after') if exec_script: os.environ['CHROOT_DIR'] = self.source_dir self.Output.updateProgress("[%s|%s] %s: %s" % ( @@ -254,7 +272,7 @@ class ChrootHandler(GenericExecutionStep): if rc != 0: self.Output.updateProgress("[%s|%s] %s: %s" % ( blue("ChrootHandler"),darkred(self.spec_name), - _("outer chroot hook failed"),rc, + _("outer chroot hook (after inner) failed"),rc, ) ) return rc @@ -563,6 +581,10 @@ class LivecdSpec(GenericSpec): 'cb': self.valid_path_string, 've': self.ve_string_stripper, }, + 'outer_chroot_script_after': { + 'cb': self.valid_path_string, + 've': self.ve_string_stripper, + }, 'destination_livecd_root': { 'cb': self.valid_path_string, 've': self.ve_string_stripper, diff --git a/molecule/specs/plugins/remaster.py b/molecule/specs/plugins/remaster.py index 09e0758..e9527a7 100644 --- a/molecule/specs/plugins/remaster.py +++ b/molecule/specs/plugins/remaster.py @@ -342,6 +342,10 @@ class RemasterSpec(GenericSpec): 'cb': self.valid_path_string, 've': self.ve_string_stripper, }, + 'outer_chroot_script_after': { + 'cb': self.valid_path_string, + 've': self.ve_string_stripper, + }, 'extra_mkisofs_parameters': { 'cb': self.always_valid, 've': self.ve_string_splitter,