[molecules] add Amazon EC2 ext3-based image generation specs

This commit is contained in:
Fabio Erculiani 2011-07-22 13:40:47 +02:00
parent 1756f52a5c
commit 3621eda846
5 changed files with 260 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# Use abs path, otherwise daily builds automagic won't work
# For further documentation, see the file above:
%import /sabayon/molecules/spinbase-amazon-ami-image-template.common
# pre chroot command, example, for 32bit chroots on 64bit system, you always
# have to append "linux32" this is useful for inner_chroot_script
# prechroot:
# Path to source ISO file (MANDATORY)
source_iso: /sabayon/iso/Sabayon_Linux_SpinBase_DAILY_amd64.iso
release_version: 6
image_name: Sabayon_Linux_SpinBase_6_amd64_ami.img

View File

@ -0,0 +1,13 @@
# Use abs path, otherwise daily builds automagic won't work
# For further documentation, see the file above:
%import /sabayon/molecules/spinbase-amazon-ami-image-template.common
# 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: /sabayon/iso/Sabayon_Linux_SpinBase_DAILY_x86.iso
release_version: 6
image_name: Sabayon_Linux_SpinBase_6_x86_ami.img

View File

@ -0,0 +1,126 @@
# WARNING:
# variables in your .spec files importing this .common header,
# DO NOT override the ones set here, but rather their values will
# be concatenated.
# So, if this files has:
# my_variable: hello_world
# And you import this (through %import file.common) and set
# my_variable: go_to_hell
# You will get my_variable containing: "hello_world go_to_hell"
# It doesn't work like in programming languages!
# Define an alternative execution strategy, in this case, the value must be
execution_strategy: iso_to_image
# Error script command, executed when something went wrong and molecule has
# to terminate the execution
# Variables exported:
# LOOP_DEVICE = loop device (/dev/loopN) currently in use
error_script: /sabayon/scripts/image_error_script.sh
# Outer chroot script command, to be executed outside destination chroot before
# before entering it (and before inner_chroot_script)
outer_chroot_script: /sabayon/scripts/remaster_pre.sh
# Inner chroot script command, to be executed inside destination chroot before
# packing it
inner_chroot_script: /sabayon/scripts/remaster_generic_inner_chroot_script.sh
# Inner chroot script command, to be executed inside destination chroot after
# packages installation and removal
inner_chroot_script_after: /sabayon/scripts/image_generic_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: /sabayon/scripts/remaster_post.sh
# Pre-image building script. Hook called before image file creation
# Variables exported:
# TMP_IMAGE_PATH = path pointing to the temporary destination image file
# LOOP_DEVICE = loop device (/dev/loopN) currently in use
# pre_image_script: /sabayon/scripts/pre_image_script.sh
# Post-image building script. Hook called after image file creation and move
# into destination directory.
# Variables exported:
# IMAGE_PATH = path pointing to the destination image file
# IMAGE_CHECKSUM_PATH = path pointing to the destination image file checksum (md5)
# post_image_script: /sabayon/scripts/post_image_script.sh
# Destination directory for the image path (MANDATORY)
destination_image_directory: /sabayon/images
# Specify an alternative image file name (image file name will be automatically
# produced otherwise)
# image_name:
# Specify the image file size in Megabytes. This is mandatory.
# To avoid runtime failure, make sure the image is large enough to fit your
# chroot data.
# Example: 5000 (means: ~5GB)
# Example: 15000 (means: ~15GB)
image_mb: 5000
# Either set this to "yes" or "no" if you want your image to be filled with
# random data instead of zeroes. urandom is used, fallback is: random.
# Default is: no
# image_randomize:
# Specify an image filesystem formatter that takes a single argument , which is
# the image device (by design, a loop device is passed to this executable).
# Default is: mkfs.ext3
# image_formatter:
# Specify an image file mount command. Two arguments are passed: (1) a loop
# device (/dev/loopN), (2) a temporary destination directory.
# Default is: mount -o loop,rw
# image_mounter:
# Specify am image file unmount command. One arguments is passed: mount point.
# Default is: umount
# image_umounter:
# 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:
# List of packages that would be removed from chrooted system (comma separated)
packages_to_remove:
app-admin/anaconda,
net-misc/networkmanager,
net-firewall/ufw,
sys-kernel/linux-sabayon
# 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:
app-admin/ec2-ami-tools,
net-misc/dhcpcd,
sys-kernel/linux-xen-domU,
sys-process/atop
# 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: no
# Directories to remove completely (comma separated)
# paths_to_remove:
# Directories to empty (comma separated)
# paths_to_empty:

