Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Dengler <martin@martindengler.com>2009-06-29 21:31:30 (GMT)
committer Martin Dengler <martin@martindengler.com>2009-06-30 11:35:31 (GMT)
commit0ae1da97a8da1f25c8d4cba1135e1f4cc9b17db8 (patch)
tree10e97b686c618c651be009ecb288865145240c25
parent628648f8d89fe8322e2867a5a56a673900683206 (diff)
refactor build process into smaller, more sensible, more restartable scripts
-rw-r--r--README.txt34
-rwxr-xr-xbootable-tree-to-removable-img.sh45
-rwxr-xr-xbootable-tree-to-xo.sh41
-rwxr-xr-xbuild20
-rwxr-xr-xlivecd-iso-to-bootable-tree.sh49
-rwxr-xr-xlivecd-iso-to-disk.sh686
-rwxr-xr-xmake_fake_device.sh71
-rw-r--r--olpc.fth.bootmenu41
-rw-r--r--soas-sugar.ks3
-rw-r--r--soas-xo.ks489
10 files changed, 791 insertions, 688 deletions
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..f15d227
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,34 @@
+
+Introduction
+-------------
+
+This set of scripts is for people that want to build their own
+Sugar/Fedora image customised for the the OLPC XO-1.
+
+This set of scripts:
+
+1) creates a livecd .ISO suitable for use booting an XO-1 with
+ Sugar/F11 via Fedora's livecd-creator tool
+
+2) creates a file that can be copied bit-for-bit (e.g., dd) onto a 4GB
+ removable drive from which Sugar/F11 can be booted
+
+3) creates a jffs2 .img, .crc, and .plc file set suitable for OFW's
+ copy-nand and NANDBlaster image-copying methods
+
+Invocaton
+-------------
+
+Scripts are written assuming that "build" is being run by a cron job
+that does the following (note the cd into 'images' and its effect on
+relative paths):
+
+#!/bin/bash
+set -e
+rm -rf images.prev
+mv images images.prev
+mkdir -p images
+cd images
+date >> buildlog
+time ../build >> buildlog 2>&1
+date >> buildlog
diff --git a/bootable-tree-to-removable-img.sh b/bootable-tree-to-removable-img.sh
new file mode 100755
index 0000000..08302fb
--- /dev/null
+++ b/bootable-tree-to-removable-img.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -x
+set -e
+set -o pipefail
+
+
+cleanup() {
+ [ -d "$TMP_MNT" ] && rm -rf $TMP_MNT
+}
+
+exitclean() {
+ echo "Cleaning up to exit..."
+ cleanup
+ exit 1
+}
+
+trap exitclean SIGINT SIGTERM
+
+
+ROOT=$1
+output_stem=${2:-soas}
+
+echo "Making removable image $ROOT --> $output_stem"
+
+TMP_MNT=$(mktemp -d ./removable.XXXXXX)
+
+device=`../make_fake_device.sh ${output_stem}.img`
+mount -t ext2 $device $TMP_MNT
+
+cp -a $ROOT/* $TMP_MNT
+
+cp ../olpc.fth.bootmenu $TMP_MNT/boot/olpc.fth
+
+umount $TMP_MNT
+losetup -d $device
+tar cf - ${output_stem}.img | lzma -1 > ${output_stem}.img.tar.lzma
+
+
+echo "Done making removable image $ROOT --> $output_stem"
+cleanup
+
+
+
+
diff --git a/bootable-tree-to-xo.sh b/bootable-tree-to-xo.sh
new file mode 100755
index 0000000..2ba138b
--- /dev/null
+++ b/bootable-tree-to-xo.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+set -x
+set -e
+
+PATH=$PATH:/usr/sbin
+
+cleanup() {
+ [ -d "$TMP_MNT" ] && rm -rf $TMP_MNT
+}
+
+exitclean() {
+ echo "Cleaning up to exit..."
+ cleanup
+ exit 1
+}
+
+trap exitclean SIGINT SIGTERM
+
+
+echo "Build jffs2 image $IMG"
+
+ROOT=$1
+IMG=${2:-${ROOT}.img}
+
+TMP_MNT=$(mktemp -d ./jffs2.XXXXXX)
+
+chmod a+rx $TMP_MNT/.
+
+cp -al $ROOT/* $TMP_MNT
+
+echo "(removing livesys scripts from image because they'll really foul it up if they run)"
+rm -f $TMP_MNT/etc/init.d/livesys*
+
+mkfs.jffs2 -n -e128KiB -r $TMP_MNT -o $IMG.tmp
+sumtool -n -p -e 128KiB -i $IMG.tmp -o $IMG
+rm $IMG.tmp
+crcimg $IMG
+
+echo "Done building jffs2 image $IMG"
+cleanup
diff --git a/build b/build
index c99a9dc..8dd8182 100755
--- a/build
+++ b/build
@@ -3,5 +3,21 @@
set -e
set -o pipefail
-python live.py
-python appliance.py
+python ../live.py
+
+stem=`ls -t *.iso | head -1 | sed -e "s/.iso//;"`
+
+../livecd-iso-to-bootable-tree.sh ${stem}.iso $stem
+
+echo "archiving bootable tree -> tarball..."
+tar -c -C $stem . | lzma -1 > ${stem}-files.tar.lzma
+
+../bootable-tree-to-removable-img.sh $stem ${stem}-removable
+
+../bootable-tree-to-xo.sh $stem ${stem}.img
+../../xo-image-digestor/image-digestor.sh ${stem}.img
+for ext in img crc plc ; do
+ rm -f soas.${ext}
+ cp -l ${stem}.${ext} soas.${ext}
+done
+
diff --git a/livecd-iso-to-bootable-tree.sh b/livecd-iso-to-bootable-tree.sh
new file mode 100755
index 0000000..29d418e
--- /dev/null
+++ b/livecd-iso-to-bootable-tree.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+set -e
+
+cleanup() {
+ [ -d "$EXTMNT" ] && umount $EXTMNT && rmdir $EXTMNT
+ [ -d "$SQUASHMNT" ] && umount $SQUASHMNT && rmdir $SQUASHMNT
+ [ -d "$ISOMNT" ] && umount $ISOMNT && rmdir $ISOMNT
+}
+
+exitclean() {
+ echo "Cleaning up to exit..."
+ cleanup
+ exit 1
+}
+
+trap exitclean SIGINT SIGTERM
+
+ISO=$(readlink -f "$1")
+ROOT=$(readlink -f "$2")
+
+ISOMNT=$(mktemp -d /media/isotmp.XXXXXX)
+mount -o loop,ro "$ISO" $ISOMNT || exitclean
+
+EXTIMG=$ISOMNT/LiveOS/ext3fs.img
+if [ -e $ISOMNT/LiveOS/squashfs.img ] ; then
+ SQUASHMNT=$(mktemp -d /media/squashtmp.XXXXXX)
+ mount -o loop,ro $ISOMNT/LiveOS/squashfs.img $SQUASHMNT || exitclean
+ EXTIMG=$SQUASHMNT/LiveOS/ext3fs.img
+fi
+
+EXTMNT=$(mktemp -d /media/exttmp.XXXXXX)
+mount -o loop,ro $EXTIMG $EXTMNT || exitclean
+
+echo "Create root filesystem..."
+
+mkdir -p $ROOT
+chmod a+rx $ROOT/.
+
+cp -a $EXTMNT/* $ROOT
+for initrd in $ISOMNT/isolinux/initrd*.img ; do
+ cp -p $initrd $ROOT/boot
+done
+for kernel in $ISOMNT/isolinux/vmlinuz* ; do
+ cp -p $kernel $ROOT/boot
+done
+
+echo "Done."
+cleanup
diff --git a/livecd-iso-to-disk.sh b/livecd-iso-to-disk.sh
deleted file mode 100755
index 3ee51b1..0000000
--- a/livecd-iso-to-disk.sh
+++ /dev/null
@@ -1,686 +0,0 @@
-#!/bin/bash
-# Convert a live CD iso so that it's bootable off of a USB stick
-# Copyright 2007 Red Hat, Inc.
-# Jeremy Katz <katzj@redhat.com>
-#
-# overlay/persistence enhancements by Douglas McClendon <dmc@viros.org>
-# GPT+MBR hybrid enhancements by Stewart Adam <s.adam@diffingo.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Library General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-
-export PATH=/sbin:/usr/sbin:$PATH
-
-usage() {
- echo "$0 [--format] [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] [--skipcopy] <isopath> <usbstick device>"
- exit 1
-}
-
-cleanup() {
- [ -d "$CDMNT" ] && umount $CDMNT && rmdir $CDMNT
- [ -d "$USBMNT" ] && umount $USBMNT && rmdir $USBMNT
-}
-
-exitclean() {
- echo "Cleaning up to exit..."
- cleanup
- exit 1
-}
-
-getdisk() {
- DEV=$1
-
- if [[ "$DEV" =~ "/dev/loop*" ]]; then
- device="$DEV"
- return
- fi
-
- p=$(udevadm info -q path -n $DEV)
- if [ -e /sys/$p/device ]; then
- device=$(basename /sys/$p)
- else
- device=$(basename $(readlink -f /sys/$p/../))
- fi
- if [ ! -e /sys/block/$device -o ! -e /dev/$device ]; then
- echo "Error finding block device of $DEV. Aborting!"
- exitclean
- fi
-
- device="/dev/$device"
- # FIXME: weird dev names could mess this up I guess
- p=/dev/`basename $p`
- partnum=${p##$device}
-}
-
-resetMBR() {
- if [[ "$DEV" =~ "/dev/loop*" ]]; then
- return
- fi
- getdisk $1
- # if efi, we need to use the hybrid MBR
- if [ -n "$efi" ];then
- if [ -f /usr/lib/syslinux/gptmbr.bin ]; then
- gptmbr='/usr/lib/syslinux/gptmbr.bin'
- elif [ -f /usr/share/syslinux/gptmbr.bin ]; then
- gptmbr='/usr/share/syslinux/gptmbr.bin'
- else
- echo "Could not find gptmbr.bin (syslinux)"
- exitclean
- fi
- # our magic number is LBA-2, offset 16 - (512+512+16)/$bs
- dd if=$device bs=16 skip=65 count=1 | cat $gptmbr - > $device
- else
- if [ -f /usr/lib/syslinux/mbr.bin ]; then
- cat /usr/lib/syslinux/mbr.bin > $device
- elif [ -f /usr/share/syslinux/mbr.bin ]; then
- cat /usr/share/syslinux/mbr.bin > $device
- else
- echo "Could not find mbr.bin (syslinux)"
- exitclean
- fi
- fi
-}
-
-checkMBR() {
- getdisk $1
-
- bs=$(mktemp /tmp/bs.XXXXXX)
- dd if=$device of=$bs bs=512 count=1 2>/dev/null || exit 2
-
- mbrword=$(hexdump -n 2 $bs |head -n 1|awk {'print $2;'})
- rm -f $bs
- if [ "$mbrword" = "0000" ]; then
- echo "MBR appears to be blank."
- echo "Do you want to replace the MBR on this device?"
- echo "Press Enter to continue or ctrl-c to abort"
- read
- resetMBR $1
- fi
-
- return 0
-}
-
-checkPartActive() {
- dev=$1
- getdisk $dev
-
- # if we're installing to whole-disk and not a partition, then we
- # don't need to worry about being active
- if [ "$dev" = "$device" ]; then
- return
- fi
- if [[ "$dev" =~ "/dev/loop*" ]]; then
- return
- fi
-
- if [ "$(/sbin/fdisk -l $device 2>/dev/null |grep $dev |awk {'print $2;'})" != "*" ]; then
- echo "Partition isn't marked bootable!"
- echo "You can mark the partition as bootable with "
- echo " # /sbin/parted $device"
- echo " (parted) toggle N boot"
- echo " (parted) quit"
- exitclean
- fi
-}
-
-createGPTLayout() {
- dev=$1
- getdisk $dev
-
- echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
- echo "Press Enter to continue or ctrl-c to abort"
- read
- umount ${device}? &> /dev/null
- /sbin/parted --script $device mklabel gpt
- partinfo=$(/sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart '"EFI System Partition"' fat32 17408 $(($size - 17408)) set 1 boot on
- USBDEV=${device}1
- # Sometimes automount can be _really_ annoying.
- echo "Waiting for devices to settle..."
- /sbin/udevadm settle
- sleep 5
- umount $USBDEV &> /dev/null
- /sbin/mkdosfs -n FEDORA $USBDEV
- USBLABEL="UUID=$(/lib/udev/vol_id -u $USBDEV)"
-}
-
-createMSDOSLayout() {
- dev=$1
- getdisk $dev
-
- echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
- echo "Press Enter to continue or ctrl-c to abort"
- read
- umount ${device}? &> /dev/null
- /sbin/parted --script $device mklabel msdos
- partinfo=$(/sbin/parted --script -m $device "unit b print" |grep ^$device:)
- size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
- /sbin/parted --script $device unit b mkpart primary fat32 17408 $(($size - 17408)) set 1 boot on
- USBDEV=${device}1
- # Sometimes automount can be _really_ annoying.
- echo "Waiting for devices to settle..."
- /sbin/udevadm settle
- sleep 5
- umount $USBDEV &> /dev/null
- /sbin/mkdosfs -n FEDORA $USBDEV
- USBLABEL="UUID=$(/lib/udev/vol_id -u $USBDEV)"
-}
-
-checkGPT() {
- dev=$1
- getdisk $dev
-
- if [ "$(/sbin/fdisk -l $device 2>/dev/null |grep -c GPT)" -eq "0" ]; then
- echo "EFI boot requires a GPT partition table."
- echo "This can be done manually or you can run with --format"
- exitclean
- fi
-
- partinfo=$(/sbin/parted --script -m $device "print" |grep ^$partnum:)
- volname=$(echo $partinfo |cut -d : -f 6)
- flags=$(echo $partinfo |cut -d : -f 7)
- if [ "$(echo $flags |grep -c boot)" = "0" ]; then
- echo "Partition isn't marked bootable!"
- echo "You can mark the partition as bootable with "
- echo " # /sbin/parted $device"
- echo " (parted) toggle N boot"
- echo " (parted) quit"
- exitclean
- fi
-}
-
-checkFilesystem() {
- dev=$1
-
- USBFS=$(/lib/udev/vol_id -t $dev)
- if [ "$USBFS" != "vfat" -a "$USBFS" != "msdos" -a "$USBFS" != "ext2" -a "$USBFS" != "ext3" ]; then
- echo "USB filesystem must be vfat or ext[23]"
- exitclean
- fi
-
- USBLABEL=$(/lib/udev/vol_id -u $dev)
- if [ -n "$USBLABEL" ]; then
- USBLABEL="UUID=$USBLABEL" ;
- else
- USBLABEL=$(/lib/udev/vol_id -l $dev)
- if [ -n "$USBLABEL" ]; then
- USBLABEL="LABEL=$USBLABEL"
- else
- echo "Need to have a filesystem label or UUID for your USB device"
- if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
- echo "Label can be set with /sbin/dosfslabel"
- elif [ "$USBFS" = "ext2" -o "$USBFS" = "ext3" ]; then
- echo "Label can be set with /sbin/e2label"
- fi
- exitclean
- fi
- fi
-
- if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
- mountopts="-o shortname=winnt,umask=0077"
- fi
-}
-
-checkSyslinuxVersion() {
- if [ ! -x /usr/bin/syslinux ]; then
- echo "You need to have syslinux installed to run this script"
- exit 1
- fi
- if ! syslinux 2>&1 | grep -qe -d; then
- SYSLINUXPATH=""
- elif [ -n "$multi" ]; then
- SYSLINUXPATH="$LIVEOS/syslinux"
- else
- SYSLINUXPATH="syslinux"
- fi
-}
-
-checkMounted() {
- dev=$1
- if grep -q "^$dev " /proc/mounts ; then
- echo "$dev is mounted, please unmount for safety"
- exitclean
- fi
- if grep -q "^$dev " /proc/swaps; then
- echo "$dev is in use as a swap device, please disable swap"
- exitclean
- fi
-}
-
-checkint() {
- if ! test $1 -gt 0 2>/dev/null ; then
- usage
- fi
-}
-
-if [ $(id -u) != 0 ]; then
- echo "You need to be root to run this script"
- exit 1
-fi
-
-cryptedhome=1
-keephome=1
-homesizemb=0
-swapsizemb=0
-overlaysizemb=0
-LIVEOS=LiveOS
-
-HOMEFILE="home.img"
-while [ $# -gt 2 ]; do
- case $1 in
- --overlay-size-mb)
- checkint $2
- overlaysizemb=$2
- shift
- ;;
- --home-size-mb)
- checkint $2
- homesizemb=$2
- shift
- ;;
- --swap-size-mb)
- checkint $2
- swapsizemb=$2
- shift
- ;;
- --crypted-home)
- cryptedhome=1
- ;;
- --unencrypted-home)
- cryptedhome=""
- ;;
- --delete-home)
- keephome=""
- ;;
- --noverify)
- noverify=1
- ;;
- --reset-mbr|--resetmbr)
- resetmbr=1
- ;;
- --efi|--mactel)
- efi=1
- ;;
- --format)
- format=1
- ;;
- --skipcopy)
- skipcopy=1
- ;;
- --xo)
- xo=1
- skipcompress=1
- ;;
- --xo-no-home)
- xonohome=1
- ;;
- --compress)
- skipcompress=""
- ;;
- --skipcompress)
- skipcompress=1
- ;;
- --extra-kernel-args)
- kernelargs=$2
- shift
- ;;
- --force)
- force=1
- ;;
- --livedir)
- LIVEOS=$2
- shift
- ;;
- --multi)
- multi=1
- ;;
- *)
- echo "invalid arg -- $1"
- usage
- ;;
- esac
- shift
-done
-
-ISO=$(readlink -f "$1")
-USBDEV=$(readlink -f "$2")
-
-if [ -z "$ISO" ]; then
- usage
-fi
-
-if [ ! -b "$ISO" -a ! -f "$ISO" ]; then
- usage
-fi
-
-# FIXME: If --format is given, we shouldn't care and just use /dev/foo1
-if [ -z "$USBDEV" -o ! -b "$USBDEV" ]; then
- usage
-fi
-
-if [ -z "$noverify" ]; then
- # verify the image
- echo "Verifying image..."
- checkisomd5 --verbose "$ISO"
- if [ $? -ne 0 ]; then
- echo "Are you SURE you want to continue?"
- echo "Press Enter to continue or ctrl-c to abort"
- read
- fi
-fi
-
-# do some basic sanity checks.
-checkMounted $USBDEV
-if [ -n "$format" ];then
- # checks for a valid filesystem
- if [ -n "$efi" ];then
- createGPTLayout $USBDEV
- else
- createMSDOSLayout $USBDEV
- fi
-fi
-checkFilesystem $USBDEV
-if [ -n "$efi" ]; then
- checkGPT $USBDEV
-fi
-checkSyslinuxVersion
-# Because we can't set boot flag for EFI Protective on msdos partition tables
-[ -z "$efi" ] && checkPartActive $USBDEV
-[ -n "$resetmbr" ] && resetMBR $USBDEV
-checkMBR $USBDEV
-
-
-if [ "$overlaysizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
- if [ "$overlaysizemb" -gt 2047 ]; then
- echo "Can't have an overlay of 2048MB or greater on VFAT"
- exitclean
- fi
-fi
-
-if [ "$homesizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
- if [ "$homesizemb" -gt 2047 ]; then
- echo "Can't have a home overlay greater than 2048MB on VFAT"
- exitclean
- fi
-fi
-
-if [ "$swapsizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
- if [ "$swapsizemb" -gt 2047 ]; then
- echo "Can't have a swap file greater than 2048MB on VFAT"
- exitclean
- fi
-fi
-
-# FIXME: would be better if we had better mountpoints
-CDMNT=$(mktemp -d /media/cdtmp.XXXXXX)
-mount -o loop,ro "$ISO" $CDMNT || exitclean
-USBMNT=$(mktemp -d /media/usbdev.XXXXXX)
-mount $mountopts $USBDEV $USBMNT || exitclean
-
-trap exitclean SIGINT SIGTERM
-
-if [ -f "$USBMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then
- echo "ERROR: Requested keeping existing /home and specified a size for /home"
- echo "Please either don't specify a size or specify --delete-home"
- exitclean
-fi
-
-if [ -n "$efi" -a ! -d $CDMNT/EFI/boot ]; then
- echo "ERROR: This live image does not support EFI booting"
- exitclean
-fi
-
-# let's try to make sure there's enough room on the stick
-if [ -d $CDMNT/LiveOS ]; then
- check=$CDMNT/LiveOS
-else
- check=$CDMNT
-fi
-if [ -d $USBMNT/$LIVEOS ]; then
- tbd=$(du -s -B 1M $USBMNT/$LIVEOS | awk {'print $1;'})
- [ -f $USBMNT/$LIVEOS/$HOMEFILE ] && homesz=$(du -s -B 1M $USBMNT/$LIVEOS/$HOMEFILE | awk {'print $1;'})
- [ -n "$homesz" -a -n "$keephome" ] && tbd=$(($tbd - $homesz))
-else
- tbd=0
-fi
-livesize=$(du -s -B 1M $check | awk {'print $1;'})
-if [ -n "$skipcompress" ]; then
- mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT
- livesize=$(du -s -B 1M $CDMNT/LiveOS/ext3fs.img | awk {'print $1;'})
- umount $CDMNT
-fi
-free=$(df -B1M $USBDEV |tail -n 1 |awk {'print $4;'})
-
-if [ $(($overlaysizemb + $homesizemb + $livesize + $swapsizemb)) -gt $(($free + $tbd)) ]; then
- echo "Unable to fit live image + overlay on available space on USB stick"
- echo "Size of live image: $livesize"
- [ "$overlaysizemb" -gt 0 ] && echo "Overlay size: $overlaysizemb"
- [ "$homesizemb" -gt 0 ] && echo "Home overlay size: $homesizemb"
- [ "$swapsizemb" -gt 0 ] && echo "Home overlay size: $swapsizemb"
- echo "Available space: $(($free + $tbd))"
- exitclean
-fi
-
-if [ -z "$skipcopy" ];then
- if [ -d $USBMNT/$LIVEOS -a -z "$force" ]; then
- echo "Already set up as live image."
- if [ -z "$keephome" -a -e $USBMNT/$LIVEOS/$HOMEFILE ]; then
- echo "WARNING: Persistent /home will be deleted!!!"
- echo "Press Enter to continue or ctrl-c to abort"
- read
- else
- echo "Deleting old OS in fifteen seconds..."
- sleep 15
-
- [ -e "$USBMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" ] && mv $USBMNT/$LIVEOS/$HOMEFILE $USBMNT/$HOMEFILE
- fi
-
- rm -rf $USBMNT/$LIVEOS
- fi
-fi
-
-# Bootloader is always reconfigured, so keep these out of the if skipcopy stuff.
-[ ! -d $USBMNT/$SYSLINUXPATH ] && mkdir -p $USBMNT/$SYSLINUXPATH
-[ -n "$efi" -a ! -d $USBMNT/EFI/boot ] && mkdir -p $USBMNT/EFI/boot
-
-if [ -z "$skipcopy" ];then
- echo "Copying live image to USB stick"
- [ ! -d $USBMNT/$LIVEOS ] && mkdir $USBMNT/$LIVEOS
- [ -n "$keephome" -a -f "$USBMNT/$HOMEFILE" ] && mv $USBMNT/$HOMEFILE $USBMNT/$LIVEOS/$HOMEFILE
- if [ -n "$skipcompress" -a -f $CDMNT/LiveOS/squashfs.img ]; then
- mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT
- cp $CDMNT/LiveOS/ext3fs.img $USBMNT/$LIVEOS/ext3fs.img || (umount $CDMNT ; exitclean)
- umount $CDMNT
- elif [ -f $CDMNT/LiveOS/squashfs.img ]; then
- cp $CDMNT/LiveOS/squashfs.img $USBMNT/$LIVEOS/squashfs.img || exitclean
- elif [ -f $CDMNT/LiveOS/ext3fs.img ]; then
- cp $CDMNT/LiveOS/ext3fs.img $USBMNT/$LIVEOS/ext3fs.img || exitclean
- fi
- if [ -f $CDMNT/LiveOS/osmin.img ]; then
- cp $CDMNT/LiveOS/osmin.img $USBMNT/$LIVEOS/osmin.img || exitclean
- fi
-fi
-
-cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH
-BOOTCONFIG=$USBMNT/$SYSLINUXPATH/isolinux.cfg
-# Set this to nothing so sed doesn't care
-BOOTCONFIG_EFI=
-if [ -n "$efi" ];then
- cp $CDMNT/EFI/boot/* $USBMNT/EFI/boot
-
- # this is a little ugly, but it gets the "interesting" named config file
- BOOTCONFIG_EFI=$USBMNT/EFI/boot/boot?*.conf
- rm -f $USBMNT/EFI/boot/grub.conf
-fi
-
-echo "Updating boot config file"
-# adjust label and fstype
-sed -i -e "s/CDLABEL=[^ ]*/$USBLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$USBFS/" $BOOTCONFIG $BOOTCONFIG_EFI
-if [ -n "$kernelargs" ]; then sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI ; fi
-if [ "$LIVEOS" != "LiveOS" ]; then sed -i -e "s;liveimg;liveimg live_dir=$LIVEOS;" $BOOTCONFIG $BOOTCONFIG_EFI ; fi
-
-if [ "$overlaysizemb" -gt 0 ]; then
- echo "Initializing persistent overlay file"
- OVERFILE="overlay-$( /lib/udev/vol_id -l $USBDEV )-$( /lib/udev/vol_id -u $USBDEV )"
- if [ "$USBFS" = "vfat" ]; then
- # vfat can't handle sparse files
- dd if=/dev/zero of=$USBMNT/$LIVEOS/$OVERFILE count=$overlaysizemb bs=1M
- else
- dd if=/dev/null of=$USBMNT/$LIVEOS/$OVERFILE count=1 bs=1M seek=$overlaysizemb
- fi
- sed -i -e "s/liveimg/liveimg overlay=${USBLABEL}/" $BOOTCONFIG $BOOTCONFIG_EFI
- sed -i -e "s/\ ro\ /\ rw\ /" $BOOTCONFIG $BOOTCONFIG_EFI
-fi
-
-if [ "$swapsizemb" -gt 0 ]; then
- echo "Initializing swap file"
- dd if=/dev/zero of=$USBMNT/$LIVEOS/swap.img count=$swapsizemb bs=1M
- mkswap -f $USBMNT/$LIVEOS/swap.img
-fi
-
-if [ "$homesizemb" -gt 0 ]; then
- echo "Initializing persistent /home"
- homesource=/dev/zero
- [ -n "$cryptedhome" ] && homesource=/dev/urandom
- if [ "$USBFS" = "vfat" ]; then
- # vfat can't handle sparse files
- dd if=${homesource} of=$USBMNT/$LIVEOS/$HOMEFILE count=$homesizemb bs=1M
- else
- dd if=/dev/null of=$USBMNT/$LIVEOS/$HOMEFILE count=1 bs=1M seek=$homesizemb
- fi
- if [ -n "$cryptedhome" ]; then
- loop=$(losetup -f)
- losetup $loop $USBMNT/$LIVEOS/$HOMEFILE
- setupworked=1
- until [ ${setupworked} == 0 ]; do
- echo "Encrypting persistent /home"
- cryptsetup luksFormat -y -q $loop
- setupworked=$?
- done
- setupworked=1
- until [ ${setupworked} == 0 ]; do
- echo "Please enter the password again to unlock the device"
- cryptsetup luksOpen $loop EncHomeFoo
- setupworked=$?
- done
- mke2fs -j /dev/mapper/EncHomeFoo
- tune2fs -c0 -i0 -ouser_xattr,acl /dev/mapper/EncHomeFoo
- cryptsetup luksClose EncHomeFoo
- losetup -d $loop
- else
- echo "Formatting unencrypted /home"
- mke2fs -F -j $USBMNT/$LIVEOS/$HOMEFILE
- tune2fs -c0 -i0 -ouser_xattr,acl $USBMNT/$LIVEOS/$HOMEFILE
- fi
-fi
-
-# create the forth files for booting on the XO if requested
-# we'd do this unconditionally, but you have to have a kernel that will
-# boot on the XO anyway.
-if [ -n "$xo" ]; then
- echo "Setting up /boot/olpc.fth file"
- args=$(egrep "^[ ]*append" $USBMNT/$SYSLINUXPATH/isolinux.cfg |head -n1 |sed -e 's/.*initrd=[^ ]*//')
- if [ -z "$xonohome" -a ! -f $USBMNT/$LIVEOS/$HOMEFILE ]; then
- args="$args persistenthome=mtd0"
- fi
- args="$args reset_overlay"
- xosyspath=$(echo $SYSLINUXPATH | sed -e 's;/;\\;')
- if [ ! -d $USBMNT/boot ]; then mkdir -p $USBMNT/boot ; fi
- cat > $USBMNT/boot/olpc.fth <<EOF
-\ Boot script for USB boot
-hex rom-pa fffc7 + 4 \$number drop h# 2e19 < [if]
- patch 2drop erase claim-params
- : high-ramdisk ( -- )
- cv-load-ramdisk
- h# 22c +lp l@ 1+ memory-limit umin /ramdisk - ffff.f000 and ( new-ramdisk-adr )
- ramdisk-adr over /ramdisk move ( new-ramdisk-adr )
- to ramdisk-adr
- ;
- ' high-ramdisk to load-ramdisk
-[then]
-
-: set-bootpath-dev ( -- )
- " /chosen" find-package if ( phandle )
- " bootpath" rot get-package-property 0= if ( propval$ )
- get-encoded-string ( bootpath$ )
- [char] \ left-parse-string 2nip ( dn$ )
- dn-buf place ( )
- then
- then
-
- " /sd" dn-buf count sindex 0>= if
- " sd:"
- else
- " u:"
- then
- " BOOTPATHDEV" \$set-macro
-;
-
-set-bootpath-dev
-" $args" to boot-file
-" \${BOOTPATHDEV}$xosyspath\initrd0.img" expand$ to ramdisk
-" \${BOOTPATHDEV}$xosyspath\vmlinuz0" expand$ to boot-device
-unfreeze
-boot
-EOF
-
-fi
-
-if [ -z "$multi" ]; then
- echo "Installing boot loader"
- if [ -n "$efi" ]; then
- # replace the ia32 hack
- if [ -f "$USBMNT/EFI/boot/boot.conf" ]; then cp -f $USBMNT/EFI/boot/bootia32.conf $USBMNT/EFI/boot/boot.conf ; fi
- fi
-
- # this is a bit of a kludge, but syslinux doesn't guarantee the API for its com32 modules :/
- if [ -f $USBMNT/$SYSLINUXPATH/vesamenu.c32 -a -f /usr/share/syslinux/vesamenu.c32 ]; then
- cp /usr/share/syslinux/vesamenu.c32 $USBMNT/$SYSLINUXPATH/vesamenu.c32
- elif [ -f $USBMNT/$SYSLINUXPATH/vesamenu.c32 -a -f /usr/lib/syslinux/vesamenu.c32 ]; then
- cp /usr/lib/syslinux/vesamenu.c32 $USBMNT/$SYSLINUXPATH/vesamenu.c32
- elif [ -f $USBMNT/$SYSLINUXPATH/menu.c32 -a -f /usr/share/syslinux/menu.c32 ]; then
- cp /usr/share/syslinux/menu.c32 $USBMNT/$SYSLINUXPATH/menu.c32
- elif [ -f $USBMNT/$SYSLINUXPATH/menu.c32 -a -f /usr/lib/syslinux/menu.c32 ]; then
- cp /usr/lib/syslinux/menu.c32 $USBMNT/$SYSLINUXPATH/menu.c32
- fi
-
- if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
- # syslinux expects the config to be named syslinux.cfg
- # and has to run with the file system unmounted
- mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/syslinux.cfg
- # deal with mtools complaining about ldlinux.sys
- if [ -f $USBMNT/$SYSLINUXPATH/ldlinux.sys ] ; then rm -f $USBMNT/$SYSLINUXPATH/ldlinux.sys ; fi
- cleanup
- if [ -n "$SYSLINUXPATH" ]; then
- syslinux -d $SYSLINUXPATH $USBDEV
- else
- syslinux $USBDEV
- fi
- elif [ "$USBFS" = "ext2" -o "$USBFS" = "ext3" ]; then
- # extlinux expects the config to be named extlinux.conf
- # and has to be run with the file system mounted
- mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/extlinux.conf
- extlinux -i $USBMNT/$SYSLINUXPATH
- cleanup
- fi
-else
- # we need to do some more config file tweaks for multi-image mode
- sed -i -e "s;kernel vm;kernel $LIVEOS/syslinux/vm;" $USBMNT/$SYSLINUXPATH/isolinux.cfg
- sed -i -e "s;initrd i;initrd $LIVEOS/syslinux/i;" $USBMNT/$SYSLINUXPATH/isolinux.cfg
- mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/syslinux.cfg
- cleanup
-fi
-
-echo "USB stick set up as live image!"
diff --git a/make_fake_device.sh b/make_fake_device.sh
new file mode 100755
index 0000000..c44a0e0
--- /dev/null
+++ b/make_fake_device.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+PATH=/usr/sbin:/sbin:$PATH
+
+SAFE_SIZE_4G=3758096384 #3584mb
+SAFE_SIZE_2G=1879048192 #1/2 4g safe size
+SAFE_SIZE_1G=939524096 #1/2 2g safe size
+
+DISK_SIZE=$SAFE_SIZE_4G
+LOOP_DEV=$(losetup -f)
+
+usage() {
+ echo "make_fake_device.sh [--4G|--2G|--1G] <loop device backing store filename>"
+ echo " outputs a loop device whose backing store is a partitioned disk "
+ echo " image using a sparse file of the specified size (default is --4G)"
+ exit 1
+}
+
+while [ $# -gt 1 ]; do
+ case $1 in
+ --4G)
+ DISK_SIZE=$SAFE_SIZE_4G
+ shift
+ ;;
+ --2G)
+ DISK_SIZE=$SAFE_SIZE_2G
+ shift
+ ;;
+ --1G)
+ DISK_SIZE=$SAFE_SIZE_2G
+ shift
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+IMG=$1
+
+
+BLOCK_SIZE=512
+NUM_HEADS=16
+NUM_SECTORS_PER_TRACK=62
+NUM_BLOCKS=$(($DISK_SIZE / $BLOCK_SIZE))
+NUM_CYLINDERS=$(($NUM_BLOCKS / $NUM_HEADS / $NUM_SECTORS_PER_TRACK))
+IMAGE_SIZE=$(($NUM_CYLINDERS * $NUM_HEADS * $NUM_SECTORS_PER_TRACK * $BLOCK_SIZE))
+OS_PART1_BEGIN=$(($NUM_SECTORS_PER_TRACK * $BLOCK_SIZE))
+
+dd if=/dev/zero of=$IMG bs=$BLOCK_SIZE count=0 seek=$(($IMAGE_SIZE / $BLOCK_SIZE)) > /dev/null 2>&1 || exitclean
+/sbin/fdisk -b $BLOCK_SIZE -C $NUM_CYLINDERS -S $NUM_SECTORS_PER_TRACK -H $NUM_HEADS $IMG > /dev/null 2>&1 <<EOF
+n
+p
+1
+
+
+t
+83
+p
+w
+q
+EOF
+
+losetup -d $LOOP_DEV > /dev/null 2>&1 || /bin/true
+losetup -o $OS_PART1_BEGIN $LOOP_DEV $IMG
+
+mke2fs -O dir_index -L OLPCRoot -F $LOOP_DEV > /dev/null 2>&1 || exitclean
+echo $LOOP_DEV
+
diff --git a/olpc.fth.bootmenu b/olpc.fth.bootmenu
new file mode 100644
index 0000000..0a55663
--- /dev/null
+++ b/olpc.fth.bootmenu
@@ -0,0 +1,41 @@
+\ olpc.fth
+
+" root=mtd0 rootfstype=jffs2 console=tty0 console=ttyS0,115200 fbcon=font:SUN12x22" to boot-file
+" nand:\boot\vmlinuz" to boot-device
+
+setup-smbios
+unfreeze
+dcon-unfreeze
+visible
+
+." Temporary boot menu for testing" cr
+cr
+." 1 to boot from SD" cr
+." 2 to boot from USB" cr
+." 3 to boot from internal NAND" cr
+." 4 to boot alternate image from NAND" cr
+cr
+key case
+ [char] 1 of \ SD boot info
+ " ro root=/dev/mmcblk0p1 rootdelay=1 console=ttyS0,115200 console=tty0 fbcon=font:SUN12x22" to boot-file
+ " sd:\boot\vmlinuz" to boot-device
+ " sd:\boot\olpcrd.img" to ramdisk
+ endof
+ [char] 2 of \ USB boot info
+ " ro root=sda1 rootdelay=1 console=ttyS0,115200 console=tty0 fbcon=font:SUN12x22" to boot-file
+ " disk:\boot\vmlinuz" to boot-device
+ " disk:\boot\olpcrd.img" to ramdisk
+ endof
+ [char] 4 of \ Alternate boot image info
+ " ro root=mtd0 rootfstype=jffs2 console=ttyS0,115200 console=tty0 fbcon=font:SUN12x22" to boot-file
+ " nand:\boot-alt\vmlinuz" to boot-device
+ " nand:\boot-alt\olpcrd.img" to ramdisk
+ endof
+ ( default ) \ Default sugar boot image info
+ " ro root=mtd0 rootfstype=jffs2 console=ttyS0,115200 console=tty0 fbcon=font:SUN12x22" to boot-file
+ " nand:\boot\vmlinuz" to boot-device
+ " nand:\boot\olpcrd.img" to ramdisk
+endcase
+
+
+boot
diff --git a/soas-sugar.ks b/soas-sugar.ks
index 0cf67ea..b5e1a94 100644
--- a/soas-sugar.ks
+++ b/soas-sugar.ks
@@ -118,6 +118,9 @@ curl -O http://git.sugarlabs.org/projects/soas/repos/mainline/blobs/raw/8ad00566
chown -R 500:500 $BUNDLES_DIR
cd $WD
+#vte is needed by Terminal
+vte
+
%end
%post
diff --git a/soas-xo.ks b/soas-xo.ks
new file mode 100644
index 0000000..217eff4
--- /dev/null
+++ b/soas-xo.ks
@@ -0,0 +1,489 @@
+%include soas-sugar.ks
+
+%packages --excludedocs --instLangs en_US
+
+bootchart
+fbida
+ntpdate
+ohm
+xcompmgr
+
+# FIXME: uncomment when packaged for F11
+#olpc-kbdshim
+#olpc-powerd
+
+%end
+
+%post
+
+
+
+##################
+# BEGIN olpc.fth
+cat > /boot/olpc.fth <<EOF
+\ olpc.fth
+
+" root=mtd0 rootfstype=jffs2 console=tty0 console=ttyS0,115200 fbcon=font:SUN12x22" to boot-file
+" nand:\boot\vmlinuz" to boot-device
+
+setup-smbios
+unfreeze
+dcon-unfreeze
+visible
+
+boot
+EOF
+
+# END olpc.fth
+##################
+
+
+
+##################
+# BEGIN dcon-unfreeze-failsafe
+
+
+cat > /etc/event.d/dcon-unfreeze-failsafe <<EOF
+# this service unfreezes the DCON
+# Sugar should do this but a) it might not; and b) we might not be running Sugar
+#
+
+
+description "unfreeze DCON"
+author "Martin Dengler <martin@martindengler.com>"
+
+start on started prefdm
+stop on stopping prefdm
+stop on starting shutdown
+
+stop on runlevel 0
+stop on runlevel 1
+stop on runlevel 6
+
+script
+echo 0 > /sys/devices/platform/dcon/freeze
+end script
+EOF
+
+chmod a+rx /etc/event.d/dcon-unfreeze-failsafe
+
+# END dcon-unfreeze-failsafe
+##################
+
+
+
+CREATE_USERNAME=olpc
+
+##################
+# BEGIN avoid livesys script at every boot
+
+
+cat >> /etc/fstab <<EOF
+/tmp /tmp tmpfs rw 0 0
+varcacheyum /var/cache/yum tmpfs rw,mode=755 0 0
+vartmp /var/tmp tmpfs rw 0 0
+none /ofw promfs defaults 0 0
+EOF
+
+/usr/sbin/useradd -m -c "SoaS user" -G audio $CREATE_USERNAME
+/usr/bin/passwd -d $CREATE_USERNAME
+
+
+# permanently set %__dbi_cdb rpm macro to work around jffs2's lack of writeable mmap()
+mkdir -p /etc/rpm
+echo "%__dbi_cdb create private nommap" > /etc/rpm/macros.rpmdb
+
+
+# amend build
+sed -i -e 's/SoaS/SoaS-XO/g' /etc/fedora-release
+
+
+# disable screensaver locking
+gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-screensaver/lock_enabled false >/dev/null
+
+
+# disable the logout menu item in Sugar
+gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /desktop/sugar/show_logout false >/dev/null
+
+
+# nicer console font for our little screen
+echo "SYSFONT=sun12x22" >> /etc/sysconfig/i18n
+
+
+# make sure the fonts are not too big in GNOME
+# FIXME: remove when http://dev.laptop.org/ticket/9331 is fixed
+gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t float /desktop/gnome/font_rendering/dpi 201 >/dev/null
+
+
+# make sure the fonts are not too big in Sugar
+# FIXME: remove when http://dev.laptop.org/ticket/9331 is fixed
+echo "Xft.dpi: 201" > /home/$CREATE_USERNAME/.Xresources
+chown $CREATE_USERNAME:$CREATE_USERNAME /home/$CREATE_USERNAME/.Xresources
+
+
+# use smaller font size for XO
+# FIXME: fix upstream at http://dev.sugarlabs.org/ticket/954
+sed -i -e 's/Sans Serif 10/Sans Serif 7/g' /usr/share/sugar/data/sugar-100.gtkrc
+
+
+# symlink Honey activities to /home/.../Activities
+HONEY_DIR=/usr/share/sugar/honey
+chown -R $CREATE_USERNAME:$CREATE_USERNAME $HONEY_DIR
+mkdir /home/$CREATE_USERNAME/Activities
+for activity_dir in $HONEY_DIR/* ; do
+ ln -s $activity_dir /home/$CREATE_USERNAME/Activities
+done
+
+# setup Xclients
+cat > /home/$CREATE_USERNAME/.Xclients <<FOE
+
+eval \$(dbus-launch --sh-syntax --exit-with-session)
+
+exec sugar
+FOE
+chmod a+x /home/$CREATE_USERNAME/.Xclients
+chown $CREATE_USERNAME:$CREATE_USERNAME /home/$CREATE_USERNAME/.Xclients
+
+
+# fix issues with dbus and ck
+rm /etc/X11/xinit/xinitrc.d/00-start-message-bus.sh
+
+
+# END avoid livesys scripts at every boot
+##################
+
+
+##################
+# BEGIN liveuser .xsession
+
+cat >> /home/$CREATE_USERNAME/.xsession <<EOF
+
+# full debugging on
+export LM_DEBUG=net
+export GABBLE_DEBUG=all
+export GABBLE_LOGFILE=/home/$CREATE_USERNAME/.sugar/default/logs/telepathy-gabble.log
+export SALUT_DEBUG=all
+export SALUT_LOGFILE=/home/$CREATE_USERNAME/.sugar/default/logs/telepathy-salut.log
+export GIBBER_DEBUG=all
+export PRESENCESERVICE_DEBUG=1
+export SUGAR_LOGGER_LEVEL=debug
+
+# Uncomment the following line to enable core dumps
+#ulimit -c unlimited
+
+# Uncomment the following line to debug sugar startup problems
+#exec xterm
+
+# If you drop out of this script, the normal olpc-session will proceed
+# Uncomment the following line to prevent it
+#exit 0
+
+(sleep 5 ; xcompmgr ) &
+
+EOF
+
+# END olpc .xsession
+##################
+
+
+
+##################
+# BEGIN ntpdate
+
+ntpdate_file=/etc/NetworkManager/dispatcher.d/42-ntpdate
+if [ ! -e $ntpdate_file ] ; then
+ cat > $ntpdate_file <<EOF
+#!/bin/bash
+
+if [ "\$2" = "up" ] ; then
+ sleep 5
+ /usr/sbin/ntpdate 0.pool.ntp.org >> /tmp/ntpdate.log 2>&1
+fi
+EOF
+
+chmod u+rx $ntpdate_file
+
+fi
+
+# END ntpdate
+##################
+
+
+
+##################
+# BEGIN smolt
+
+smolt_file=/etc/NetworkManager/dispatcher.d/43-smolt
+if [ ! -e $smolt_file ] ; then
+ cat > $smolt_file <<EOF
+#!/bin/bash
+
+if [ "\$2" = "up" ] ; then
+ sleep 15
+ ( nice /usr/bin/smoltSendProfile -a --submitOnly -b -c || /usr/sbin/smoltSentProfile -a --submitOnly -b ) >> /tmp/smolt.log 2>&1
+fi
+EOF
+
+fi
+
+chmod u+rx $smolt_file
+
+# END smolt
+##################
+
+
+##################
+# BEGIN make sugar default
+cat > /home/$CREATE_USERNAME/.dmrc <<EOF
+[Desktop]
+Layout=olpc
+Session=sugar
+EOF
+# END make sugar default
+##################
+
+
+
+##################
+# BEGIN set sugar power management on
+gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /desktop/sugar/power/automatic True >/dev/null
+# END set sugar power management on
+##################
+
+
+
+##################
+# BEGIN slim autostart
+cat >> /etc/slim.conf << FOE
+auto_login yes
+default_user $CREATE_USERNAME
+FOE
+# END slim autostart
+##################
+
+
+
+##################
+# BEGIN fix keyboard layout
+cat > /etc/sysconfig/keyboard <<EOF
+KEYBOARDTYPE="pc"
+KEYTABLE="us"
+LAYOUT="us"
+MODEL="olpc"
+OPTIONS=""
+VARIANT="olpc"
+EOF
+
+cat > /usr/share/hal/fdi/information/10freedesktop/30-keymap-olpc.fdi <<EOF
+<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
+
+
+<!-- FIXME: this isn't a great way to detect a C2 / XO-1 -->
+<deviceinfo version="0.2">
+ <device>
+ <match key="info.product" string="OLPC HGPK ALPS HGPK">
+ <merge key="/org/freedesktop/Hal/devices/computer:system.hardware.product" type="string">C2</merge>
+ <merge key="/org/freedesktop/Hal/devices/computer:system.hardware.vendor" type="string">OLPC</merge>
+ <merge key="/org/freedesktop/Hal/devices/computer:system.hardware.version" type="string">OLPC C2</merge>
+ </match>
+ </device>
+</deviceinfo>
+
+<deviceinfo version="0.2">
+ <device>
+
+ <match key="/org/freedesktop/Hal/devices/computer:system.hardware.version" string="OLPC C2">
+
+ <match key="@input.originating_device:info.linux.driver" string="atkbd">
+ <append key="input.keymap.data" type="strlist">59:fn</append>
+ <append key="input.keymap.data" type="strlist">e001:fn_esc</append>
+
+ <append key="input.keymap.data" type="strlist">e079:camera</append>
+ <!-- FN-CAMERA is 'Mic', KEY_SOUND is as close as I see. -->
+ <append key="input.keymap.data" type="strlist">e078:sound</append>
+
+ <append key="input.keymap.data" type="strlist">e03b:fn_f1</append>
+ <append key="input.keymap.data" type="strlist">e03c:fn_f2</append>
+ <append key="input.keymap.data" type="strlist">e03d:fn_f3</append>
+ <append key="input.keymap.data" type="strlist">e03e:fn_f4</append>
+ <append key="input.keymap.data" type="strlist">e03f:fn_f5</append>
+ <append key="input.keymap.data" type="strlist">e040:fn_f6</append>
+ <append key="input.keymap.data" type="strlist">e041:fn_f7</append>
+ <append key="input.keymap.data" type="strlist">e042:fn_f8</append>
+ <append key="input.keymap.data" type="strlist">e043:fn_f9</append>
+ <append key="input.keymap.data" type="strlist">e044:fn_f10</append>
+ <append key="input.keymap.data" type="strlist">e057:fn_f11</append>
+ <append key="input.keymap.data" type="strlist">e058:fn_f12</append>
+
+ <!-- Using KEY_F13-KEY_F21 for the .5 F keys right now. -->
+ <append key="input.keymap.data" type="strlist">e077:fn_f13</append>
+ <append key="input.keymap.data" type="strlist">e076:fn_f14</append>
+ <append key="input.keymap.data" type="strlist">e075:fn_f15</append>
+ <append key="input.keymap.data" type="strlist">e074:fn_f16</append>
+ <append key="input.keymap.data" type="strlist">e073:fn_f17</append>
+ <append key="input.keymap.data" type="strlist">e072:fn_f18</append>
+ <append key="input.keymap.data" type="strlist">e071:fn_f19</append>
+ <append key="input.keymap.data" type="strlist">e070:fn_f20</append>
+ <append key="input.keymap.data" type="strlist">e06f:fn_f21</append>
+
+ <append key="input.keymap.data" type="strlist">e06e:chat</append>
+ <!-- FIXME: FN-CHAT, just mapping to KEY_CHAT right now -->
+ <append key="input.keymap.data" type="strlist">e064:chat</append>
+
+ <!-- Frame and Fn-frame , which is listed as 'Win App', try -->
+ <append key="input.keymap.data" type="strlist">e05d:menu</append>
+ <append key="input.keymap.data" type="strlist">e05a:prog1</append>
+
+ <!-- The FN of some keys is other keys -->
+ <append key="input.keymap.data" type="strlist">e053:delete</append>
+ <append key="input.keymap.data" type="strlist">e052:insert</append>
+ <append key="input.keymap.data" type="strlist">e049:pageup</append>
+ <append key="input.keymap.data" type="strlist">e051:pagedown</append>
+ <append key="input.keymap.data" type="strlist">e047:home</append>
+ <append key="input.keymap.data" type="strlist">e04f:end</append>
+
+ <!-- FIXME: These should be the language key. Don't ask what they
+ are doing as KEY_HP. It will make your brain hurt. -->
+ <append key="input.keymap.data" type="strlist">73:hp</append>
+ <append key="input.keymap.data" type="strlist">7e:hp</append>
+
+ <!-- L/R grab -->
+ <append key="input.keymap.data" type="strlist">e05b:leftmeta</append>
+ <append key="input.keymap.data" type="strlist">e05c:rightmeta</append>
+ <!-- FIXME: right grab seems to be releasing on a different scancode -->
+ <append key="input.keymap.data" type="strlist">85:rightmeta</append>
+
+ <!-- Fn-space toggles the backlight.
+ At least in a dream I had last night. -->
+ <append key="input.keymap.data" type="strlist">e056:kbdillumtoggle</append>
+
+ <!-- Set the D-PAD keys to map to up/down/left/right for now -->
+ <append key="input.keymap.data" type="strlist">65:kp8</append>
+ <append key="input.keymap.data" type="strlist">66:kp2</append>
+ <append key="input.keymap.data" type="strlist">67:kp4</append>
+ <append key="input.keymap.data" type="strlist">68:kp6</append>
+
+ <!-- set the game keys to map to pgup/pgdn/home/end -->
+ <append key="input.keymap.data" type="strlist">e065:kp9</append>
+ <append key="input.keymap.data" type="strlist">e066:kp3</append>
+ <append key="input.keymap.data" type="strlist">e067:kp7</append>
+ <append key="input.keymap.data" type="strlist">e068:kp1</append>
+
+ <append key="input.keymap.data" type="strlist">69:switchvideomode</append>
+
+ <append key="info.capabilities" type="strlist">input.keymap</append>
+
+ </match>
+
+ </match>
+ </device>
+</deviceinfo>
+
+EOF
+
+# END fix keyboard layout
+##################
+
+
+
+##################
+# BEGIN enable serial console
+
+echo ttyS0 >> /etc/securetty
+
+cat > /etc/event.d/ttyS0 <<EOF
+# ttyS0 - serial console
+start on stopped rc2
+start on stopped rc3
+start on stopped rc4
+start on stopped prefdm
+
+stop on runlevel 0
+stop on runlevel 1
+stop on runlevel 6
+
+respawn
+exec agetty ttyS0 115200
+EOF
+
+# END enable serial console
+##################
+
+
+
+##################
+# BEGIN make /var/log/messages a+r so Log activity can see it
+chmod a+r /var/log/messages
+# END make /var/log/messages a+r so Log activity can see it
+##################
+
+
+
+%end
+
+
+%post --nochroot
+
+mkdir -p $INSTALL_ROOT/var/tmp
+cp ../bits/kernel-2.6.25-20090223.1.olpc.69098d87d56945c.i586.rpm \
+ ../bits/kernel-2.6.30-20090604.1.olpc.9f05ee9.i586.rpm \
+ ../bits/olpc-kbdshim-6-3.fc9.i386.rpm \
+ ../bits/olpc-powerd-7-1.fc9.i386.rpm \
+ $INSTALL_ROOT/var/tmp
+
+%end
+
+
+
+#do this at the end because it (might/does) depend on rpms install outside of the chroot
+%post
+
+set -x
+
+mount -o bind /dev $INSTALL_ROOT/dev
+mount -o bind /proc $INSTALL_ROOT/proc
+
+##################
+# BEGIN prime yum db
+setarch i386 yum -y update
+##################
+
+
+##################
+# BEGIN install k
+#OLPC stable kernel with DCON + PM + OFW
+setarch i386 rpm -ivh --force --nodeps /var/tmp/kernel-2.6.25-20090223.1.olpc.69098d87d56945c.i586.rpm
+
+#OLPC development kernel with DCON + PM
+setarch i386 rpm -ivh --force --nodeps /var/tmp/kernel-2.6.30-20090604.1.olpc.9f05ee9.i586.rpm
+# END install kernels
+##################
+
+
+##################
+# BEGIN install olpc-powerd and olpc-kbdshim
+# FIXME: remove when packaged in rawhide / F11
+setarch i386 rpm -ivh /var/tmp/olpc-powerd-7-1.fc9.i386.rpm /var/tmp/olpc-kbdshim-6-3.fc9.i386.rpm
+# END install olpc-powerd and olpc-kbdshim
+##################
+
+
+##################
+# BEGIN setup services
+for service in auditd cpuspeed cups dnsmasq exim firstboot gpm ip6tables irda livesys livesys-late mdmonitor netfs network nfs nfslock nscd pcscd portreserve readahead_early readahead_later rpcbind rpcgssd rpcidmapd setroubleshoot yum-updatesd ; do
+ /sbin/chkconfig --level 2345 $service off
+done
+
+for service in avahi-daemon olpc-kbdshim olpc-powerd sshd ; do
+ /sbin/chkconfig --level 2345 $service on
+done
+# something triggers prompting, so just turn it off with a big hammer
+sed -i -e 's/PROMPT=yes/PROMPT=no/;' /etc/sysconfig/init
+# END setup services
+##################
+
+umount $INSTALL_ROOT/dev/pts
+umount $INSTALL_ROOT/dev
+umount $INSTALL_ROOT/proc
+
+%end \ No newline at end of file