linux下向clearcase中提交多级目录(clearcase add to source recursively)

来源:互联网 发布:淘宝助理无法上传宝贝 编辑:程序博客网 时间:2024/06/07 03:14


现在开始了新的工作,工作中使用到的代码管理工具是clearcase。但是它在提交多级目录时很是麻烦,所以自己写了个脚本。

放在这里,给需要的用户。

使用方法是:

./add_source.sh dir

需要注意的是 需要提交的目录下的东西都是自己新建的,否则会出错直接退出



#!/bin/bash#list result analyzer added but not check in java fileTMPFILE="/tmp/tmp_file"TMPFILE2="/tmp/tmp_file2"CT="/usr/atria/bin/cleartool "CTCO="/usr/atria/bin/cleartool co -nc "CTCI="/usr/atria/bin/cleartool ci -nc "CTMKELEM="/usr/atria/bin/cleartool mkelem -mkpath -nc "WORKSAPCE=""CURRENTPATH=""function cleantmpfile(){rm -rf $TMPFILE $TMPFILE2} if [ $# -ne 1 ]thenecho "usage: ./add_source.sh dir"echo "for example, ./add_source.sh /tmp/ab"echo "/tmp path must be under VOBs, your created directory ab, ab/cd, etc"echo "then this shell will check in all the directory and file to clearcase."exitfifunction checkexitcode(){if [ "$?" -ne "0" ]; thenecho "##############################"echo "Sorry, command executed error."echo "##############################"exit 1fi}cleantmpfile#backup current pathCURRENTPATH=$(pwd)cd $1WORKSAPCE=$(pwd)echo -n "Your parameter is: "echo $WORKSAPCE#check out current path's parentcd ..$CTCO .#find all dirctories/files in user inputfind $WORKSAPCE -type d -print > $TMPFILEfind $WORKSAPCE -type f -print > $TMPFILE2#add all dir to clearcaseecho "mkelem all directories"while read LINEdoecho $LINE$CTMKELEM $LINEcheckexitcodedone < $TMPFILE#make sure file under directory is add to clearcaseecho "check in all files"path=""while read FILEdoecho $FILE#path=$(dirname $FILE)#cd $path$CTMKELEM $FILEcheckexitcode#check in file$CTCI $FILEcheckexitcodedone < $TMPFILE2#check all direcho "check out all directories"while read LINEdo$CTCI $LINEcheckexitcodedone < $TMPFILE$CTCI .#restore pathcd $CURRENTPATH





原创粉丝点击