19
scripts/image_error_script.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
if [ -d "${CHROOT_DIR}/proc" ]; then
echo "Unmounting ${CHROOT_DIR}/proc"
umount "${CHROOT_DIR}/proc"
fi
CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages"
if [ -d "${CHROOT_PKGS_DIR}" ]; then
echo "Umounting bind to ${CHROOT_PKGS_DIR}"
umount "${CHROOT_PKGS_DIR}" || exit 1
fi
echo "trying to umount ${CHROOT_DIR}"
umount "${CHROOT_DIR}"
#if [ -n "${LOOP_DEVICE}" ]; then
# echo "trying to umount loop device ${LOOP_DEVICE}"
# /sbin/losetup -d "${LOOP_DEVICE}"
#fi

View File

@ -0,0 +1,89 @@
#!/bin/sh
echo
echo "Configuring AMI chroot"
echo
/usr/sbin/env-update && source /etc/profile
# setup networking, make sure networkmanager is gone
rc-update del networkmanager default &> /dev/null
# add eth0, should get dhcp by default already
rc-update add net.eth0 default
# drop ufw
rc-update del ufw default
# drop other useless services
rc-update del sabayonlive boot
rc-update del x-setup boot
# Enable ssh
rc-update add sshd default
# setup default root password
echo "root:sabayonamichangeme" | chpasswd
# setup UTC clock
sed -i 's:clock=".*":clock="UTC":' /etc/conf.d/hwclock || exit 1
# setup fstab
# TODO: really needed?
echo "# molecule generated fstab
/dev/sda1 / ext3 defaults 1 1
/dev/sdb /mnt ext3 defaults 0 0
none /dev/shm tmpfs defaults 0 0" > /etc/fstab
echo -5 | equo conf update
mount -t proc proc /proc
export ETP_NONINTERACTIVE=1
# need to install grub-1
equo install sys-boot/grub:0 || exit 1
# remove grub-2
equo remove sys-boot/grub:2 --nodeps --force-system || exit 1
# configure grub-1 config
kernel_bin=$(ls /boot/kernel-genkernel-* | sort | tail -n 1)
# we need a bzImage
#initrd_bin=$(ls /boot/initramfs-genkernel-* | sort | tail -n 1)
rm -f /boot/grub/grub.cfg
echo "default 0
timeout 3
title EC2
root (hd0)
kernel ${kernel_bin} root=/dev/sda1
" > /boot/grub/grub.conf
# initrd ${initrd_bin}
# Generate list of installed packages
equo query list installed -qv > /etc/sabayon-pkglist
/lib/rc/bin/rc-depend -u
echo "Vacuum cleaning client db"
rm /var/lib/entropy/client/database/*/sabayonlinux.org -rf
rm /var/lib/entropy/client/database/*/sabayon-weekly -rf
equo rescue vacuum
# restore original repositories.conf (all mirrors were filtered for speed)
cp /etc/entropy/repositories.conf.example /etc/entropy/repositories.conf || exit 1
# cleanup log dir
rm /var/lib/entropy/logs -rf
# Generate openrc cache
touch /lib/rc/init.d/softlevel
/etc/init.d/savecache start
/etc/init.d/savecache zap
ldconfig
ldconfig
umount /proc
# remove hw hash
rm -f /etc/entropy/.hw.hash