User Tools

Site Tools


work:android-shell

This is an old revision of the document!


工作中用到的一些脚本

由于办公室用的是colinux,生成的东西都要通过samba共享出来,有时候目录太深,拷贝文件很不方便,于是就写了几个小脚本来自动拷贝文件.

还有一些其它乱七八糟的脚本.

mymake.sh

用来快速编译单个AP,并将生成的APK拷贝到指定的目录下面,需要放到android工程根目录下.

root@ubuntu:/ice/android# cat mymake.sh



#!/bin/bash

#echo "make Browser && cp out/target/product/generic/system/app/Browser.apk /ice/targetimg/"

#make Browser && cp out/target/product/generic/system/app/Browser.apk /ice/targetimg/





START_AT=`date`



ROOT_DIR=/ice/android



TARGET=generic

#TARGET=msm7627_ffa



TARGET_DEST=/ice/targetimg/${TARGET}



IMAGE_DIR=${ROOT_DIR}/out/target/product/${TARGET}



mkdir -p ${TARGET_DEST}



FRAMEWORK_DIR=${ROOT_DIR}/out/target/product/${TARGET}/system/framework/

OUT_DIR=${ROOT_DIR}/out/target/product/${TARGET}/system/app



if [ ${#} != 1 ];then

echo "USAGE:${0} module_name"

echo "example: ${0} Browser"

echo "Then Browser.apk will be copied to ${TARGET_DEST}"

exit 0

fi



echo "Now start make ${1}"

. build/envsetup.sh

make ${1}





if [ ${1} = "framework" -o ${1} = "core" ];then

echo "cp ${FRAMEWORK_DIR}/${1}.jar ${TARGET_DEST}/"

cp ${FRAMEWORK_DIR}/${1}.jar ${TARGET_DEST}/



elif [ ${1} = "snod"   ];then

echo "cp  ${IMAGE_DIR}/system.img ${TARGET_DEST}/"

cp  ${IMAGE_DIR}/system.img ${TARGET_DEST}/





else

echo "cp ${OUT_DIR}/${1}.apk ${TARGET_DEST}/"

cp ${OUT_DIR}/${1}.apk ${TARGET_DEST}/



fi



#out/target/product/generic/system/framework/core.jar





END_AT=`date`



echo "START AT:${START_AT}"

echo "Finished AT:${END_AT}"


makedalvik.sh

编译dalvik目录,并调用mymake.sh直接打包system.img(make snod)

root@ubuntu:~/shell# cat makedalvik.sh

#!/bin/bash



echo "Make dalvik for Target,and will run make snod to package the system.img"



echo ". build/envsetup.sh"

source build/envsetup.sh

echo "choosecombo Device release msm7627_ffa eng"

choosecombo Device release msm7627_ffa eng

echo "cd dalvik"

cd dalvik

echo "mm"

mm

echo "cd .."

cd ..

echo "./mymake snod"

./mymake.sh snod


mybuild.sh

用来编译整个工程的,拷贝生成的image到指定目录

root@ubuntu:/ice/android/build# cat mybuild.sh

#!/bin/sh



START=`date`

EMU_SOURCEDIR=/ice/android/out/target/product/generic

TARGET_SOURCEDIR=/ice/android/out/target/product/msm7627_ffa



EMU_DESTDIR=/ice/targetimg/emulator/

TARGET_DESTDIR=/ice/targetimg/target/





mkdir -p ${EMU_DESTDIR}

mkdir -p ${TARGET_DESTDIR}





[ -e ${TARGET_DESTDIR}download.sh  ] || { echo "cp /root/shell/download.sh/ ${TARGET_DESTDIR};"; cp /root/shell/download.sh ${TARGET_DESTDIR}; }



#./build.sh ${1}



if [ ${1} = "target" ]; then



        echo "cp ${TARGET_SOURCEDIR}/boot.img ${TARGET_DESTDIR} "

        cp ${TARGET_SOURCEDIR}/boot.img ${TARGET_DESTDIR}



        echo "cp ${TARGET_SOURCEDIR}/system.img ${TARGET_DESTDIR} "

        cp ${TARGET_SOURCEDIR}/system.img ${TARGET_DESTDIR}



        echo "cp ${TARGET_SOURCEDIR}/userdata.img ${TARGET_DESTDIR} "

        cp ${TARGET_SOURCEDIR}/userdata.img ${TARGET_DESTDIR}



        echo "cp ${TARGET_SOURCEDIR}/system/app/Browser.apk ${TARGET_DESTDIR}"

        cp ${TARGET_SOURCEDIR}/system/app/Browser.apk ${TARGET_DESTDIR}



elif [ ${1} = "emulator" ];then



        echo "cp ${EMU_SOURCEDIR}/boot.img ${EMU_DESTDIR} "

        cp ${EMU_SOURCEDIR}/boot.img ${EMU_DESTDIR}



        echo "cp ${EMU_SOURCEDIR}/system.img ${EMU_DESTDIR} "

        cp ${EMU_SOURCEDIR}/system.img ${EMU_DESTDIR}



        echo "cp ${EMU_SOURCEDIR}/userdata.img ${EMU_DESTDIR} "

        cp ${EMU_SOURCEDIR}/userdata.img ${EMU_DESTDIR}

        echo "cp ${EMU_SOURCEDIR}/system/app/Browser.apk ${EMU_DESTDIR}"

        cp ${EMU_SOURCEDIR}/system/app/Browser.apk ${EMU_DESTDIR}

else

        echo "Nothing to copy"



fi







END=`date`

echo "Start at ${START}"

echo "finished at ${END}"


getpnglist.sh

用来查找drawable png图片在哪些java文件里面用到的脚本

root@ubuntu:~/shell# cat getpnglist.sh

#!/bin/sh

#Author:pengjianqing@gmail.com

#Date:2010/02/03

#Description:

#Use the shell to find the resource file and where the resource file is used

#the default file is png

#Example:

#cd /ice

#./getpnglist.sh Browser

#

START_AT=`date`



APP_NAME=${1}

APP_DIR=android/packages/apps

RES_DIR=res



FILE_TYPE=png



echo "Get the ${APP_NAME} png list in the resource directory"

echo "*************************************************************"



echo "Create the ${APP_NAME}_${FILE_TYPE}_list.txt"

ls ${APP_DIR}/${APP_NAME}/${RES_DIR}/*/*.${FILE_TYPE}|grep -v hdpi >${APP_NAME}_${FILE_TYPE}_list.txt

echo "*************************************************************"



FILE_LIST=`ls ${APP_DIR}/${APP_NAME}/${RES_DIR}/*/*.${FILE_TYPE}|grep -v hdpi`



echo "Create the ${APP_NAME}_${FILE_TYPE}_WhereUsed_list.txt"

echo ${RESULT}>${APP_NAME}_${FILE_TYPE}_WhereUsed_list.txt

echo "*************************************************************"

for i in `echo ${FILE_LIST}`:

do

   echo "*************************************************************" >>${APP_NAME}_${FILE_TYPE}_WhereUsed_list.txt

     FILENAME=`echo ${i}|cut -d "/" -f7|cut -d "." -f1`

     echo "Filename:${FILENAME}" >>${APP_NAME}_${FILE_TYPE}_WhereUsed_list.txt



     #grep -i -R -n ${FILENAME} ${APP_DIR}/${APP_NAME} -d ${APP_DIR}/${APP_NAME}/.git/

    RESULT=`grep -i -R -n ${FILENAME} ${APP_DIR}/${APP_NAME}/src ${APP_DIR}/${APP_NAME}/res`

   echo "${RESULT}"



   echo ${RESULT}>>${APP_NAME}_${FILE_TYPE}_WhereUsed_list.txt

echo "*************************************************************"

done

echo "*************************************************************"

END_AT=`date`

echo "Start at:${START_AT}"

echo "Finished at:${END_AT}"

echo "done."




/var/www/dokuwiki/wiki/data/attic/work/android-shell.1350897703.txt.gz · Last modified: 2016/05/05 13:06 (external edit)