Subversion Repositories DevTools

Rev

Rev 5709 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : find_vob_root.pl
5
# Module type   : JATS Utility
6
# Compiler(s)   : Perl
7
# Environment(s): JATS
8
#
9
# Description   :
10
#
11
# Usage:
12
#
13
#
14
#......................................................................#
15
 
16
require 5.008_002;
17
use strict;
18
use warnings;
19
 
20
use Pod::Usage;
21
use Getopt::Long;
22
 
23
use JatsError;
24
use JatsSystem;
25
use Cwd;
26
 
27
my @error_list;
28
my $last_result;
29
my @last_results;
30
 
31
 
32
        ClearCmd('describe', '-fmt', '%Ln', 'vob:.');
33
        Error ("Program Terminated") if ( @error_list );
34
        Error ("Cannot determine current VOB base" ) unless ( $last_result );
35
        my $vob_base = quotemeta($last_result);
36
        Message ("VOB Base: $vob_base");
37
 
38
        my $here =  getcwd();
39
        Message ("Current dir: $here");
40
 
41
        my $base_dir = $here;
42
        $here =~ m~^(.*$vob_base)~;
43
        $base_dir = $1;
44
 
45
        Message ("Path of base: $base_dir");
46
        chdir ( $base_dir ) || Error ("Cannot chdir to vob base", $base_dir);
47
        Message ("All is good", getcwd());
48
 
49
#-------------------------------------------------------------------------------
50
# Function        : ClearCmd
51
#
52
# Description     : Execute a ClearCase command and capture the results
53
#                   Errors are held in one array
54
#                   Result are held in another
55
#
56
# Inputs          :
57
#
58
# Returns         :
59
#
60
sub ClearCmd
61
{
62
    my $cmd = QuoteCommand (@_);
63
    Verbose2( "cleartool $cmd" );
64
 
65
        @error_list = ();
66
        @last_results = ();
67
        $last_result = undef;
68
 
69
        open(CMD, "cleartool $cmd  2>&1 |")    || Error( "can't run command: $!" );
70
        while (<CMD>)
71
        {
72
            chomp;
73
            $last_result = $_;
74
            $last_result =~ tr~\\/~/~s;
75
            push @last_results, $last_result;
76
 
77
            Verbose2 ( "cleartool resp:" . $_);
78
            push @error_list, $_ if ( m~Error:~ );
79
        }
80
        close(CMD);
81
 
82
    Verbose2( "Exit Status: $?" );
83
    return $? / 256;
84
}
85