diff --git a/examples/specs/5-amd64-g.spec b/examples/specs/5-amd64-g.spec index c076b6c..56a69e8 100755 --- a/examples/specs/5-amd64-g.spec +++ b/examples/specs/5-amd64-g.spec @@ -42,6 +42,10 @@ destination_chroot: /sabayon # - kmerge.sh - setup kernel bins inner_chroot_script: /sabayon/scripts/inner_chroot_script.sh +# Outer chroot script command, to be executed outside destination chroot before +# before entering it (and AFTER inner_chroot_script) +# outer_chroot_script_after: /path/to/script/to/be/executed/outside/after + # Destination LiveCD root directory, where files are placed before getting mkisofs'ed # NOTE: data will be stored inside an auto-generated subdir destination_livecd_root: /sabayon diff --git a/examples/specs/5-amd64-k.spec b/examples/specs/5-amd64-k.spec index 59ec4e0..17d9ad7 100755 --- a/examples/specs/5-amd64-k.spec +++ b/examples/specs/5-amd64-k.spec @@ -42,6 +42,10 @@ destination_chroot: /sabayon # - kmerge.sh - setup kernel bins inner_chroot_script: /sabayon/scripts/inner_chroot_script.sh +# Outer chroot script command, to be executed outside destination chroot before +# before entering it (and AFTER inner_chroot_script) +# outer_chroot_script_after: /path/to/script/to/be/executed/outside/after + # Destination LiveCD root directory, where files are placed before getting mkisofs'ed # NOTE: data will be stored inside an auto-generated subdir destination_livecd_root: /sabayon diff --git a/examples/specs/5-x86-g-remaster-add-games.spec b/examples/specs/5-x86-g-remaster-add-games.spec index ec06073..e035544 100644 --- a/examples/specs/5-x86-g-remaster-add-games.spec +++ b/examples/specs/5-x86-g-remaster-add-games.spec @@ -15,14 +15,18 @@ prechroot: linux32 # Path to source ISO file (MANDATORY) source_iso: /sabayon/iso_images/Sabayon_5.0_G.iso -# Outer chroot script command, to be executed outside destination chroot before packing it -# - x86-archscript.sh - setup kernel bins +# Outer chroot script command, to be executed outside destination chroot before +# before entering it (and before inner_chroot_script) # outer_chroot_script: /path/to/script/to/be/executed/outside # Inner chroot script command, to be executed inside destination chroot before packing it # - kmerge.sh - setup kernel bins # inner_chroot_script: /sabayon/scripts/inner_chroot_script.sh +# Outer chroot script command, to be executed outside destination chroot before +# before entering it (and AFTER inner_chroot_script) +# outer_chroot_script_after: /path/to/script/to/be/executed/outside/after + # Extra mkisofs parameters, perhaps something to include/use your bootloader extra_mkisofs_parameters: -b isolinux/isolinux.bin -c isolinux/boot.cat diff --git a/examples/specs/5-x86-g.spec b/examples/specs/5-x86-g.spec index 16e27c8..b71c2b8 100755 --- a/examples/specs/5-x86-g.spec +++ b/examples/specs/5-x86-g.spec @@ -42,6 +42,10 @@ destination_chroot: /sabayon # - kmerge.sh - setup kernel bins inner_chroot_script: /sabayon/scripts/inner_chroot_script.sh +# Outer chroot script command, to be executed outside destination chroot before +# before entering it (and AFTER inner_chroot_script) +# outer_chroot_script_after: /path/to/script/to/be/executed/outside/after + # Destination LiveCD root directory, where files are placed before getting mkisofs'ed # NOTE: data will be stored inside an auto-generated subdir destination_livecd_root: /sabayon diff --git a/examples/specs/5-x86-k.spec b/examples/specs/5-x86-k.spec index 65d2c4f..2cc2c88 100755 --- a/examples/specs/5-x86-k.spec +++ b/examples/specs/5-x86-k.spec @@ -42,6 +42,10 @@ destination_chroot: /sabayon # - kmerge.sh - setup kernel bins inner_chroot_script: /sabayon/scripts/inner_chroot_script.sh +# Outer chroot script command, to be executed outside destination chroot before +# before entering it (and AFTER inner_chroot_script) +# outer_chroot_script_after: /path/to/script/to/be/executed/outside/after + # Destination LiveCD root directory, where files are placed before getting mkisofs'ed # NOTE: data will be stored inside an auto-generated subdir destination_livecd_root: /sabayon 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,