Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2815172
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2009-09-11 09:31:21

1:公司为了增加svn update时的灵活性,决定让我写个脚本(这个是我自己留作备份之用!这个脚本中项目之间的关系一下说不清楚!)
我的build.prop文件内容如下:

2:

xliu@qhtlnx28 ~/project$ cat build.prop
#auf=common:branches,p.a.0,head;customtags:branches,p.b.0,head;flextag:branches,p.c.0,head
auf=common:hello,p.a.0,head;customtags:hello,p.b.0,head;flextag:hello,p.c.0,head

#!/bin/sh

#programme

# Trying to update and switch to another version making the update and compile conveniently

# Author xliu

# history 2009-09-09

# first release

#set the variable pwd

pwd=~/project

ip=*.*.*.* ##svn server的ip地址

port=** #svn server使用的端口号

#only one user can run the script at the same time on every port

/bin/ps -ef | grep $USER | grep make_wars.sh | grep -v grep|wc -l >${pwd}/num

num=`cat ~/project/num`

if [ "$num" != "1" ]; then

echo "Another person is running ,please wait"

rm -f ${pwd}/num

exit 0

fi

rm -f ${pwd}/num

#load the configure of OS's environment

. ~/.bashrc

#shudown the port

echo "Your port is going to be shutdown,please waiting!!"

~/bin/myshutdown.sh

if [ -e ${pwd}/build.prop ] #when the build.prop file exists ,execute the following code

then

#If there is no parameter ,You are needed to pass

