Removed /usr/local from CDPATH
[clearscm.git] / cc / findvob
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         findvob,v
5 # Revision:     1.1.1.1
6 # Description:  This script will locate a vob by searching through the various
7 #               regions.
8 # Author:       Andrew@DeFaria.com
9 # Created:      Mon May  3 09:06:55 PDT 2004
10 # Modified:     2007/05/17 07:45:48
11 # Language:     Perl
12 #
13 # (c) Copyright 2004, Andrew@DeFaria.com, all rights reserved.
14 #
15 ################################################################################
16 use strict;
17 use warnings;
18
19 use FindBin;
20 use lib "$FindBin::Bin/../lib";
21
22 use Display;
23
24 sub Usage {
25   display "Usage $FindBin::Script: [ <vob tag>... | -u ]";
26   display "\nWhere:";
27   display "\t<vob tag>\tName of the vob to find (can be partial name)";
28
29   exit 1;
30 } # Usage
31
32 sub SearchRegions {
33   my $vob = shift;
34
35   my $nbr_vobs = 0;
36
37   # Get a list of regions
38   my @regions   = `cleartool lsregion`;
39   my $region;
40
41   # Process each region
42   foreach $region (@regions) {
43     chomp $region;
44     chop  $region if $region =~ /\r/; # Remove carriage returns
45
46     # Get a list of vovs in the region
47     my @lines = `cleartool lsvob -region $region`;
48
49     # Parse the lines extracting vob tag and storage area
50     foreach (@lines) {
51       if (/[\* ]\s*(\S*)\s*\S*/) {
52         my $name = $1;
53
54         if ($name =~ /$vob/i) {
55           display "\t$name ($region)";
56           $nbr_vobs++;
57           next;
58         } # if
59       } # if
60     } # foreach @lines
61   } # foreach @regions
62
63   return $nbr_vobs;
64 } # SearchRegions
65
66 # Get parms
67 if (defined $ARGV [0] and $ARGV [0] =~ /^-u/) {
68   Usage;
69 } # if
70
71 foreach (@ARGV) {
72   verbose "Searching for vobs containing \"$_\"\n";
73   my $nbr_vobs = SearchRegions $_;
74
75   if ($nbr_vobs eq 0) {
76     display "No vobs found"
77   } elsif ($nbr_vobs eq 1) {
78     display "1 vob found";
79   } else {
80     display "$nbr_vobs vobs found";
81   } # if
82
83   verbose " matching \"$_\"\n";
84 } # foreach
85
86 # All done...
87 exit 0;
88