[G1 Android Development] Firerat:
Sorry , I have uploaded a new script

#!/sbin/sh
SYSTEM="/system"
DATA="/data"
CACHE="/cache"
UPDATESCRIPT="/data/META-INF/com/google/android/update-script"
INSTALL_SCRIPT="/dev/install.sh"
GREP_CMD="grep"
UNZIP_CMD="unzip"
SED_CMD="sed"
CUT_CMD="cut"
CHMOD_CMD="chmod"
CHOWN_CMD="chown"
CP_CMD="cp"
MOUNT_CMD="mount"
TEE_CMD="tee"
RM_CMD="rm"
MKDIR_CMD="mkdir"
LN_CMD="ln"
DOS2UNIX_CMD="busybox dos2unix"
#############

if [ -e $UPDATESCRIPT ];
then
$DOS2UNIX_CMD $UPDATESCRIPT
# symlinks
$GREP_CMD symlink $UPDATESCRIPT |$GREP_CMD -v app_s|$SED_CMD -e s~symlink~$LN_CMD\ -s~ -e s~SYSTEM\:~$SYSTEM/~|$TEE_CMD -a $INSTALL_SCRIPT

# recursive permision changes
$GREP_CMD set_perm_recursive $UPDATESCRIPT |$GREP_CMD SYSTEM|$SED_CMD -e s~set_perm_recursive~$CHMOD_CMD\ -R~ -e s~SYSTEM\:~$SYSTEM\\\/~|$CUT_CMD -d " " -f 1,2,5,7 > /dev/chmodr1.tmp
$GREP_CMD set_perm_recursive $UPDATESCRIPT |$GREP_CMD SYSTEM|$SED_CMD -e s~set_perm_recursive~$CHMOD_CMD\ -R~ -e s~SYSTEM\:~$SYSTEM\\\/~|$CUT_CMD -d " " -f 1,2,6,7|$SED_CMD s/\$/\\\/\*/|$SED_CMD s/\\\/\\\//\\\// > /dev/chmodr2.tmp

# keep recursive permision changes in order ( top down )
cmrl=`$SED_CMD -n '$=' /dev/chmodr1.tmp`
for i in `seq 1 $cmrl`;do
$SED_CMD "$i !d" /dev/chmodr1.tmp|$TEE_CMD -a $INSTALL_SCRIPT
$SED_CMD "$i !d" /dev/chmodr2.tmp|$TEE_CMD -a $INSTALL_SCRIPT
done
# just a little tidy up
$RM_CMD /dev/chmodr*tmp

#system permisions
$GREP_CMD set_perm_recursive $UPDATESCRIPT |$GREP_CMD SYSTEM|$SED_CMD -e s~set_perm_recursive~$CHOWN_CMD\ -R~ -e s~SYSTEM\:~$SYSTEM/~|$CUT_CMD -d " " -f 1,2,3,4,7|$SED_CMD s~\ ~.~3|$TEE_CMD -a $INSTALL_SCRIPT
$GREP_CMD set_perm\ $UPDATESCRIPT |$GREP_CMD SYSTEM|$SED_CMD -e s~set_perm~$CHOWN_CMD~ -e s~SYSTEM\:~$SYSTEM/~|$CUT_CMD -d " " -f 1,2,3,5|$SED_CMD -e s~\ ~.~2|$TEE_CMD -a $INSTALL_SCRIPT
$GREP_CMD set_perm\ $UPDATESCRIPT |$GREP_CMD SYSTEM|$SED_CMD -e s~set_perm~$CHMOD_CMD~ -e s~SYSTEM\:~$SYSTEM/~|$CUT_CMD -d " " -f 1,4,5|$TEE_CMD -a $INSTALL_SCRIPT

#data permision changes ( do we need to worry about order? )
$GREP_CMD set_perm_recursive $UPDATESCRIPT |$GREP_CMD DATA|$SED_CMD -e s~set_perm_recursive~$CHOWN_CMD\ -R~ -e s~DATA\:~$DATA/~|$CUT_CMD -d " " -f 1,2,3,4,7|$SED_CMD s~\ ~.~3|$TEE_CMD -a $INSTALL_SCRIPT
$GREP_CMD set_perm\ $UPDATESCRIPT |$GREP_CMD DATA|$SED_CMD -e s~set_perm~$CHOWN_CMD~ -e s~DATA\:~$DATA/~|$CUT_CMD -d " " -f 1,2,3,5|$SED_CMD -e s~\ ~.~2|$TEE_CMD -a $INSTALL_SCRIPT
$GREP_CMD set_perm\ $UPDATESCRIPT |$GREP_CMD DATA|$SED_CMD -e s~set_perm~$CHMOD_CMD~ -e s~DATA\:~$DATA/~|$CUT_CMD -d " " -f 1,4,5|$TEE_CMD -a $INSTALL_SCRIPT

#cache permision changes, who knows we could have a non cut'n'paste rom ;)
$GREP_CMD set_perm_recursive $UPDATESCRIPT |$GREP_CMD CACHE|$SED_CMD -e s~set_perm_recursive~$CHOWN_CMD\ -R~ -e s~CACHE\:~$CACHE/~|$CUT_CMD -d " " -f 1,2,3,4,7|$SED_CMD s~\ ~.~3|$TEE_CMD -a $INSTALL_SCRIPT
$GREP_CMD set_perm\ $UPDATESCRIPT |$GREP_CMD CACHE|$SED_CMD -e s~set_perm~$CHOWN_CMD~ -e s~CACHE\:~$CACHE/~|$CUT_CMD -d " " -f 1,2,3,5|$SED_CMD -e s~\ ~.~2|$TEE_CMD -a $INSTALL_SCRIPT
$GREP_CMD set_perm\ $UPDATESCRIPT |$GREP_CMD CACHE|$SED_CMD -e s~set_perm~$CHMOD_CMD~ -e s~CACHE\:~$CACHE/~|$CUT_CMD -d " " -f 1,4,5|$TEE_CMD -a $INSTALL_SCRIPT
fi