#!/bin/sh

# mkidiot v0.0.1 (don't trust these version numbers)
#
# Dummm Dummmmmm?    'Diesel' Dave 'Kill a Cop' Cinege - GPL2
#
# Linux Router Project Development kit 

MKDOSFS="bin/mkdosfs"	#Support bigger sizes
SYSLINUX="bin/syslinux"

sp=' '
tab='	'

builddisk () {

	bootpat=
	bootline="boot=/dev/fd0u$SIZE,msdos"

	echo -n "Making $IMAGEN..."

	{

	dd if=/dev/zero of=$IMAGEN bs=1024 count=$SIZE
	
	$MKDOSFS $IMAGEN $SIZE

	$SYSLINUX $IMAGEN
	mount -t msdos -o loop $IMAGEN $MNT

	cp $BOOT $MNT/
	sed "s|boot=[^$sp|$tab]*|$bootline|" $BOOTCFG >$MNT/$(basename $BOOTCFG)
	cp $KERNEL $MNT/linux
	cp $ROOT $MNT/root.lrp
	cp $PAKS $MNT/

	umount $MNT

	} >/dev/null 2>&1

	echo "done."
}



mk20 () {
	KERNEL="source/kernel/current_2.0/*-LRP-*zImage"
	ROOT="base/root.lrp"
	IMAGEN="idiot-image_${SIZE}KB_FAT_$(cat Version)_Linux_2.0"

	builddisk
	gzip -f9 $IMAGEN
}


mk22 () {
	KERNEL="source/kernel/current_2.2/*-LRP-*zImage"
	ROOT="base/root_22.lrp"
	IMAGEN="idiot-image_${SIZE}KB_FAT_$(cat Version)_Linux_2.2"

	builddisk 
	gzip -f9 $IMAGEN
}

MNT=/mnt
BOOT="boot/syslinux/syslinux.dpy"
BOOTCFG="boot/syslinux/syslinux.cfg"
PAKS="base/etc.lrp base/log.lrp base/local.lrp base/modules.lrp"

SIZE=1440
mk20
mk22

#Requires our fixed mkdosfs
SIZE=1680
mk20
mk22

#SIZE=1701
#mk20
#mk22

SIZE=1722
mk20
mk22

SIZE=1743
mk20
mk22
