`
xifengtaizi
  • 浏览: 11432 次
  • 性别: Icon_minigender_2
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

xbuild.sh

    博客分类:
  • UNIX
 
阅读更多

ME=xbuild.sh

#echo - Check for updates ......
if [ /home/sh13256/$ME -nt $0 ]; then
#  echo - New version found. Update ...
  cp /home/sh13256/$ME $0
  echo - $0 Updated. Relaunching ...
  echo
  echo "$0 $*"
  $0 $*
  exit
fi
#echo - $0 is up to date

#set -x

Usage(){
  echo
  echo " Usage:"
  echo
  echo "     - 1 - Compilation Jobs - "
  echo
  echo "     $0 lqtfront     : build LQT front end    (CVS Update, Compile)"
  echo "     $0 lqtback      : build LQT back end     (CVS Update, Compile)"
  echo "     $0 lqt          : build LQT front & back (CVS Update, Compile)"
  echo
  echo "     $0 lqtfront [N] : build LQT front end lazily"
  echo "     $0 lqtback [N]  : build LQT back end lazily"
  echo "     $0 lqt [N]      : build LQT front & back lazily"
  echo
  echo "     $0 lqtfrontC    : build LQT front end    (Compile Only)"
  echo "     $0 lqtbackC     : build LQT back end     (Compile Only)"
  echo
  echo "     $0 loanwl       : build Loan WL"
  echo "     $0 loanwl [N]   : build Loan WL lazily"
  echo
  echo "                [N] : number of updated files, will skip compile if there are not enough updates."
  echo
  echo "     Create a file 'To' at the same dir. Enter email addresses in it, one email each line."
  echo "     Logs will be send to these emails."
  echo
  echo "     - 2 - Hermes Jobs - "
  echo
  echo "     $0 lqtfrontH releasetype [config file] : send LQT front end to Hermes "
  echo "     $0 lqtbackH  releasetype [config file] : send LQT back end to Hermes "
  echo "     $0 loanwlH   releasetype [config file] : send LoanWL to Hermes "
  echo "     $0 lqtDBH    releasetype [config file] : send LoansQTDB to Hermes "
  echo
  echo "               releasetype = integration | major | minor | bugfix | resubmission"
  echo "               in [config file]: AdditionalEmailList=[comma separated list of email addresses to CC.]"
  echo

  exit

}

if [ $# -lt 1 ]; then
  Usage
fi

CMD=$1
CMD_LQT='lqt'
CMD_FRONT='lqtfront'
CMD_BACK='lqtback'
CMD_LWL='loanwl'
CMD_LQTDBH='lqtDBH'
xROOT=`pwd`
LOGFRONT=$xROOT/.$CMD_FRONT.log
LOGBACK=$xROOT/.$CMD_BACK.log
LOGLWL=$xROOT/.$CMD_LWL.log
LOGCVS=$xROOT/.cvs.log
LOG_DB=$xROOT/.$CMD_LQTDBH.log
TO=$xROOT/To

LWL_COMPILE=lwlCompile
BRANCH_FILE=$xROOT/.branch
LQT_BRANCH=`cat ${BRANCH_FILE} | grep '^LQT:' | sed 's/^LQT://'`
LWL_BRANCH=`cat ${BRANCH_FILE} | grep '^LWL:' | sed 's/^LWL://'`


sendMail(){
#  #set -x

  TOLIST=`echo shangshang.hu@iuo.citi.com`
  MY_MAIL=$TOLIST
  if [ -f $TO ]; then
    TOLIST=`cat $TO | tr '\n' ' '`
  elif [ -f /home/sh13256/To ]; then
    TOLIST=`cat /home/sh13256/To | tr '\n' ' '`
  fi

  echo "---------------- Send Mail Start ------------------"

  mailx -b $MY_MAIL -t <<EOF
To: $TOLIST
Subject: $1
Mime-Version: 1.0;
Content-Type: text/html; charset="ISO-8859-1";
Content-Transfer-Encoding: 7bit;
<html><body><pre style='font-size:12px; color:003366'>
`cat $2`
</pre></body></html>
EOF

  echo "  Subject : $1"
  echo "   Attach : $2"
  echo "  Sent to : ${TOLIST}"
  echo "---------------- Send Mail Finish ------------------"

#  mailx -s $1 -b shangshang.hu@citi.com "$TOLIST" < $2

#  for to in $TOLIST
#  do
#    mailx -s $1 ${to}< $2
#    echo "         - Mail sent to ${to}"
#  done
}

updateCode(){
#  set -x

  echo
  echo "========== Updating Code from CVS STARTED: `date` =========="
  echo "========== Updating Code from CVS STARTED: `date` ==========" >> $1
  rm -f ./checkout
  cp /home/sh13256/checkout.sh checkout
  chmod +x ./checkout

  if [ $1 = $LOGLWL ]; then
  if [ -d $xROOT/zTRSBackEnd ]; then
      echo "         - Source code found, start update. (zTRSBackEnd) "
      ./checkout updateLWL $1
  else
      echo "         - No source code found, please do checkout first. "
      exit
    fi
  else
#    if [ $1 = $LOGBACK ] or [ $1 = $LOGFRONT ]; then
    if [ -d $xROOT/LoansQuickTicket/LQT ]; then
      echo "         - Source code found, start update. (LoansQuickTicket/LQT) "
      ./checkout updateLQT $1
    else
      echo "         - No source code found, please do checkout first. "
      exit
    fi
  fi

  rm -f ./checkout
}

lazyPrepare(){
#  set -x

  rm $LOGCVS
  cat $1 | grep "^[UPARMC]" | sed '/LQT\/libBack\/CBIdl\/idl\/CBTicket\.idl/d' >> $LOGCVS
  COUNT=`wc -l $LOGCVS | sed 's/ \/.*$//' | sed 's/ //g'`
  echo "" >> $LOGCVS
  echo "$COUNT file(s) updated" >> $LOGCVS

  echo "         - $COUNT file(s) updated"

  BRANCH='Trunk'

  if [ $LQT_BRANCH ]; then
    BRANCH=$LQT_BRANCH
  fi
  if [ $1 = $LOGLWL ]; then
  if [ $LWL_BRANCH ]; then
      BRANCH=$LWL_BRANCH
    fi
  fi

  if [ $# -gt 1 ]; then
    if [ $COUNT -le $2 ]; then
      echo "         - Required changes for compile: [$2] - Skip !"
      echo "Not Enough Changes. [$2] - Skip Compile" >> $LOGCVS
      if [ $COUNT -gt 0 ]; then
        sendMail "CVS_${BRANCH}_${xROOT}" $LOGCVS
      fi
      exit
    fi
  fi

  if [ $COUNT -gt 0 ]; then
    sendMail "CVS_${BRANCH}_${xROOT}" $LOGCVS
  fi

  echo
  echo "========== Prepare Code STARTED: `date` =========="
  rm -f ./checkout
  cp /home/sh13256/checkout.sh checkout

  chmod +x ./checkout

  if [ $1 = $LOGLWL ]; then
    if [ -d $xROOT/zTRSBackEnd ]; then
      echo "         - Source code found, start prepare. (zTRSBackEnd) "
      ./checkout prepareLWL $1
    else
      echo "         - No source code found, please do checkout first. "
      exit
    fi
  else
#    if [ $1 = $LOGFRONT ] or [ $1 = $LOGBACK ]; then
    if [ -d $xROOT/LoansQuickTicket/LQT ]; then
      echo "         - Source code found, start prepare. (LoansQuickTicket/LQT) "
      ./checkout prepareLQT $1
    else
      echo "         - No source code found, please do checkout first. "
      exit
    fi
  fi

  rm -f ./checkout

}

doCompile(){
#  #set -x

  echo
  echo "========== Compile STARTED: `date` Logging to $1 =========="
  echo
  echo "           Please wait ....... "
  echo
  echo "========== Compile STARTED: `date` Logging to $1 ==========" >> $1

  if [ $1 = $LOGFRONT ]; then
    cd $xROOT/LoansQuickTicket/compile
    cp /home/sh13256/build.sh build
    chmod +x ./build
    ./build build_front $1
    rm -f ./build
  elif [ $1 = $LOGBACK ]; then
    cd $xROOT/LoansQuickTicket/compile
    cp /home/sh13256/build.sh build
    chmod +x ./build
    ./build build_back $1
    rm -f ./build
  elif [ $1 = $LOGLWL ]; then
    cp /home/sh13256/build.sh build
    chmod +x ./build
    ./build build_loanWL $1 "${xROOT}/$LWL_COMPILE/"
    rm -f ./build
  else
    echo Unknown Log file for do compile: $1
  fi

  echo "========== Compile ENDED: `date` Logged to $1 =========="
  echo "========== Compile ENDED: `date` Logged to $1 ==========" >> $1
}


achive(){

  currdate=`date '+%m%d%H%M%S'`
  cd $xROOT

  archivePath=$xROOT/archive

  find $archivePath -mtime +10 -exec rm -rf {} \;

  if [ ! -d $archivePath ]; then
    mkdir $archivePath
  fi

  msg=".        - Archive failed"

  if [ $1 = $LOGFRONT ]; then
    cp $xROOT/LoansQuickTicket/compile/front/LQTFront.dstream $archivePath/LQTFront.dstream.$currdate
    if [ -f $archivePath/LQTFront.dstream.$currdate ]; then
    msg=".        - Archived to $archivePath/LQTFront.dstream.$currdate"
    fi
  elif [ $1 = $LOGBACK ]; then
    cp $xROOT/LoansQuickTicket/compile/back/LoansQT.dstream $archivePath/LoansQT.dstream.$currdate
    if [ -f $archivePath/LoansQT.dstream.$currdate ]; then
    msg=".        - Archived to $archivePath/LoansQT.dstream.$currdate"
    fi
  elif [ $1 = $LOGLWL ]; then
    cp $xROOT/$LWL_COMPILE/LoanWL.dstream $archivePath/LoanWL.dstream.$currdate
    if [ -f $archivePath/LoanWL.dstream.$currdate ]; then
    msg=".        - Archived to $archivePath/LoanWL.dstream.$currdate"
    fi
  fi

  chmod 777 $archivePath/*

  echo $msg
  echo $msg  >> $1

}

sendToHermes(){

  cp /home/sh13256/build.sh build
  chmod +x ./build
  if [ $# -lt 2 ]; then
  ./build hermes
    rm ./build
    exit
  fi

  if [ $1 = $LOGFRONT ]; then
    ./build hermes $2 lqtfront $3
  elif [ $1 = $LOGBACK ]; then
    ./build hermes $2 lqtback $3
  elif [ $1 = $LOGLWL ]; then
    ./build hermes $2 loanwl $3
  elif [ $1 = $LOG_DB ]; then
    ./build hermes $2 lqtdb $3
  fi

  rm ./build

}

doPrepareProcess(){
    rm -f $1
    updateCode $1
    lazyPrepare $1 $2
}

doPostPreparePorcess(){
    doCompile $1
    achive $1

    BRANCH='Trunk'
    RESULT='FAILED'
    PROJ_NAME=''

    if [ $1 = $LOGFRONT ]; then
      if [ ${LQT_BRANCH} ]; then
        BRANCH=${LQT_BRANCH}
      fi
      DSTREAM=$xROOT/LoansQuickTicket/compile/front/LQTFront.dstream
      if [ -f $DSTREAM ] and [ $DSTREAM -nt $1 ]; then
      RESULT='SUCCESS'
      fi
      PROJ_NAME='LQTFront'
    elif [ $1 = $LOGBACK ]; then
      if [ ${LQT_BRANCH} ]; then
        BRANCH=${LQT_BRANCH}
      fi
      DSTREAM=$xROOT/LoansQuickTicket/compile/back/LoansQT.dstream
      if [ -f $DSTREAM ] and [ $DSTREAM -nt $1 ]; then
      RESULT='SUCCESS'
      fi
      PROJ_NAME='LoansQT'
    elif [ $1 = $LOGLWL ]; then
      if [ ${LWL_BRANCH} ]; then
        BRANCH=${LWL_BRANCH}
      fi
      DSTREAM=$xROOT/$LWL_COMPILE/LoanWL.dstream
      if [ -f $DSTREAM ] and [ $DSTREAM -nt $1 ]; then
      RESULT='SUCCESS'
      fi
      PROJ_NAME='LoanWL'
    fi

    sendMail "${RESULT}_${PROJ_NAME}_${BRANCH}_${xROOT}" $1

}


#====================== LQT Update - Compile ======================
if [ $CMD = $CMD_BACK ]; then

  if [ -d $xROOT/LoansQuickTicket/LQT ]; then
    doPrepareProcess $LOGBACK $2
    doPostPreparePorcess $LOGBACK
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

elif [ $CMD = $CMD_FRONT ]; then

  if [ -d $xROOT/LoansQuickTicket/LQT ]; then
    doPrepareProcess $LOGFRONT $2
    doPostPreparePorcess $LOGFRONT
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

#====================== LQT Compile Only ======================
elif [ $CMD = ${CMD_BACK}C ]; then

  if [ -d $xROOT/LoansQuickTicket/LQT ]; then
    rm -f $LOGBACK
    doPostPreparePorcess $LOGBACK
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

elif [ $CMD = ${CMD_FRONT}C ]; then

  if [ -d $xROOT/LoansQuickTicket/LQT ]; then
    rm -f $LOGFRONT
    doPostPreparePorcess $LOGFRONT
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

#====================== LQT Update - Compile Together ======================
elif [ $CMD = ${CMD_LQT} ]; then

  rm -f ${LOGFRONT}
  updateCode ${LOGFRONT}
  lazyPrepare ${LOGFRONT} $2
  doPostPreparePorcess $LOGFRONT &
  rm -f $LOGBACK
  doPostPreparePorcess $LOGBACK

#====================== LQT Hermes ======================
elif [ $CMD = ${CMD_BACK}H ]; then

  if [ $# -lt 2 ]; then
    Usage
  fi

  if [ -d $xROOT/LoansQuickTicket/LQT ]; then
    doPrepareProcess $LOGBACK
    sendToHermes $LOGBACK $2 $3
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

elif [ $CMD = ${CMD_FRONT}H ]; then

  if [ $# -lt 2 ]; then
    Usage
  fi

  if [ -d $xROOT/LoansQuickTicket/LQT ]; then
    doPrepareProcess $LOGFRONT
    sendToHermes $LOGFRONT $2 $3
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

#====================== LWL Update - Compile Together ======================
elif [ $CMD = $CMD_LWL ]; then

  if [ -d $xROOT/zTRSBackEnd ]; then
    doPrepareProcess $LOGLWL $2
    doPostPreparePorcess $LOGLWL
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/zTRSBackEnd"
  fi

#====================== LWL Hermes ======================
elif [ $CMD = ${CMD_LWL}H ]; then

  if [ $# -lt 2 ]; then
    Usage
  fi

  if [ -d $xROOT/zTRSBackEnd ]; then
    doPrepareProcess $LOGLWL
    sendToHermes $LOGLWL $2 $3
  else
    echo
    echo "Build folder not fund."
    echo "Required $xROOT/LoansQuickTicket/LQT"
  fi

#====================== LQT DB Hermes ======================
elif [ $CMD = ${CMD_LQTDBH} ]; then

  if [ $# -lt 2 ]; then
    Usage
  fi

  echo "  -- checking out --  "
  cp /home/sh13256/checkout.sh checkout
  chmod +x ./checkout
  ./checkout DB >> $LOG_DB 2>&1
  rm ./checkout

  echo "  -- sending to Hermes --  "
  sendToHermes $LOG_DB $2 $3 >> $LOG_DB 2>&1

  sendMail "LoansQTDB_Send_To_Hermes_${xROOT}" $LOG_DB

else

  Usage
fi

分享到:
评论

相关推荐

    spring boot/spring cloud项目启动脚本,默认名称:start.sh

    linux服务器,springboot,spring cloud、spring ...sh start.sh start sh start.sh stop sh start.sh restart sh start.sh status 或者: ./start.sh start ./start.sh stop ./start.sh restart ./start.sh status

    魅蓝note3 global.sh beta.sh

    命令输入工具(终端模拟器,可在自带的应用商店中搜索下载 一个551k大小的安装包),公开版官方包(官网中下载),脚本文件global.sh 手机必须彻底root(自带root开启后下载Kingroot获取完整权限 这个root不用担心...

    ubuntu如何运行.sh文件,.sh文件运行提示脚本异常

    ubuntu执行.sh文件,1 .sh文件是Ubuntu下可执行文件,首先需要确定它的权限是否是可执行的,2、 用vim打开sh文件,3、查看文件格式:4. 修改文件格式: 5. 保存退出: 6. 执行:./filename 注意:不可以用sh ...

    iterm2-send-zmodem.sh and iterm2-recv-zmodem.sh

    本文将详细讲解如何利用`iTerm2`配合`ZModem`协议的脚本`iterm2-send-zmodem.sh`和`iterm2-recv-zmodem.sh`来解决在远程服务器上进行文件传输时遇到的问题。 首先,让我们了解`ZModem`协议。`ZModem`是一种双向、...

    acme.sh 实现了 acme 协议,可以从 Let's Encrypt 生成免费的证书,内含完整源代码

    acme.sh 实现了 acme 协议,可以从 Let's Encrypt 生成免费的证书,内含完整源代码 生成证书 acme.sh 实现了 acme 协议支持的所有验证协议,有两种方式验证: http 验证 和 dns 验证。 1. http 方式 http 方式需要...

    getinfo.sh

    chmod +x getinfo.sh ./getinfo.sh 注:此脚本可以以一般用户收集到信息(除fdisk只能以root运行) 1. 基本信息 - 适合所有linux问题 - getinfo.sh basic 2.硬盘/文件系统问题(基本,全盘信息) -需要用户成为root并...

    Ubuntu下运行.sh文件

    在Ubuntu操作系统中,`.sh` 文件通常是一种shell脚本,用于执行一系列的命令或自动化任务。这类文件在Linux和类Unix系统中广泛使用。要成功地在Ubuntu上运行`.sh` 文件,你需要遵循一系列步骤,确保文件具有正确的...

    startup.sh linux 启动jar包命令

    startup.sh linux 启动jar包命令startup.sh linux 启动jar包命令startup.sh linux 启动jar包命令startup.sh linux 启动jar包命令startup.sh linux 启动jar包命令

    关于Root.sh

    Oracle数据库在Linux环境下安装完成后,需要运行root.sh脚本来完成安装过程的最后一步,这个脚本主要负责执行一些需要root权限的操作,确保Oracle数据库的环境设置和权限配置正确无误。本文将详细介绍root.sh脚本的...

    tinyos.sh文件

    tinyos.sh文件,在linux环境下生成,cygwin环境下可用,tinyos.sh文件总出问题的可以下载,将绝对路径修改成自己的

    get-docker.sh docker安装脚本

    get-docker.sh docker安装脚本,可直接执行 sh get-docker.sh --mirror Aliyun 安装

    Solaris pstack.sh

    The following scripts are located in obisolaris.tar.gz (2013-07-12) obimon (0.1) - monitor memory and connection...unpackDbx.sh.sh (0.2) - extracts dbx from Studio 12.3 download. See instructions below.

    iOS重签名 Resign.sh

    将Resign.sh与你的mobileprovision文件和ipa文件放在同一个文件夹内。 ### 2.打开命令行,复制 chmod +x ,再敲一个空格,再将Resign.sh拖入命令行里面,回车。 ### 3.继续将Resign.sh拖入命令行内,回车,将会出现...

    startServer.sh

    startServer.sh

    qnap-acme.sh

    威联通QNAP自动续签更新SSL证书脚本(配合acme.sh使用),支持Let's Encrypt免费证书,支持域名泛解析证书,如:*.xx.com。

    linux通用版本jar启动脚本傻瓜式启动 run.sh

    linux通用版本jar启动脚本傻瓜式启动 sh run.sh start 启动 sh run.sh stop 停止 nohup java -jar XXX.jar & nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行

    wait-for-it.sh脚本

    wait-for-it.sh是一个Shell脚本,主要用于在Docker容器启动时等待某个服务(如数据库、消息队列等)变得可用。在某些分布式系统中,各个服务的启动顺序和依赖关系很重要,wait-for-it.sh可以帮助解决这个问题。

    jdk_install.sh

    liunx 一键安装jdk脚本,实现jdk 一键安装 (bash jdk_install.sh)

    ldd.sh app.sh

    "ldd.sh" 和 "app.sh" 是两个在Linux环境中常见的脚本文件,它们在Qt程序打包发布过程中扮演着重要角色。现在让我们深入探讨这两个脚本文件的功能以及它们如何与“导出库”这个概念关联。 首先,`ldd.sh` 是一个...

    get-docker.sh

    此docker安装脚本为官方提供的,可以从网上下载,此处直接上传。安装docker客户端,get-docker.sh

Global site tag (gtag.js) - Google Analytics