[G1 Android Development] Firerat:
yeap

run_program("/tmp/checksys.sh");

#determine if we need to patch a boot image
if file_getprop("/tmp/nfo.prop","radioseries") == "3.22"
then
#EBI1 kernel needed
ui_print("Extracting EBI1 patch");
package_extract_file("kernel/ebi1-boot.img","/tmp/boot.img");
package_extract_file("kernel/ebi1-modules.sqf",
"/system/lib/modules/modules.sqf");
else
#EBI0/2708 kernel needed
if file_getprop("/tmp/nfo.prop","smisize") == "64" &&
( file_getprop("/tmp/nfo.prop","bootloader") == "1.33.0011" ||
file_getprop("/tmp/nfo.prop","bootloader") == "1.33.2011" ||
file_getprop("/tmp/nfo.prop","bootloader") == "1.33.3011" ||
file_getprop("/tmp/nfo.prop","bootloader") == "1.33.0013" ||
file_getprop("/tmp/nfo.prop","bootloader") == "1.33.2013" ||
file_getprop("/tmp/nfo.prop","bootloader") == "1.33.3013" ||
file_getprop("/tmp/nfo.prop","bootloader") == "1.33.0013d" ) &&
( file_getprop("/tmp/nfo.prop","baseband") == "2.22.27.08" ||
file_getprop("/tmp/nfo.prop","baseband") == "2.22.28.25" )
then
#2708 kernel (unless the user has the fake Crios SPL 1.33.2013 ENG)
# if the fake version they will fail to boot since its really
# 1.33.2005...
if file_getprop("/tmp/nfo.prop","bootloader") == "1.33.2013"
then
ui_print("1.33.2003 detected, please ensure this is not Crios SPL 1.33.2013 ENG");
endif;
ui_print("Extracting 2708+ patch");
package_extract_file("kernel/2708-boot.img","/tmp/boot.img");
else
#EBI0 kernel
ui_print("Extracting EBI0 patch");
package_extract_file("kernel/ebi0-boot.img","/tmp/boot.img");
package_extract_file("kernel/ebi0-modules.sqf",
"/system/lib/modules/modules.sqf");
endif;
endif;
## TODO ADD AUTO CUSTOM-MTD logic to /tmp/boot.img here ##
ui_print("Write boot.img");
assert(write_raw_image("/tmp/boot.img","boot"));
delete("/tmp/checksys.sh","/tmp/boot.img");

#END INSTALL boot.img

regards Auto customMTD, it should be straight forward

#!/sbin/sh
# customMTD boot only patcher
# gets mtdparts from running recovery and patches boot.img if required
GetCMDline ()
{
KCMDline="mtdparts`cat /proc/cmdline|awk -Fmtdparts '{print $2}'`"
if [ "$KCMDline" = "mtdparts" ];
then
echo "no customMTD found, exit"
exit
fi
return
}

repackimg ()
{
$wkdir/unpackbootimg $wkdir/${boot}.img $wkdir/
rm $wkdir/${boot}.img
origcmdline=`awk '{gsub(/\ .\ /,"");sub(/mtdparts.+)/,"");sub(/androidboot.bootloader=.+\ /,"");print}' $wkdir/${boot}.img-cmdline|awk '{$1=$1};1'`
$wkdir/mkbootimg --kernel $wkdir/${boot}.img-zImage --ramdisk $wkdir/${boot}.img-ramdisk.gz -o $wkdir/${boot}.img --cmdline "$origcmdline $KCMDline" --base `cat $wkdir/${boot}.img-base`
return
}

wkdir=/tmp
boot=boot

GetCMDline
repackimg

just need to run that script prior to flashing /tmp/boot.img

( also need to include the unpackbootimg and mkbootimg bins )

could even add the test to checksys.sh and only run script if its required

edit

couple of hangovers in there, like stripping the bootloader out

I'll do a proper clean version

edit2:

since I have looked more closely at it the checksys is already testing for customMTD :)

so I've added repackboot.sh and kanged koush's bins from

http://github.com/koush/AnyKernel/tree/master/kernel/

( might not be those exact bins, as I half inched them a while ago )