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


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

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

使用方法是:

./add_source.sh dir

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



#!/bin/bash

#list result analyzer added but not check in java file
TMPFILE="/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 ]
then
	echo "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."
	exit
fi

function checkexitcode()
{
	if [ "$?" -ne "0" ]; then
	echo "##############################"
	echo "Sorry, command executed error."
	echo "##############################"
	exit 1
	fi
}

cleantmpfile
#backup current path
CURRENTPATH=$(pwd)

cd $1
WORKSAPCE=$(pwd)

echo -n "Your parameter is: "
echo $WORKSAPCE

#check out current path's parent
cd ..
$CTCO .

#find all dirctories/files in user input
find $WORKSAPCE -type d -print > $TMPFILE
find $WORKSAPCE -type f -print > $TMPFILE2

#add all dir to clearcase
echo "mkelem all directories"
while read LINE
do
	echo $LINE
	$CTMKELEM $LINE
	checkexitcode
done < $TMPFILE

#make sure file under directory is add to clearcase
echo "check in all files"
path=""
while read FILE
do
	echo $FILE
	#path=$(dirname $FILE)
	#cd $path
	$CTMKELEM $FILE
	checkexitcode
	#check in file
	$CTCI $FILE
	checkexitcode
done < $TMPFILE2

#check all dir
echo "check out all directories"
while read LINE
do
	$CTCI $LINE
	checkexitcode
done < $TMPFILE

$CTCI .

#restore path
cd $CURRENTPATH





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值