删除ClearCase视图脚本

4
这是一个已删除问题的转载(应请求)。
什么是最好的ClearCase视图删除脚本?我在http://www.cmcrossroads.com/forums?func=view&id=44045&catid=31上找到了以下由Yossi Sidi编写的内容。
此脚本缺少的两个事项是删除CCRC视图中session.dat文件中的条目以及清理服务器视图存储和缓存文件目录。
手动步骤可以在此处找到: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的$'后,stackoverflow的颜色编码会出现问题。


(译注:$'是Perl中一个特殊变量,表示匹配操作中匹配成功的字符串之后的部分。在代码中使用这个变量可能会导致问题)
1个回答

3

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

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

cleartool lsview -host myHostname -quick | xargs ccperl nuke_view.pl
< p > -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技术文档中描述了删除CCWeb Views所需的额外步骤:
注意:对于ClearCase 7.1.1.1或7.1.1.2,由于APAR PM03334,session.dat文件不再从ClearCase 7.1.1.1生成:不再需要清理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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接