#!/bin/sh -e
# Create an initramfs and a menu.lst that can be loaded from Grub on a USB
# key, where the ISO file is stored in the root directory
# (c) 2008 Michael Schierl
[ -n "$1" ]
cp findiso.patch /tmp
rm -rf /tmp/initramfs /tmp/x || true
mkdir /tmp/initramfs
rm -rf $1/boot/grml_2008.11 || true
mkdir -p $1/boot/grml_2008.11
cd /tmp/initramfs
zcat /live/image/boot/grml/initrd.gz | cpio -i
patch -p1 </tmp/findiso.patch
find | cpio -H newc -o | gzip --best >$1/boot/grml_2008.11/initrd.gz
sed s#boot/grml#boot/grml_2008.11# /live/image/boot/grub/menu.lst | \
	sed "s#linux26#linux26 findiso=/grml_2008.11.iso#" | \
	sed s#grub/splash#grml_2008.11/splash# | \
	sed s#-rc1## | \
	head -n 56 >$1/boot/grml_2008.11/menu.lst
cp /live/image/boot/grml/linux26 /live/image/boot/grub/splash.xpm.gz $1/boot/grml_2008.11
echo Done. Don"'"t forget to copy grml_2008.11.iso to $1.
