删除ClearCase视图脚本

时间:2010-11-30 20:32:46

标签: perl clearcase

(这是已删除问题的转贴)(根据要求)

什么是最好的ClearCase View删除脚本?我在下面的Yossi Sidi撰写的http://www.cmcrossroads.com/forums?func=view&id=44045&catid=31上找到了以下内容

此脚本遗漏的两件事是删除了session.dat文件中的条目,用于CCRC视图以及清理服务器视图存储和缓存文件目录。

可以在此处找到手动步骤:http://www-01.ibm.com/support/docview.wss?uid=swg21172246

rmview.pl
==============
#
# rmview.pl
#
# This script is used to delete a view..
# ---------------------------------------------------
#   Fetching the UUID of the view :
# Cleartool describe -long vob:vob_name (lists all views)
#    -or-
# cleartool lsview -long <View_name>
# ------------------------------------------------------------------------
# Remove sequence:-
#   Cleartool rmview -force -uuid <uuid> (from a VIEW contents directory)
#   Cleartool unreg -view -uuid <uuid>
#   Cleartool rmtag -view VIEW_NAME
#
# Arguments:
# view tag name :
#
# ASSUMED: You must be in a VOB with a view set when this tool
# is used.
#
# Author: Yossi Sidi
# email: yossis@corrigent.com
# URL: [url=http://www.corrigent.com" target="_blank]http://www.corrigent.com[/url]
# Date: Sep. 14, 2003
############################################################
# History: 14/10/03 : Created for Corrigent
############################################################


########################
######## MAIN ########----------------------------------------------------------------
########################


$DIV1="*************************************************************n";


$USAGE=""USAGE ccperl.exe $0 view tag name \n EXAMPLE: ccperl.exe $0 ""My_view"" "";

if ($#ARGV == 0)
{
$view_name = $ARGV[0];
}
else
{
`clearprompt yes_no -mask abort -default abort -pre -prompt $USAGE`;
exit 1;
}
select STDOUT;
$| = 1; # Do not buffer the STDOUT file so ccperl prog.pl >out.txt
# will have the correct sequence of report lines
printf ($DIV1);
printf ("View Propertiesn");
printf (" View Tag: $view_namen");
printf ($DIV1);
printf ("n");

$COMMAND = "cleartool lsview -l $view_name";
@dl = `"$COMMAND"`;
$view_uuid = "";
foreach $dl (@dl) {
chomp ($dl);
printf ("$dln");
if ( $dl =~ /^View uuid: / ) {
$view_uuid = $'; #' reset syntax highlighter
}
}
if ( $#dl > 0 ) {
#   Cleartool rmview -force -all -uuid <uuid> (from a VIEW contents directory)
#   Cleartool unreg -view -uuid <uuid>
#   Cleartool rmtag -view VIEW_NAME
$rmview = "cleartool rmview -force -all -uuid $view_uuid";
$unreg = "cleartool unreg -view -uuid $view_uuid";
$rmtag = "cleartool rmtag -view $view_name";
printf ($DIV1);
printf ("Removing commandsn");
printf ($DIV1);
printf ("n");
printf ("n$rmview n");
@dl = `"$rmview"`;
printf ("n$unreg n");
@dl = `"$unreg"`;
printf ("n$rmtag n");
@dl = `"$rmtag"`;
}
exit 0;

(嗯......有趣的是,在Perl的$'....迷你bug之后,stackoverflow颜色编码变得疯狂了)

1 个答案:

答案 0 :(得分:2)

我提到了一个有点冗长的脚本,但它不会删除任何本地存储,也不会清理CCRC session.dat:

nuke_view.pl:您可以使用它删除工作站中的所有视图(可能不再可用)

cleartool lsview -host myHostname -quick | xargs ccperl nuke_view.pl

-quick选项对于快速获取给定工作站的视图列表非常重要。

## This script should be used to cleanup a view when 'ct rmview' will not
## work (such as when the viewstore directory has been deleted.
##
## Note: The view storage directory will have to manually deleted if it still exists.

use strict;

#sub NukeView();
#sub DoIt();

foreach(@ARGV) {
        NukeView($_);
}


##############################################################
sub NukeView {

        my $view2del = $_[0];

        print "Processing $view2del...\n";

        my @lines = `cleartool lsview -l $view2del`;

        my $tag;
        my $uuid;
        foreach(@lines) {
                chomp;
                $tag = $1 if /^Tag: (\S+)/;
                $uuid = $1 if /^View uuid: (\S+)/;

                s/^/\t/;

                print "$_\n";
        }

        if ( $tag eq '' or $uuid eq '' ) {
                print "Error! $view2del: unable to get tag and/or uuid\n";
                return 0;
        }

        my $err_count = 0;

        print "\tremoving tag...\n";
        my $cmd = "cleartool rmtag -view $tag";
        $err_count += 1 if DoIt($cmd);

        print "\tunregistering view storage...\n";
        $cmd = "cleartool unreg -view -uuid $uuid";
        $err_count += 1 if DoIt($cmd);

        print "\tremoving view references...\n";
        $cmd = "cleartool rmview -force -avobs -uuid $uuid";
        $err_count += 1 if DoIt($cmd);

        if ( $err_count == 0 ) {
                print "Success! removed view $view2del\n";
        }
        else {
                print "Error! errors occured while removing $view2del\n";
        }
}

#############################################
sub DoIt {
        my $ret = system($_[0]) / 256;
        print "Error! cmd failed: $_[0]\n" if $ret != 0;
        return $ret;
}

IBM technote

中介绍了删除CCWeb视图所需的额外步骤

注意:对于ClearCase 7.1.1.1或7.1.1.2,由于APAR PM03334,不再从ClearCase 7.1.1.1生成session.dat文件:不再需要清除session.dat。

删除存储在CCWeb服务器上的视图存储和缓存文件。

  

默认情况下,view.stg(CCRC / CCWeb视图存储),view.dat和VOB的缓存文件存储在以下位置:

     
      
  • Windows®C:\Program Files\Rational\ClearCase\var\ccweb\<user>\<view_tag>
  •   
  • UNIX®/Linux®/var/adm/rational/clearcase/ccweb/<user>/<view_tag>
  •   
     

删除位于上方位置的<view_tag>文件夹。这将删除视图的存储文件view.dat和VOB的缓存文件,并允许用户使用相同/原始视图的名称创建新视图。

     

注意:如果CCRC客户端上仍存在该视图,则可能还需要手动删除视图工作区。这可以通过导航到客户端系统上的已定义工作区(默认为C:\Documents and Settings\<user-name>\view_tag)并删除视图工作区来完成。   此会话工作空间的路径列在会话.dat文件中。条目如下所示:-workroot "c:/web_dev2"。在用户未使用默认位置的情况下,这可能会有用。

     

CCRC视图根也会缓存在用户配置文件中客户端上的文件中   检查以下文件,并从该列表中删除已删除的视图。

C:\Documents and Settings\<user-name>\.ccase_wvreg