#!/bin/bash # (C) 2003-2007 Willem Jan Hengeveld # Web: http://www.xs4all.nl/~itsme/ # http://wiki.xda-developers.com/ # # $Id: mkrom_xip.sh 1502 2007-04-15 07:54:20Z itsme $ # #. ../../kitchen.local/mkrom-inc.sh target_name=$1 case "$target_name" in *.nb1.zip | *.nb1) out_type=nb1 ;; *.nbf.zip | *.nbf | *.exe) out_type=nbf ;; *) echo "unknown target type" && exit 1 ;; esac mkdir out tmp cfg 2>/dev/null case $OSTYPE in linux-gnu) tounicode=./tounicode ;; cygwin) tounicode=./tounicode.exe ;; *) echo Warning: OS type not detected, you may need to set tounicode variable manually tounicode=./tounicode ;; esac out_basename=out/xdaromimg op_basename=tmp/xdaopimg xda1_basename=tmp/xda1 chain_basename=tmp/xipchain # number roms sequentially last=`ls $chain_basename-[0-9]* 2>/dev/null |sort -t- -n +1 |tail -1|cut -sd- -f2` xda1_name=$xda1_basename-$[$last+1].bin chain_name=$chain_basename-$[$last+1] out_name=$out_basename-$[$last+1].$out_type op_name=$op_basename-$[$last+1] startmenuicon=cfg/21x18-2-256.ico splash_name=cfg/bootimage.bmp templatechain_name=cfg/xipchain bootloader_name=cfg/bootloader.nb0 rom_name=cfg/rom.nb1 romopts= wincever=3 start1=81940000 size1=00500000 startbmp=81900000 startop=81940000 # warning: make sure this file does not have CRLF inside it. if [[ -e cfg/params ]]; then . cfg/params fi if [[ ! -e $rom_name || ! -e $bootloader_name || ! -e $splash_name || ! -e $templatechain_name || ! -e $startmenuicon ]]; then echo "rom, bootloader, splash, xipchain or startmenu icon missing" exit 1 fi rm -rf files1 modules1 mkdir files1 modules1 # create bootup init files perl reg2fdf.pl -$wincever cfg/default.reg files/default.fdf \ || { echo Error creating fdf file && exit 1; } $tounicode cfg/initobj.txt files/initobj.dat cp cfg/initdb.ini files if [[ -e cfg/operator.cfg && -d operator ]]; then perl dir2opimg.pl ./cfg/operator.cfg ./operator $op_name \ || { echo Error creating operator image && exit 1; } romopts="$romopts -rm $op_name:0x$startop" start1=`perl -e "\\$os= -s q($op_name); printf(qq(%08lx), 0x$startop+(\\$os+0x3ffff)&~0x3ffff);"` else start1=$startop fi size1=`printf "%08lx" $[0x81f00000-0x$start1]` # moves files to files1 perl makefiles.pl ./files ./files1 0x$size1 \ || { echo Error splitting files && exit 1; } perl makexip.pl $start1 ./files1 ./modules1 $xda1_name \ || { echo Error making xip section && exit 1; } romopts="$romopts -rm $xda1_name:0x$start1" perl chainedit.pl load $templatechain_name add TEST:$start1,$size1 setpk "*:cfg/xipkey.pub" save $chain_name \ || { echo Error editing xip chain && exit 1; } romopts="$romopts -rx $chain_name" # bootsplash romopts="$romopts -rb $splash_name -ob 0x$startbmp" romopts="$romopts -dl 8062c2e0:$startmenuicon:0026:06e0" # bootloader romopts="$romopts -rl $bootloader_name" if [[ $wincever == 4 ]]; then # this adss a special file relocation trick to get 4.x to recognise the new default.fdf etc. romopts="$romopts `perl drparse.pl $rom_name $xda1_name `" fi echo perl splitrom.pl $rom_name $romopts -wo $out_name -t $out_type -n PW10A1-ENG-3.16-007 -wp TEST:test.bin \ || { echo Error creating new rom && exit 1; } case "$target_name" in *.nb1.zip | *.nbf.zip) finalname=`dirname $out_name`/`basename $target_name .zip` mv $out_name $finalname zip -j $target_name $finalname ;; *.nb1 | *.nbf) mv $out_name $target_name ;; *.exe) mkdir out/English 2>/dev/null mv $out_name out/English/NK.nbf ( cd out ; zip ../$target_name English/NK.nbf ) unzip -v $target_name rm -rf out/English ;; *) echo "unknown target type" && exit 1 ;; esac