if [ $# -eq 0 ]

then

echo "Usage the prameter is needed such as: ./make_wars.sh ttv"

exit

fi

#the main process

for var in $@

do

#get the information from build.prop under ~/project

/bin/cat ${pwd}/build.prop| grep "^${var}" >${pwd}/${var}.txt

if [ "`cat ${pwd}/${var}.txt`" = "" ]

then

echo "The package name does not exist,Please fix it"

rm -f ${pwd}/${var}.txt

~/bin/mystartup.sh

exit

else

cat ${pwd}/${var}.txt|awk -F= '{print $2}'>${pwd}/${var}_info.txt

fi

# for testing whether it is in {dot internal rad rem ttv loc itv afl auf itv}

if [ "${var}" = "auf" -o "${var}" = "afl" -o "${var}" = "dot" -o "${var}" = "internal" -o "${var}" = "rad" -o "${var}" = "rem" -o "${var}" = "ttv" -o "${var}" = "mpm" -o "${var}" = "itv" -o "${var}" = "loc" ]

then

#common package update and switch

awk -F\; '{ print $1 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_common.txt

awk -F: '{ print $2 }' ${pwd}/${var}_info_common.txt >${pwd}/common_value.txt

branches=`awk -F, '{ print $1 }' ${pwd}/common_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches}/${directory}

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches} 2>>${pwd}/error.log

else

echo "No Match,use the default settings"

branches="branches"

directory="p.a.0"

version="head"

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

ant 2>>${pwd}/error.log

#echo "Convet Common Package to the original branches/p.a.0"

#svn switch -r HEAD svn://${ip}:${port}/home/svnsource/common/branches/p.a.0

#customtags package update and switch

awk -F\; '{ print $2 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_customtags.txt

awk -F: '{print $2}' ${pwd}/${var}_info_customtags.txt >${pwd}/customtags_value.txt

branches=`awk -F, '{print $1}' ${pwd}/customtags_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/customtags_value.txt`

version=`awk -F, '{print $3}' ${pwd}/customtags_value.txt`

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/customtags ${pwd}/customtags_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/customtags/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/customtags_value.txt`

version=`awk -F, '{print $3}' ${pwd}/customtags_value.txt`

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/customtags ${pwd}/customtags_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/customtags/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/customtags_value.txt`

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/customtags ${pwd}/customtags_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/customtags/${branches} 2>>${pwd}/error.log

else

echo "No Match Use the defalut settings"

branches="branches"

directory="p.b.0"

version="head"

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/customtags/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

ant 2>>${pwd}/error.log

#echo "Convert Customtags Package to the original branches/p.b.0"

#svn switch -r HEAD svn://${ip}:${port}/home/svnsource/customtags/branches/p.b.0

 

#flextag package update and switch

awk -F\; '{ print $3 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_flextag.txt

awk -F: '{print $2}' ${pwd}/${var}_info_flextag.txt >${pwd}/flextag_value.txt

branches=`awk -F, '{print $1}' ${pwd}/flextag_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/flextag_value.txt`

version=`awk -F, '{print $3}' ${pwd}/flextag_value.txt`

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/flextag ${pwd}/flextag_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/flextag/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/flextag_value.txt`

version=`awk -F, '{print $3}' ${pwd}/flextag_value.txt`

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/flextag ${pwd}/flextag_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/flextag/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/flextag_value.txt`

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/flextag ${pwd}/flextag_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/flextag/${branches} 2>>${pwd}/error.log

else

echo "No Match,Use the default Settings"

branches="branches"

directory="p.c.0"

version="head"

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/flextag/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

ant 2>>${pwd}/error.log

#echo "Convert Flextag package to the original branches/p.c.0"

#svn switch -r HEAD svn://${ip}:${port}/home/svnsource/flextag/branches/p.c.0'

 

#remove the *.txt files generated by the script

rm -f ${pwd}/${var}.txt

rm -f ${pwd}/${var}_info.txt

rm -f ${pwd}/${var}_info_common.txt

rm -f ${pwd}/${var}_info_customtags.txt

rm -f ${pwd}/${var}_info_flextag.txt

rm -f ${pwd}/common_value.txt

rm -f ${pwd}/customtags_value.txt

rm -f ${pwd}/flextag_value.txt

#compile and deploy ${var} packages

cd ~/project/${var}

svn cleanup 2>>${pwd}/error.log

svn update 2>>${pwd}/error.log

ant clean 2>>${pwd}/error.log

sleep 3

ant deploy 2>>${pwd}/error.log

sleep 6

#deal with for common customtags flextag(generatated in the process)

rm -fr ${pwd}/common

rm -fr ${pwd}/customtags

rm -fr ${pwd}/flextag

mv ${pwd}/common_bak ${pwd}/common

svn cleanup

svn update

mv ${pwd}/customtags_bak ${pwd}/customtags

svn cleanup

svn update

mv ${pwd}/flextag_bak ${pwd}/flextag

svn cleanup

svn update

# $var is flextag or customtags

else

#the process for handling when the parameter is in {flextag customtags}

#handle the common package when the parameter is in {flextag customtags}

awk -F\; '{ print $1 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_common.txt

awk -F: '{ print $2 }' ${pwd}/${var}_info_common.txt >${pwd}/common_value.txt

awk -F\; '{ print $2 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_value.txt

awk -F: '{ print $2 }' ${pwd}/${var}_info_value.txt >${pwd}/${var}_value.txt

branches=`awk -F, '{print $1}' ${pwd}/common_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches}/${directory}

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches} 2>>${pwd}/error.log

else

echo "No Match,use the default settings"

branches="branches"

directory="p.a.0"

version="head"

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

sleep 2

ant 2>>${pwd}/error.log

echo " Convert Common package to the original branches/p.a.0"

#svn switch -r HEAD svn://${ip}:${port}/home/svnsource/common/branches/p.a.0

 

 

#handle when the parameter flextag or cutomtags

branches=`awk -F, '{print $1}' ${pwd}/${var}_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/${var}_value.txt`

version=`awk -F, '{print $3}' ${pwd}/${var}_value.txt`

cd ${pwd}/${var}

svn cleanup

svn update

