[molecule] add post_iso_script hook support

This commit is contained in:
Fabio Erculiani
2010-06-05 12:03:48 +02:00
parent 63515f0f52
commit 4aad1c784b
9 changed files with 127 additions and 103 deletions
+12 -1
View File
@@ -60,9 +60,20 @@ merge_livecd_root: /sabayon/boot/standard
# Extra mkisofs parameters, perhaps something to include/use your bootloader
extra_mkisofs_parameters: -b isolinux/isolinux.bin -c isolinux/boot.cat
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# Pre-ISO building script. Hook called before making the iso image.
# environment variables exported:
# SOURCE_CHROOT_DIR: path pointing to source chroot directory
# CHROOT_DIR: path pointing to destination chroot directory (chroot being worked
# on)
# CDROOT_DIR: path pointing to CD/DVD root directory (ISO filesystem root)
pre_iso_script: /sabayon/scripts/cdroot.py
# Post-ISO building script. Hook called after having made the iso image and md5.
# environment variables exported:
# ISO_PATH: path to newly created ISO image file
# ISO_CHECKSUM_PATH: path to newly created ISO image checksum file
# post_iso_script: /sabayon/scripts/post_iso_script.sh
# Destination directory for the ISO image path
destination_iso_directory: /sabayon/iso
+12 -1
View File
@@ -60,9 +60,20 @@ merge_livecd_root: /sabayon/boot/standard
# Extra mkisofs parameters, perhaps something to include/use your bootloader
extra_mkisofs_parameters: -b isolinux/isolinux.bin -c isolinux/boot.cat
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# Pre-ISO building script. Hook called before making the iso image.
# environment variables exported:
# SOURCE_CHROOT_DIR: path pointing to source chroot directory
# CHROOT_DIR: path pointing to destination chroot directory (chroot being worked
# on)
# CDROOT_DIR: path pointing to CD/DVD root directory (ISO filesystem root)
pre_iso_script: /sabayon/scripts/cdroot.py
# Post-ISO building script. Hook called after having made the iso image and md5.
# environment variables exported:
# ISO_PATH: path to newly created ISO image file
# ISO_CHECKSUM_PATH: path to newly created ISO image checksum file
# post_iso_script: /sabayon/scripts/post_iso_script.sh
# Destination directory for the ISO image path
destination_iso_directory: /sabayon/iso
+12 -1
View File
@@ -35,9 +35,20 @@ source_iso: /sabayon/iso_images/Sabayon_5.0_G.iso
# before entering it (and AFTER inner_chroot_script)
# outer_chroot_script_after: /path/to/script/to/be/executed/outside/after
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# Pre-ISO building script. Hook called before making the iso image.
# environment variables exported:
# SOURCE_CHROOT_DIR: path pointing to source chroot directory
# CHROOT_DIR: path pointing to destination chroot directory (chroot being worked
# on)
# CDROOT_DIR: path pointing to CD/DVD root directory (ISO filesystem root)
# pre_iso_script: /sabayon/scripts/cdroot.py
# Post-ISO building script. Hook called after having made the iso image and md5.
# environment variables exported:
# ISO_PATH: path to newly created ISO image file
# ISO_CHECKSUM_PATH: path to newly created ISO image checksum file
# post_iso_script: /sabayon/scripts/post_iso_script.sh
# Destination directory for the ISO image path (MANDATORY)
destination_tar_directory: /home/fabio
+12 -1
View File
@@ -41,9 +41,20 @@ source_iso: /sabayon/iso_images/Sabayon_5.0_G.iso
# Extra mkisofs parameters, perhaps something to include/use your bootloader
extra_mkisofs_parameters: -b isolinux/isolinux.bin -c isolinux/boot.cat
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# Pre-ISO building script. Hook called before making the iso image.
# environment variables exported:
# SOURCE_CHROOT_DIR: path pointing to source chroot directory
# CHROOT_DIR: path pointing to destination chroot directory (chroot being worked
# on)
# CDROOT_DIR: path pointing to CD/DVD root directory (ISO filesystem root)
# pre_iso_script: /sabayon/scripts/cdroot.py
# Post-ISO building script. Hook called after having made the iso image and md5.
# environment variables exported:
# ISO_PATH: path to newly created ISO image file
# ISO_CHECKSUM_PATH: path to newly created ISO image checksum file
# post_iso_script: /sabayon/scripts/post_iso_script.sh
# Destination directory for the ISO image path (MANDATORY)
destination_iso_directory: /home/fabio
+12 -1
View File
@@ -60,9 +60,20 @@ merge_livecd_root: /sabayon/boot/standard
# Extra mkisofs parameters, perhaps something to include/use your bootloader
extra_mkisofs_parameters: -b isolinux/isolinux.bin -c isolinux/boot.cat
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# Pre-ISO building script. Hook called before making the iso image.
# environment variables exported:
# SOURCE_CHROOT_DIR: path pointing to source chroot directory
# CHROOT_DIR: path pointing to destination chroot directory (chroot being worked
# on)
# CDROOT_DIR: path pointing to CD/DVD root directory (ISO filesystem root)
pre_iso_script: /sabayon/scripts/cdroot.py
# Post-ISO building script. Hook called after having made the iso image and md5.
# environment variables exported:
# ISO_PATH: path to newly created ISO image file
# ISO_CHECKSUM_PATH: path to newly created ISO image checksum file
# post_iso_script: /sabayon/scripts/post_iso_script.sh
# Destination directory for the ISO image path
destination_iso_directory: /sabayon/iso
+12 -1
View File
@@ -60,9 +60,20 @@ merge_livecd_root: /sabayon/boot/standard
# Extra mkisofs parameters, perhaps something to include/use your bootloader
extra_mkisofs_parameters: -b isolinux/isolinux.bin -c isolinux/boot.cat
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# Pre-ISO building script. Hook called before making the iso image.
# environment variables exported:
# SOURCE_CHROOT_DIR: path pointing to source chroot directory
# CHROOT_DIR: path pointing to destination chroot directory (chroot being worked
# on)
# CDROOT_DIR: path pointing to CD/DVD root directory (ISO filesystem root)
pre_iso_script: /sabayon/scripts/cdroot.py
# Post-ISO building script. Hook called after having made the iso image and md5.
# environment variables exported:
# ISO_PATH: path to newly created ISO image file
# ISO_CHECKSUM_PATH: path to newly created ISO image checksum file
# post_iso_script: /sabayon/scripts/post_iso_script.sh
# Destination directory for the ISO image path
destination_iso_directory: /sabayon/iso
-74
View File
@@ -1,74 +0,0 @@
# Molecule example .spec file
# Define an alternative execution strategy, in this case, the value must be
# "livecd"
# execution_strategy: livecd
# pre chroot command, example, for 32bit chroots on 64bit system, you always have to append "linux32"
# prechroot: linux32
# Release string
# release_string: Sabayon Linux
# Release Version
# release_version: 4
# Release Version string description
# release_desc: Lite MCE
# Release file (inside chroot)
# release_file: /etc/sabayon-edition
# Source chroot directory, where files are pulled from
# source_chroot: /var/tmp/catalyst/tmp/stage1-amd64-2006.0
# Destination chroot directory, where files are pushed to before creating the squashfs image
# NOTE: data will be stored inside an auto-generated subdir
# destination_chroot: /var/tmp/catalyst/tmp/stage1-amd64-2006.0/default/livecd-stage2-amd64-2006.0
# Merge directory with destination chroot
# merge_destination_chroot: /path/to/your/chroot/overlay
# Extra mirror (r)sync parameters
# extra_rsync_parameters:
# Error script command, executed when something went wrong and molecule has to terminate the execution
# environment variables exported:
# - CHROOT_DIR: path to chroot directory, if any
# - CDROOT_DIR: path to livecd root directory, if any
# - SOURCE_CHROOT_DIR: path from where chroot is copied for final handling
# error_script: /path/to/script/to/be/executed/outside/after
# Outer chroot script command, to be executed outside destination chroot before packing it
# outer_chroot_script: /path/to/script/to/be/executed/outside
# Inner chroot script command, to be executed inside destination chroot before packing it
# inner_chroot_script: /path/to/script/to/be/executed/inside
# 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: /path/to/dest/livecd
# Merge directory with destination LiveCD root
# merge_livecd_root: /path/to/your/configured/bootloader dir
# Extra mksquashfs parameters
# extra_mksquashfs_parameters:
# Extra mkisofs parameters, perhaps something to include/use your bootloader
# extra_mkisofs_parameters:
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
# pre_iso_script:
# Destination directory for the ISO image path
# destination_iso_directory:
# Destination ISO image name, call whatever you want.iso, not mandatory
# destination_iso_image_name:
# Directories to remove completely (comma separated)
# paths_to_remove: /path/to/a, /path/to/b
# Directories to empty (comma separated)
# paths_to_empty: /path/to/a, /path/to/b
+51 -23
View File
@@ -465,6 +465,8 @@ class CdrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
MD5_EXT = ".md5"
def __init__(self, *args, **kwargs):
GenericExecutionStep.__init__(self, *args, **kwargs)
@@ -501,6 +503,27 @@ class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
_("executing pre_run"),
)
)
# run pre iso script
exec_script = self.metadata.get('pre_iso_script')
if exec_script:
os.environ['SOURCE_CHROOT_DIR'] = self.source_chroot
os.environ['CHROOT_DIR'] = self.chroot_dir
os.environ['CDROOT_DIR'] = self.source_path
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"), darkred(self.spec_name),
_("spawning"), exec_script,
)
)
rc = molecule.utils.exec_cmd(exec_script)
if rc != 0:
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"), darkred(self.spec_name),
_("pre iso hook failed"), rc,
)
)
return rc
return 0
def post_run(self):
@@ -509,6 +532,26 @@ class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
_("executing post_run"),
)
)
# run pre iso script
exec_script = self.metadata.get('post_iso_script')
if exec_script:
os.environ['ISO_PATH'] = self.dest_iso
os.environ['ISO_CHECKSUM_PATH'] = self.dest_iso + IsoHandler.MD5_EXT
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"), darkred(self.spec_name),
_("spawning"), exec_script,
)
)
rc = molecule.utils.exec_cmd(exec_script)
if rc != 0:
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"), darkred(self.spec_name),
_("post iso hook failed"), rc,
)
)
return rc
return 0
def kill(self, success = True):
@@ -524,26 +567,6 @@ class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
def run(self):
# run outer chroot script
exec_script = self.metadata.get('pre_iso_script')
if exec_script:
os.environ['SOURCE_CHROOT_DIR'] = self.source_chroot
os.environ['CHROOT_DIR'] = self.chroot_dir
os.environ['CDROOT_DIR'] = self.source_path
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"),darkred(self.spec_name),
_("spawning"),exec_script,
)
)
rc = molecule.utils.exec_cmd(exec_script)
if rc != 0:
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"),darkred(self.spec_name),
_("outer chroot hook failed"),rc,
)
)
return rc
self._output.output("[%s|%s] %s" % (
blue("IsoHandler"),darkred(self.spec_name),
_("building ISO image"),
@@ -579,15 +602,16 @@ class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
)
if os.path.isfile(self.dest_iso) and os.access(self.dest_iso,os.R_OK):
self._output.output("[%s|%s] %s: %s" % (
blue("IsoHandler"),darkred(self.spec_name),
_("generating md5 for"),self.dest_iso,
blue("IsoHandler"), darkred(self.spec_name),
_("generating md5 for"), self.dest_iso,
)
)
digest = molecule.utils.md5sum(self.dest_iso)
md5file = self.dest_iso+".md5"
md5file = self.dest_iso + IsoHandler.MD5_EXT
with open(md5file,"w") as f:
f.write("%s %s\n" % (digest,os.path.basename(self.dest_iso),))
f.flush()
return 0
class LivecdSpec(GenericSpec):
@@ -684,6 +708,10 @@ class LivecdSpec(GenericSpec):
'cb': self.valid_exec_first_list_item,
've': self.ve_string_splitter,
},
'post_iso_script': {
'cb': self.valid_exec_first_list_item,
've': self.ve_string_splitter,
},
'destination_iso_directory': {
'cb': self.valid_dir,
've': self.ve_string_stripper,
@@ -364,6 +364,10 @@ class RemasterSpec(GenericSpec):
'cb': self.valid_exec_first_list_item,
've': self.ve_string_splitter,
},
'post_iso_script': {
'cb': self.valid_exec_first_list_item,
've': self.ve_string_splitter,
},
'destination_iso_directory': {
'cb': self.valid_dir,
've': self.ve_string_stripper,