In my example I will use a real-life example of a spin I made for my son Tom. He is 10 years old and likes to play games. So I wanted to create a nice live-DVD for him to show of the cool stuff daddy makes and give away some copies to the kids at his school.
I used a SpinBase iso as the basis for my project.
The spin will be named "Sabatom"
First of all you need the iso, obviously.
1. I place the downloaded iso /home/joost/REMASTER
2. Create your .spec file
Next I create my .spec file. This file will get parsed by molecule and it will execute everything in there step by step.
/home/joost/REMASTERsabatom-x86.spec
- Code: Select all
# Sabayon Linux 5 x86 GNOME Molecule remaster spec file
# The aim of this spec file is to add arbitrary applications & misc stuff
# to an already built ISO image via scripting (providing hooks that call
# user-defined scripts).
# squashfs, mkisofs needed
# Define an alternative execution strategy, in this case, the value must be
# "iso_remaster"
execution_strategy: iso_remaster
# pre chroot command, example, for 32bit chroots on 64bit system, you always
# have to append "linux32" this is useful for inner_chroot_script
prechroot: linux32
# Path to source ISO file (MANDATORY)
source_iso: /home/joost/REMASTER/Sabayon_Linux_SpinBase_DAILY_x86.iso
# 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
# 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
# Inner chroot script command, to be executed inside destination chroot after
# packages installation and removal
inner_chroot_script_after: /home/joost/REMASTER/sabatom/inner_chroot_script_after.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
# Pre-ISO building script. Hook to be able to copy kernel images in place, for example
pre_iso_script: /home/joost/REMASTER/sabatom/cdroot.sh
# Destination directory for the ISO image path (MANDATORY)
destination_iso_directory: /home/joost/REMASTER
# Destination ISO image name, call whatever you want.iso, not mandatory
destination_iso_image_name: Sabatom_x86.iso
# Output iso image title
iso_title: Sabatom_x86
# Alternative ISO file mount command (default is: mount -o loop -t iso9660)
# iso_mounter:
# Alternative ISO umounter command (default is: umount)
# iso_umounter:
# Alternative squashfs file mount command (default is: mount -o loop -t squashfs)
# squash_mounter:
# Alternative ISO squashfs umount command (default is: umount)
# squash_umounter:
# Merge directory with destination LiveCD root
# merge_livecd_root: /put/more/files/onto/CD/root
# List of packages that would be removed from chrooted system (comma separated)
packages_to_remove: www-client/lynx
# Custom shell call to packages removal (default is: equo remove)
# custom_packages_remove_cmd:
# List of packages that would be added from chrooted system (comma separated)
packages_to_add: @X,@wireless,x11-drivers/nvidia-drivers,x11-drivers/ati-drivers,@gnome,gnome-extra/gnome-power-manager,app-admin/anaconda,app-misc/anaconda-runtime-gui,games-simulation/flightgear,games-fps/tremulous,games-fps/warsow,games-fps/openarena,games-strategy/wormux,games-fps/nexuiz,games-strategy/warzone2100,games-puzzle/world-of-goo-demo,games-puzzle/monsterz,games-strategy/spring,games-util/springlobby,www-client/firefox,www-plugins/adobe-flash,app-office/openoffice,net-im/pidgin,net-im/skype,media-video/vlc,app-cdr/brasero,media-tv/xbmc,app-emulation/wine,app-cdr/acetoneiso
# Custom shell call to packages add (default is: equo install)
# custom_packages_add_cmd:
# Custom command for updating repositories (default is: equo update)
# repositories_update_cmd:
# Determine whether repositories update should be run (if packages_to_add is set)
# (default is: no), values are: yes, no.
execute_repositories_update: yes
# Directories to remove completely (comma separated)
# paths_to_remove:
# Directories to empty (comma separated)
# paths_to_empty:
Since this project will be x86 (32bits only) You must pay attention to prechroot. Since molecule chroots into the iso after extraction it must append linux32 incase you are working on a 64bits system. Also keep in mind that you cannot create a 64bits iso on a 32bits system!
So in the spec file you see the most important part of the whole thing here, the addition of packages. In Entropy we defined some sets to make things even more easy. @X set obviously pulls in Xorg and @wireless should give you good wireless support. I've added some additional drivers and games.
The spec file also calls some script hooks we want to have executed.
3. inner_chroot_script_after.sh
After the script is done with the the package installation we want to make sure everything is in place AND the downloaded Entropy packages are removed, we only need to ship the installed packages.
/home/joost/REMASTER/sabatom/inner_chroot_script_after.sh
- Code: Select all
#!/bin/bash
# Use gdm by default
sed -i 's/DISPLAYMANAGER=".*"/DISPLAYMANAGER="gdm"/g' /etc/conf.d/xdm
#Disable the autologin thing
sed -i 's/AutomaticLoginEnable=true/AutomaticLoginEnable=false/g' /usr/share/gdm/defaults.conf
sed -i 's/TimedLoginEnable=true/TimedLoginEnable=false/g' /usr/share/gdm/defaults.conf
sed -i 's/#DefaultSession=gnome.desktop/DefaultSession=gnome.desktop/g' /usr/share/gdm/defaults.conf
# automaticly start xdm
rc-update del xdm
rc-update add xdm boot
rc-update del sshd
rc-update add sshd default
rc-update del NetworkManager
rc-update add NetworkManager default
rc-update del consolekit
rc-update add consolekit boot
# to be sure, cleanup
equo cleanup
echo -5 | equo conf update
Now everything will be packed with squasfs, the file system we use to run the system from the DVD.
But there is still one detail I want to work out. You might not know this but the iso boot menu is NOT a grub menu, it is called isolinux. It has its own file on the Disc (outside the squashfs packed system). In this menu I'd like to change the default Sabayon.... text into my own text!
4. Tweak the isolinux menu
/home/joost/REMASTER/sabatom/cdroot.sh
- Code: Select all
#!/bin/bash
cp /home/joost/REMASTER/sabatom/isolinux.cfg "${CDROOT_DIR}/isolinux/isolinux.cfg"
Yes this actually copies a file to the yet to be created iso.
/home/joost/REMASTER/sabatom/isolinux.cfg
- Code: Select all
DEFAULT /boot/sabayon
GFXBOOT bootlogo
GFXBOOT-BACKGROUND 0xAAAAAA
APPEND root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=791 console=tty1 quiet --
LABEL sabayonnomusic
menu label ^Start Sabayom gamedisc
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=791 console=tty1 quiet --
LABEL install
menu label Graphical ^Installation
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=791 console=tty1 quiet installer-gui --
LABEL text-install
menu label Text ^Installation
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=verbose,theme:sabayon vga=791 console=tty1 quiet installer-text gentoo=nox nox --
LABEL genuine
menu label Start in Safe ^Mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=788 noproprietary genuine res=1024x768 refresh=60 hsync=43-51 pci=routeirq irqpoll noddc console=tty1 quiet nokvm --
LABEL console
menu label Start in ^Console mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=verbose,theme:sabayon vga=791 gentoo=nox nox console=tty1 quiet --
LABEL debug
menu label Deb^ug mode
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs console=tty1 --
LABEL memtest
menu label Memory ^test
kernel /boot/memtest
append -
LABEL hd
menu label ^Boot from first hard disk
localboot 0x80
append -
DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
5. Run molecule
Now that we have everything in place, let's make it happen!
From a root shell we can now run:
- Code: Select all
molecule /home/joost/REMASTERsabatom-x86.spec


