IMG_NAME=""
ROOT_DIR=""
+SKIP_GRUB="n"
. ./functions.sh
# first, create a sparse image
minus_size=$(($size * 6 / 100))
size=$(($size - $minus_size))
- dd if=/dev/zero of=$img bs=1M count=1 seek=$(($size - 1))
+ dd if=/dev/zero of=$img bs=1M count=1 seek=$size
# fill in the partition table
parted -s "$img" "mklabel msdos"
timeout 5
color cyan/blue white/blue
EOF
+ installer_added=0
label=`sed -ne 's/^LABEL=\(.\+\)[[:space:]]\+\/[[:space:]]\+.*/\1/p' configs/${CONFIG_TYPE}/fstab-ext3`
prefix=
grep -q ' ${mntpt}/boot ' /proc/mounts && prefix=/boot
for kern in ${mntpt}/boot/vmlinuz-*; do
v=$(basename $kern | sed 's/vmlinuz-//')
+ if [ "${v}" = '*' ]; then
+ echo "*** Error: no kernel images found in /boot!" 1>&2
+ exit 1
+ fi
cat >>${mntpt}/boot/grub/menu.lst<<EOF
title Debian GNU/Linux, kernel ${v}
initrd ${prefix}/initrd.img-${v}
boot
EOF
+ if [ "$installer_added" = "0" ]; then
+ installer_added=1
+ cat >>${mntpt}/boot/grub/menu.lst<<EOF
+
+title Debian GNU/Linux Installer
+root (hd0,0)
+kernel ${prefix}/vmlinuz-${v} root=LABEL=${label} ro installer
+initrd ${prefix}/initrd.img-${v}
+boot
+EOF
+ fi
+
done
# grub-install is pretty broken, so we do this manually
geom=`parted -s "$img" "unit chs" "print" | sed -ne 's/geometry: \([0-9]\+\),\([0-9]\+\),\([0-9]\+\)/:\1 \2 \3:/p' | cut -d: -f2`
- grub --device-map=/dev/null <<EOF
+ grub --batch --device-map=/dev/null <<EOF
device (hd0) $img
geometry (hd0) $geom
root (hd0,0)
# populate the filesystem
cp -ra "$root_dir"/* "$mount_point_root" || true
- grub_install "$img" "$mount_point_root"
+ if [ "$SKIP_GRUB" != "y" ]; then
+ grub_install "$img" "$mount_point_root"
+ fi
# umount the filesystem
sed -ne 's/^LABEL=//p' configs/${CONFIG_TYPE}/fstab-ext3 | \
echo "" 1>&2
echo "Options:" 1>&2
echo " --config-type <config> directory name in configs/ to use" 1>&2
+ echo " --help display this help screen" 1>&2
+ echo " --skip-grub don't install GRUB on image" 1>&2
echo "" 1>&2
exit 1
}
}
shift
;;
+ --skip-grub)
+ SKIP_GRUB="y"
+ ;;
+ --help|-h)
+ usage
+ ;;
*)
ROOT_DIR="$1"
shift
usage
fi
-check_for_cmds losetup parted mke2fs tune2fs grub || exit 1
+check_for_cmds losetup parted mke2fs tune2fs || exit 1
+if [ "$SKIP_GRUB" != "y" ]; then
+ check_for_cmds grub || exit 1
+fi
# create image's /etc/fstab
if [ ! -f ./configs/${CONFIG_TYPE}/fstab-ext3 ]; then
#mount ${IMG_NAME}.ext3 $MOUNT_POINT -o loop,offset=$OS_PART1_BEGIN -t ext3
#cp -r "$ROOT_DIR"/* $MOUNT_POINT
#umount $MOUNT_POINT
+
+exit 0