echo off

echo.
echo Select options and run BuildOS.  When BuildOS is closed, BuildNB will continue.
echo [BuildOS]
TOOLS\BuildOS.exe

echo.
echo Relocating modules.
echo [G'Reloc -dump -doit]
"TOOLS\G'Reloc.exe" -dump -doit

echo.
echo Compacting packages...
echo [AllPackagesToOne]
TOOLS\all_packages_to_one.exe
del buildpkg.wrn

echo.
echo Rebuilding templates...
mkdir .\Temp2
cd .\Temp2
echo [prepare_imgfs ..\ROM\core.img -nosplit]
..\TOOLS\prepare_imgfs.exe ..\ROM\core.img -nosplit
echo .... Done.

echo Building new imgfs.bin from dump...
cd ..\Temp
echo [imgfsfromdump.exe ..\Temp2\imgfs_raw_data.bin ..\Temp2\imgfs-out.bin]
..\Tools\imgfsfromdump.exe ..\Temp2\imgfs_raw_data.bin ..\Temp2\imgfs-out.bin > ..\imgfsfromdump.log
del ..\Temp2\imgfs_*_data.bin
echo .... Done.

echo Building flash.dip...
cd ..\Temp2
echo [imgfstonb.exe imgfs-out.bin ..\ROM\core.img newrom.dip -bigstoragemove]
..\Tools\imgfstonb.exe imgfs-out.bin ..\ROM\core.img newrom.dip -bigstoragemove > ..\imgfstonb.log
del imgfs-out.bin
echo .... Done.

echo Clean up time!
cd ..
rd /s /q .\Temp
move .\Temp2\newrom.dip .\RUU\flash.dip
rd /s /q .\Temp2
echo .... Done.

echo BuildIt is Complete. 
echo Flash your new FLASH.dip, and enjoy!
pause

goto :EOF


:error
echo.
echo ERROR! (errorlevel: %errorlevel%)
