Use Molecule to create your own spin

If you are using the daily ISO, please report issues here to keep confusion down in other forums. Questions or issues with Molecule also here

Moderator: Moderators

Use Molecule to create your own spin

Postby joost » Tue Aug 09, 2011 19:27

This post is an attempt to help you understand and hopefully motivate you to create your own Sabayon Linux(tm) Spin.
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
User avatar
joost
Sagely Hen
 
Posts: 2332
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: Use Molecule to create your own spin

Postby sqlpython » Wed Aug 10, 2011 2:22

Thanks, answers some questions.
Something I have been meaning to look into and you saved me some trial and error.
Criticism accepted for Solutions that work. ;^)
Sabayon 11-DEBIAN 7-#Sid-Slackware 14-Calculate 13-
User avatar
sqlpython
Technological Hen
 
Posts: 340
Joined: Mon Jun 18, 2007 7:01
Location: If It Moves Compile It

Re: Use Molecule to create your own spin

Postby albfneto » Wed Aug 10, 2011 4:13

Joost, is basically the procedure athat i use for making my full KDE+GNOME spins.
i remasterize bimontly, the following will use KDE and GNOME3.
Image
ALBERTO FEDERMAN NETO
albfneto
albfneto@fcfrp.usp.br
Favorite Distros: Sabayon, Gentoo, Mandriva and OpenSUSE
User avatar
albfneto
Sagely Hen
 
Posts: 1304
Joined: Fri Nov 16, 2007 1:15
Location: Ribeirão Preto City, São Paulo State, Brazil

Re: Use Molecule to create your own spin.Bug in Molecule

Postby albfneto » Fri Aug 12, 2011 14:21

Bug in Molecule.

In the last days, i try to remasterize my complete KDE+GNOME spin, the first that will have GNOME3

But seems that molecule have Bug during the download of packages, Python errors and the remasterize process aborted.
until this moment, remasterize not possible, and download of the same two packages is there have a problem. this suggests
that is in the PACKAGE and not in the MOLECULE the problem..
the defective packages are: nvidia-cuda-sdk and gnome-games (of ther gnome3 version)

errors are type:

Code: Select all
l.ufpr.br
>>   ## Recebimento agregado: 1 itens
>>    # [1] sabayon.c3sl.ufpr.br => gnome-extra:gnome-games-3.0.2~0.tbz2
Exception in thread Thread-177:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/entropy/libraries/entropy/misc.py", line 353, in run
    self.__rc = self.__function(*self.__args, **self.__kwargs)
  File "/usr/lib/entropy/libraries/entropy/fetchers.py", line 1006, in do_download
    ds[th_id] = downloader.download()
  File "/usr/lib/entropy/libraries/entropy/fetchers.py", line 317, in download
    status = downloader()
  File "/usr/lib/entropy/libraries/entropy/fetchers.py", line 448, in _rsync_download
    sts = self.__fork_cmd(list_args, rsync_environ, rsync_list_extractor)
  File "/usr/lib/entropy/libraries/entropy/fetchers.py", line 232, in __fork_cmd
    pid, fd = pty.fork()
  File "/usr/lib64/python2.7/pty.py", line 107, in fork
    master_fd, slave_fd = openpty()
  File "/usr/lib64/python2.7/pty.py", line 29, in openpty
    master_fd, slave_name = _open_terminal()
  File "/usr/lib64/python2.7/pty.py", line 70, in _open_terminal
    raise os.error, 'out of pty devices'
OSError: out of pty devices

>>    ## Alguns pacotes não puderam ser obtidos.
>> [ChrootHandler|nprimrem.spec] executing kill

Image
ALBERTO FEDERMAN NETO
albfneto
albfneto@fcfrp.usp.br
Favorite Distros: Sabayon, Gentoo, Mandriva and OpenSUSE
User avatar
albfneto
Sagely Hen
 
Posts: 1304
Joined: Fri Nov 16, 2007 1:15
Location: Ribeirão Preto City, São Paulo State, Brazil

Re: Use Molecule to create your own spin

Postby joost » Fri Aug 12, 2011 14:29

please use the bugzilla for bugs.
User avatar
joost
Sagely Hen
 
Posts: 2332
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

@packages seems deprecated

Postby albfneto » Fri Aug 12, 2011 14:37

seems to me also, that the @packages, the sets of packages, are now deprecated in sabayon 6, because the equo commands, in that i tried the string @kde, @gnome etc... no more works, packages not found
Last edited by albfneto on Sun Aug 14, 2011 23:29, edited 1 time in total.
Image
ALBERTO FEDERMAN NETO
albfneto
albfneto@fcfrp.usp.br
Favorite Distros: Sabayon, Gentoo, Mandriva and OpenSUSE
User avatar
albfneto
Sagely Hen
 
Posts: 1304
Joined: Fri Nov 16, 2007 1:15
Location: Ribeirão Preto City, São Paulo State, Brazil

Re: Use Molecule to create your own spin

Postby albfneto » Sun Aug 14, 2011 23:23

I reported the Bug in Bugzilla, as Bug number 2620, and in only one day, Fabio Resolved.
working good now, Molecule....
in this moment i remasterize the new copy of my Sabayon Full, containing GNOME3 and KDE together.

at this moment, i consider GNOME3 unstable and difficult to use, bu i test it, since i know that it is the future.

a serious Rolling Release, as Sabayon, should not be "freezed" in GNOME2, only because GNOME2 have fans, as me...
Image
ALBERTO FEDERMAN NETO
albfneto
albfneto@fcfrp.usp.br
Favorite Distros: Sabayon, Gentoo, Mandriva and OpenSUSE
User avatar
albfneto
Sagely Hen
 
Posts: 1304
Joined: Fri Nov 16, 2007 1:15
Location: Ribeirão Preto City, São Paulo State, Brazil

Re: Use Molecule to create your own spin

Postby Nick_Djinn » Mon Sep 19, 2011 8:16

How would somebody add things like importing a fully customized firefox with bookmarks, addons, extensions, etc?

How would somebody get widgets set up for aggregated media that updates in a certain way for everyone using that specific distro/spin?

How would you add radio-broadcasts and give all users access to a shared cloud storage? Preferably one way, so that you can take files from the common storage but not delete them or use it to access the other computers?


A lot of these things could be done by taking a snapshot of someones desktop, like with remastersys, but I have no idea how to do this with Molecule.
Nick_Djinn
Young Hen
 
Posts: 26
Joined: Sun Sep 11, 2011 18:34


Return to ISO Testing & Molecule

Who is online

Users browsing this forum: No registered users and 1 guest