cp -r ${pwd}/${var} ${pwd}/${var}_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/${var}/${branches}/${directory}

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/${var}_value.txt`

version=`awk -F, '{print $3}' ${pwd}/${var}_value.txt`

cd ${pwd}/${var}

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/${var} ${pwd}/${var}_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/${var}/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/common_value.txt`

cd ${pwd}/${var}

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://${ip}:${port}/home/svnsource/${var}/${branches} 2>>${pwd}/error.log

else

echo "No Match,use please check the parameter that you passed"

rm -f ${pwd}/${var}.txt

rm -f ${pwd}/${var}_info.txt

rm -f ${pwd}/${var}_info_common.txt

rm -f ${pwd}/${var}_value.txt

fi

ant clean 2>>${pwd}/error.log

sleep 2

ant 2>>${pwd}/error.log

##convert to the original version

#if [ "${var}" = "customtags" ]

# then

# echo "Convert Customtags Package to original branches/p.b.0"

# cd ${pwd}/customtags

# svn switch -r HEAD svn://${ip}:${port}/home/svnsource/customtags/branches/p.b.0

#

#fi

#if [ "${var}" = "flextag" ]

# then

# echo "Convert Flextag Package to original branches/p.c.0"

# cd ${pwd}/flextag

# svn switch -r HEAD svn://${ip}:${port}/home/svnsource/flextag/branches/p.c.0

#fi

 

 

#deal with for common and ${var} package

rm -fr ${pwd}/common

mv ${pwd}/common_bak ${pwd}/common

cd ${pwd}/common

svn cleanup

svn update

rm -fr ${pwd}/${var}

mv ${pwd}/${var}_bak ${pwd}/${var}

svn cleanup

svn update

 

#remove unnecessary files

rm -f ${pwd}/{${var}_value.txt,${var}_info_common.txt,${var}_info_value.txt,common_value.txt,project_${var}.txt,${var}.txt,${var}_info.txt}

fi

done

 

else #when the build.prop file does exist ,excute the following code

if [ $# -eq 0 ]

then

echo "Usage the prameter is needed such as: ./make_wars.sh ttv"

exit

fi

#complile customtags and flextag

for var in common customtags flextag

do

cd ${pwd}/$var

svn cleanup

svn update

ant clean 2>>${pwd}/error.log

sleep 3

ant 2>>${pwd}/error.log

sleep 5

done

#compile package auf\dot\dot2\intenal\ms2\rad\rem\loc\ttv

for var in $@

do

cd ${pwd}/$var

svn cleanup

svn update

ant clean 2>>${pwd}/error.log

sleep 3

ant deploy 2>>${pwd}/error.log

sleep 5

done

fi

#startup the port

~/bin/mystartup.sh

该版本有问题,例如:人为的手动终止脚本(没有在此添加处理!)

#!/bin/sh

#programme

# Trying to update and switch to another version making the update and compile conveniently

# Author xliu

# history 2009-09-09

# first release

#set the variable pwd

#fina edition fix the bug for interrupting the script with ctrl+c

pwd=~/project

ip="*"

port="*"

#only one user can run the script at the same time

/bin/ps -ef | grep $USER | grep make_wars.sh | grep -v grep|wc -l >${pwd}/num

num=`cat ~/project/num`

if [ "$num" != "1" ]; then

echo "Another person is running ,please wait"

rm -f ${pwd}/num

exit 0

fi

rm -f ${pwd}/num

#load the configure of OS's environment

. ~/.bashrc

#if someone interupts the script,the following code will performance it

if [ -d ${pwd}/common_bak ]

then

/bin/rm -fr ${pwd}/common_bak

echo "Initialize common to p.a.0 because someone interrupted it last time,Please Wait"

sleep 3

cd ${pwd}/common

/usr/local/svn/bin/svn cleanup

/usr/local/svn/bin/svn switch -r HEAD svn://${ip}:${port}/home/svnsource/common/branches/p.a.0

fi

#if someone interupts the script,the following code will performance it

if [ -d ${pwd}/customtags_bak ]

then

/bin/rm -fr ${pwd}/customtags_bak

echo "Initialize customtags to p.b.0 because someone interrupted it last time,Please Wait"

sleep 3

cd ${pwd}/customtags

/usr/local/svn/bin/svn cleanup

/usr/local/svn/bin/svn switch -r HEAD svn://${ip}:${port}/home/svnsource/customtags/branches/p.b.0

fi

#if someone interupts the script,the following code will performance it

if [ -d ${pwd}/flextag_bak ]

then

/bin/rm -fr ${pwd}/flextag_bak

echo "Initialize flextag to p.c.0 because someone interrupted it last time,Please Wait"

sleep 3

cd ${pwd}/flextag

/usr/local/svn/bin/svn cleanup

/usr/local/svn/bin/svn switch -r HEAD svn://${ip}:${port}/home/svnsource/flextag/branches/p.c.0

fi

#shudown the port

echo "Your port is going to be shutdown,please waiting!!"

~/bin/myshutdown.sh

if [ -e ${pwd}/build.prop ] #when the build.prop file exists ,execute the following code

then

#If there is no parameter ,You are needed to pass

if [ $# -eq 0 ]

then

echo "Usage the prameter is needed such as: ./make_wars.sh ttv"

exit

fi

#the main process

for var in $@

do

#get the information from build.prop under ~/project

/bin/cat ${pwd}/build.prop| grep "^${var}" >${pwd}/${var}.txt

if [ "`cat ${pwd}/${var}.txt`" = "" ]

then

echo "The package name does not exist,Please fix it"

rm -f ${pwd}/${var}.txt

~/bin/mystartup.sh

exit

else

cat ${pwd}/${var}.txt|awk -F= '{print $2}'>${pwd}/${var}_info.txt

fi

# for testing whether it is in {dot internal rad rem ttv loc itv afl auf itv}

if [ "${var}" = "auf" -o "${var}" = "afl" -o "${var}" = "dot" -o "${var}" = "internal" -o "${var}" = "rad" -o "${var}" = "rem" -o "${var}" = "ttv" -o "${var}" = "mpm" -o "${var}" = "itv" -o "${var}" = "loc" ]

then

#common package update and switch

awk -F\; '{ print $1 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_common.txt

awk -F: '{ print $2 }' ${pwd}/${var}_info_common.txt >${pwd}/common_value.txt

branches=`awk -F, '{ print $1 }' ${pwd}/common_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches}/${directory}

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches} 2>>${pwd}/error.log

else

echo "No Match,use the default settings"

branches="branches"

directory="p.a.0"

version="head"

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

ant 2>>${pwd}/error.log

#echo "Convet Common Package to the original branches/p.a.0"

#svn switch -r HEAD svn://*:*/home/svnsource/common/branches/p.a.0

#customtags package update and switch

awk -F\; '{ print $2 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_customtags.txt

awk -F: '{print $2}' ${pwd}/${var}_info_customtags.txt >${pwd}/customtags_value.txt

branches=`awk -F, '{print $1}' ${pwd}/customtags_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/customtags_value.txt`

version=`awk -F, '{print $3}' ${pwd}/customtags_value.txt`

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/customtags ${pwd}/customtags_bak

svn switch -r ${version} svn://*:*/home/svnsource/customtags/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/customtags_value.txt`

version=`awk -F, '{print $3}' ${pwd}/customtags_value.txt`

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/customtags ${pwd}/customtags_bak

svn switch -r ${version} svn://*:*/home/svnsource/customtags/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/customtags_value.txt`

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/customtags ${pwd}/customtags_bak

svn switch -r ${version} svn://*:*/home/svnsource/customtags/${branches} 2>>${pwd}/error.log

else

echo "No Match Use the defalut settings"

branches="branches"

directory="p.b.0"

version="head"

cd ${pwd}/customtags

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://*:*/home/svnsource/customtags/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

ant 2>>${pwd}/error.log

#echo "Convert Customtags Package to the original branches/p.b.0"

#svn switch -r HEAD svn://*:*/home/svnsource/customtags/branches/p.b.0

 

#flextag package update and switch

awk -F\; '{ print $3 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_flextag.txt

awk -F: '{print $2}' ${pwd}/${var}_info_flextag.txt >${pwd}/flextag_value.txt

branches=`awk -F, '{print $1}' ${pwd}/flextag_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/flextag_value.txt`

version=`awk -F, '{print $3}' ${pwd}/flextag_value.txt`

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/flextag ${pwd}/flextag_bak

svn switch -r ${version} svn://*:*/home/svnsource/flextag/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/flextag_value.txt`

version=`awk -F, '{print $3}' ${pwd}/flextag_value.txt`

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/flextag ${pwd}/flextag_bak

svn switch -r ${version} svn://*:*/home/svnsource/flextag/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/flextag_value.txt`

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/flextag ${pwd}/flextag_bak

svn switch -r ${version} svn://*:*/home/svnsource/flextag/${branches} 2>>${pwd}/error.log

else

echo "No Match,Use the default Settings"

branches="branches"

directory="p.c.0"

version="head"

cd ${pwd}/flextag

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://*:*/home/svnsource/flextag/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

ant 2>>${pwd}/error.log

#echo "Convert Flextag package to the original branches/p.c.0"

#svn switch -r HEAD svn://*:*/home/svnsource/flextag/branches/p.c.0'

 

#remove the *.txt files generated by the script

rm -f ${pwd}/${var}.txt

rm -f ${pwd}/${var}_info.txt

rm -f ${pwd}/${var}_info_common.txt

rm -f ${pwd}/${var}_info_customtags.txt

rm -f ${pwd}/${var}_info_flextag.txt

rm -f ${pwd}/common_value.txt

rm -f ${pwd}/customtags_value.txt

rm -f ${pwd}/flextag_value.txt

#compile and deploy ${var} packages

cd ~/project/${var}

svn cleanup 2>>${pwd}/error.log

svn update 2>>${pwd}/error.log

ant clean 2>>${pwd}/error.log

sleep 3

ant deploy 2>>${pwd}/error.log

sleep 6

#deal with for common customtags flextag(generatated in the process)

rm -fr ${pwd}/common

rm -fr ${pwd}/customtags

rm -fr ${pwd}/flextag

mv ${pwd}/common_bak ${pwd}/common

svn cleanup

svn update

mv ${pwd}/customtags_bak ${pwd}/customtags

svn cleanup

svn update

mv ${pwd}/flextag_bak ${pwd}/flextag

svn cleanup

svn update

# $var is flextag or customtags

else

#the process for handling when the parameter is in {flextag customtags}

#handle the common package when the parameter is in {flextag customtags}

awk -F\; '{ print $1 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_common.txt

awk -F: '{ print $2 }' ${pwd}/${var}_info_common.txt >${pwd}/common_value.txt

awk -F\; '{ print $2 }' ${pwd}/${var}_info.txt >${pwd}/${var}_info_value.txt

awk -F: '{ print $2 }' ${pwd}/${var}_info_value.txt >${pwd}/${var}_value.txt

branches=`awk -F, '{print $1}' ${pwd}/common_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches}/${directory}

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/common_value.txt`

version=`awk -F, '{print $3}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/common_value.txt`

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches} 2>>${pwd}/error.log

else

echo "No Match,use the default settings"

branches="branches"

directory="p.a.0"

version="head"

cd ${pwd}/common

svn cleanup 2>>${pwd}/error.log

svn switch -r ${version} svn://*:*/home/svnsource/common/${branches}/${directory} 2>>${pwd}/error.log

fi

ant clean 2>>${pwd}/error.log

sleep 2

ant 2>>${pwd}/error.log

echo " Convert Common package to the original branches/p.a.0"

#svn switch -r HEAD svn://*:*/home/svnsource/common/branches/p.a.0

 

 

#handle when the parameter flextag or cutomtags

branches=`awk -F, '{print $1}' ${pwd}/${var}_value.txt`

if [ "${branches}" = "branches" ]

then

directory=`awk -F, '{print $2}' ${pwd}/${var}_value.txt`

version=`awk -F, '{print $3}' ${pwd}/${var}_value.txt`

cd ${pwd}/${var}

svn cleanup

svn update

cp -r ${pwd}/${var} ${pwd}/${var}_bak

svn switch -r ${version} svn://*:*/home/svnsource/${var}/${branches}/${directory}

elif [ "${branches}" = "tags" ]

then

directory=`awk -F, '{print $2}' ${pwd}/${var}_value.txt`

version=`awk -F, '{print $3}' ${pwd}/${var}_value.txt`

cd ${pwd}/${var}

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/${var} ${pwd}/${var}_bak

svn switch -r ${version} svn://*:*/home/svnsource/${var}/${branches}/${directory} 2>>${pwd}/error.log

elif [ "${branches}" = "trunk" ]

then

version=`awk -F, '{print $2}' ${pwd}/common_value.txt`

cd ${pwd}/${var}

svn cleanup 2>>${pwd}/error.log

svn update

cp -r ${pwd}/common ${pwd}/common_bak

svn switch -r ${version} svn://*:*/home/svnsource/${var}/${branches} 2>>${pwd}/error.log

else

echo "No Match,use please check the parameter that you passed"

rm -f ${pwd}/${var}.txt

rm -f ${pwd}/${var}_info.txt

rm -f ${pwd}/${var}_info_common.txt

rm -f ${pwd}/${var}_value.txt

fi

ant clean 2>>${pwd}/error.log

sleep 2

ant 2>>${pwd}/error.log

##convert to the original version

#if [ "${var}" = "customtags" ]

# then

# echo "Convert Customtags Package to original branches/p.b.0"

# cd ${pwd}/customtags

# svn switch -r HEAD svn://*:*/home/svnsource/customtags/branches/p.b.0

#

#fi

#if [ "${var}" = "flextag" ]

# then

# echo "Convert Flextag Package to original branches/p.c.0"

# cd ${pwd}/flextag

# svn switch -r HEAD svn://*:*/home/svnsource/flextag/branches/p.c.0

#fi

 

 

#deal with for common and ${var} package

rm -fr ${pwd}/common

mv ${pwd}/common_bak ${pwd}/common

cd ${pwd}/common

svn cleanup

svn update

rm -fr ${pwd}/${var}

mv ${pwd}/${var}_bak ${pwd}/${var}

svn cleanup

svn update

 

#remove unnecessary files

rm -f ${pwd}/{${var}_value.txt,${var}_info_common.txt,${var}_info_value.txt,common_value.txt,project_${var}.txt,${var}.txt,${var}_info.txt}

fi

done

 

else #when the build.prop file does exist ,excute the following code

if [ $# -eq 0 ]

then

echo "Usage the prameter is needed such as: ./make_wars.sh ttv"

exit

fi

#complile customtags and flextag

for var in common customtags flextag

do

cd ${pwd}/$var

svn cleanup

svn update

ant clean 2>>${pwd}/error.log

sleep 3

ant 2>>${pwd}/error.log

sleep 5

done

#compile package auf\dot\dot2\intenal\ms2\rad\rem\loc\ttv

for var in $@

do

cd ${pwd}/$var

svn cleanup

svn update

ant clean 2>>${pwd}/error.log

sleep 3

ant deploy 2>>${pwd}/error.log

sleep 5

done

fi

#startup the port

~/bin/mystartup.sh


阅读(2110) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~