Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
315 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
315 dpurdie 3
#
4
# Module name   : jats_vars.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Program to show the environment variables passed into
10
#                 a program invoked by JATS
11
#
12
# Usage:        jats vars
13
#
14
#......................................................................#
15
 
16
require 5.008_002;
17
use strict;
18
use warnings;
19
 
20
use Pod::Usage;
21
use Getopt::Long;
22
use Cwd;
23
 
24
use JatsError qw(:name=JatsVars);
25
 
26
#
27
#   Local variables
28
#
29
my $VERSION = "1.0.0";                      # Update this
30
my $opt_verbose = $ENV{'GBE_VERBOSE'} || 0;
31
my $opt_help = 0;
5109 dpurdie 32
my $indent = 19;
353 dpurdie 33
my @indents;
315 dpurdie 34
my $GBE_UNIX = $ENV{GBE_UNIX} || 0;
35
my $CWD;
36
my $PSPLIT;
37
 
38
#-------------------------------------------------------------------------------
39
# Function        : Main Entry
40
#
41
# Description     :
42
#
43
# Inputs          :
44
#
45
# Returns         :
46
#
47
my $result = GetOptions (
48
                "help:+"        => \$opt_help,          # flag, multiple use allowed
49
                "manual:3"      => \$opt_help,          # flag
50
                "verbose:+"     => \$opt_verbose,       # flag
51
                );
52
 
53
#
54
#   Process help and manual options
55
#
56
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
57
pod2usage(-verbose => 1)  if ($opt_help == 2 );
58
pod2usage(-verbose => 2)  if ($opt_help > 2);
59
 
60
#
61
#   Init some useful variables
62
#
63
$CWD = getcwd();
64
$PSPLIT = $GBE_UNIX ? ':' : ';';                               # Win/Unix path splitter
65
if ( $opt_verbose > 1 ) {
66
    dump_full();
67
} else {
68
    dump_vars();
69
}
70
 
71
#-------------------------------------------------------------------------------
72
# Function        : display functions
73
#
74
# Description     : 
75
#
76
# Inputs          : 
77
#
78
# Returns         : 
79
#
80
 
81
#   Display an array separated list, one entry per line, with dir sanity check
82
sub alist
83
{
84
    my ($text, @var) = @_;
85
    my $sep = "=";
86
    for ( @var )
87
    {
88
        my $valid = ( -d $_ || -f $_ ) ? " " : "*";
89
        printf "%-${indent}s%s%s%s\n", $text, $sep, $valid, $_;
90
        $text = "";
91
        $sep = " ";
92
    }
93
}
94
 
95
# Simple print of name and variable
96
sub pvar
97
{
98
    my ($text, $data) = @_;
99
    $data =~ s~\n~\\n~g;
100
    printf "%-${indent}s= %s\n", $text, $data;
101
}
102
 
103
# Print of name and variable of directory with sanity check
104
sub dvar
105
{
106
    my ($text, $data) = @_;
107
    my $valid = ( ! $data || -d $data || -f $data ) ? " " : "*";
108
    printf "%-${indent}s=%s%s\n", $text, $valid, $data;
109
}
110
 
111
# Display a variable extracted from the environment
112
sub penv
113
{
114
    my ($var) = @_;
6511 dpurdie 115
    pvar $var, defined ($ENV{$var}) ? $ENV{$var} : '';
315 dpurdie 116
}
117
 
118
# Display a variable extracted from the environment with dir sanity check
119
sub denv
120
{
121
    my ($var) = @_;
6511 dpurdie 122
    dvar $var, defined ($ENV{$var}) ? $ENV{$var} : '';
315 dpurdie 123
}
124
 
125
#   Display a ';' or ':' separated list, one entry per line based on EnvVar
126
sub lenv
127
{
128
    my ($var) = @_;
129
    alist( $var, split $PSPLIT, $ENV{$var} || " " );
130
}
131
 
132
 
133
#-------------------------------------------------------------------------------
134
# Function        : dump_full
135
#
136
# Description     : Display ALL EnvVars
137
#
138
# Inputs          : 
139
#
140
# Returns         : 
141
#
142
sub dump_full
143
{
144
    Message ("Complete environment dump");
145
 
146
    $indent = 33;
147
    foreach my $var ( sort keys(%ENV) )
148
    {
149
        penv ($var);
150
    }
151
    return;
152
}
153
 
154
#-------------------------------------------------------------------------------
155
# Function        : dump_vars
156
#
157
# Description     : Dump selected environment varaibles
158
#
159
# Inputs          : 
160
#
161
# Returns         : 
162
#
163
sub dump_vars
164
{
165
    #
166
    #   Complete environment dump
167
    #
168
    if ( $opt_verbose > 1 )
169
    {
170
    }
171
 
172
    #
173
    #   Partial dump
174
    #   Display selected parts
175
    #
176
    penv    "GBE_VERSION";
177
    penv    "GBE_SCRIPT";
178
    penv    "GBE_DEBUG";
179
    penv    "GBE_VERBOSE";
180
 
181
    if ( $opt_verbose )
182
    {
183
        penv    "GBE_JATS_VERSION";
184
        penv    "GBE_JATS_SANE";
185
    }
186
    penv    "GBE_MACHTYPE";
187
    penv    "GBE_HOSTMACH";
188
    penv    "GBE_UNIX";
189
    penv    "GBE_DRV";
190
    denv    "GBE_PERL";
191
    denv    "GBE_CORE";
192
    denv    "GBE_BIN";
193
    denv    "GBE_TOOLS";
194
    denv    "GBE_CONFIG";
195
    penv    "GBE_CACHE_JATS";
196
    lenv    "GBE_SANDBOX";
197
    lenv    "GBE_DPKG_STORE";
198
    lenv    "GBE_DPKG";
4688 dpurdie 199
    lenv    "GBE_DPKG_REPLICA";
315 dpurdie 200
    lenv    "GBE_DPKG_CACHE";
5109 dpurdie 201
    penv    "GBE_DPKG_CACHE_CTL";
315 dpurdie 202
    lenv    "GBE_DPKG_LOCAL";
6276 dpurdie 203
    lenv    "GBE_DPKG_ESCROW";
315 dpurdie 204
    lenv    "GBE_DPKG_SBOX";
205
    lenv    "GBE_DPLY";
206
    penv    "GBE_PLATFORM";
207
    penv    "GBE_BUILDFILTER";
208
    penv    "GBE_ABT";
7447 dpurdie 209
    penv    "GBE_OPTS";
6511 dpurdie 210
    penv    "GBE_MAXMAKE";
315 dpurdie 211
    denv    "GBE_VIEWBASE";
361 dpurdie 212
    penv    "GBE_VCS";
315 dpurdie 213
    penv    "GBE_HOSTNAME";
214
    dvar    "CWD", $CWD;
215
 
216
    penv    "COMSPEC";
217
    penv    "SHELL";
218
    penv    "USER";
219
    lenv    "PATH";
220
 
221
    #
222
    #   Display variables used by various "known" toolsets
223
    #   These do cause grief sometime, so only do it for verbose
224
    #
225
    if ( $opt_verbose )
226
    {
227
 
228
        print "\nPerl Environment\n";
229
        pvar  "VERSION"         ,$];
230
        penv  "PERL5SHELL";
231
        penv  "PERL5OPT";
232
        lenv  "PERL5LIB";
233
        alist "INC"             ,@INC;
234
 
235
        print "\nJava Environment\n";
236
        foreach my $var ( sort grep ( {/^JAVA_HOME/ } keys %ENV) )
237
        {
238
            denv  $var;
239
        }
240
        denv  "ANT_HOME";
241
        denv  "JATS_HOME";
242
        lenv  "CLASSPATH";
243
    }
244
 
245
    if ( $opt_verbose || $ENV{GBE_ABT} )
246
    {
247
        print "\nRelease Manager Environment\n";
248
        penv    "GBE_RM_LOCATION";
249
        penv    "GBE_RM_USERNAME";
250
        penv    "GBE_RM_PASSWORD";
251
        penv    "GBE_RM_URL";
252
        penv    "GBE_DM_LOCATION";
253
        penv    "GBE_DM_USERNAME";
254
        penv    "GBE_DM_PASSWORD";
255
        penv    "GBE_DM_URL";
4612 dpurdie 256
        print "\nJira Environment\n";
257
        penv    "GBE_JIRA_URL";
258
        penv    "GBE_JIRA_USERNAME";
259
        penv    "GBE_JIRA_PASSWORD";
4466 dpurdie 260
        print "\nClearQuest Environment\n";
261
        penv    "GBE_CQ_LOCATION";
262
        penv    "GBE_CQ_USERNAME";
263
        penv    "GBE_CQ_PASSWORD";
315 dpurdie 264
    }
265
 
353 dpurdie 266
    if ( $opt_verbose || $ENV{GBE_SVN_USERNAME} || $ENV{GBE_SVN_PATH} )
315 dpurdie 267
    {
341 dpurdie 268
        print "\nSubVersion\n";
315 dpurdie 269
        denv    "GBE_SVN_PATH";
270
        penv    "GBE_SVN_USERNAME";
271
        penv    "GBE_SVN_PASSWORD";
353 dpurdie 272
        print "\nSubVersion Repository Paths\n";
273
        push @indents, $indent;
274
        $indent = 24;
275
        foreach ( sort keys %ENV )
276
        {
277
            penv    $_ if ( m ~^GBE_SVN_URL~ );
278
        }
279
        $indent = pop @indents;
315 dpurdie 280
    }
7547 dpurdie 281
 
282
    if ( $opt_verbose || $ENV{GBE_GIT_PATH} )
283
    {
284
        print "\nGIT Binary\n";
285
        denv    "GBE_GIT_PATH";
286
        print "\nGIT Repository Paths\n";
287
        push @indents, $indent;
288
        $indent = 24;
289
        foreach ( sort keys %ENV )
290
        {
291
            penv    $_ if ( m ~^GBE_GIT_URL~ );
292
        }
293
        $indent = pop @indents;
294
    }
315 dpurdie 295
 
296
    if ( $opt_verbose && ! $GBE_UNIX)
297
    {
298
        print "\nWindows Environment\n";
299
        denv  "TEMP";
300
        denv  "TMP";
301
 
302
        print "\nMicrosoft Studio Variables\n";
303
        denv  "PROGRAMFILES";
304
        denv  "WINDIR";
305
        denv  "MSVCDir";
306
 
307
        print "\nMicroTec Compiler Variables\n";
308
        denv "MRI_68K";
309
        denv "MRI_CF";
310
        denv "VISIONCLICK";
311
 
312
        print "\nPCLint Variables\n";
313
        denv "PCLINT";
314
        penv "LINTPACKAGE";
315
    }
316
}
317
 
318
#-------------------------------------------------------------------------------
319
#   Documentation
320
#
321
 
322
=pod
323
 
324
=head1 NAME
325
 
326
vars - Display Jats Related Environment Variables
327
 
328
=head1 SYNOPSIS
329
 
330
  jats vars [options]
331
 
332
 Options:
333
    -help              - brief help message
334
    -help -help        - Detailed help message
335
    -man               - Full documentation
336
    -verbose[=n]       - Verbose operation
337
 
338
=head1 OPTIONS
339
 
340
=over 8
341
 
342
=item B<-help>
343
 
344
Print a brief help message and exits.
345
 
346
=item B<-help -help>
347
 
348
Print a detailed help message with an explanation for each option.
349
 
350
=item B<-man>
351
 
352
Prints the manual page and exits.
353
This is the same as -help=3.
354
 
355
=item B<-man[=n]>
356
 
357
Set the help level directly. Valid values are 0,1,2 and 3.
358
 
359
=item B<-verbose[=n]>
360
 
361
This option will increase the level of verbosity of the command.
362
 
363
The allowed verbosity levels are:
364
 
365
=over 4
366
 
361 dpurdie 367
=item 0
315 dpurdie 368
 
361 dpurdie 369
Basic variable display
315 dpurdie 370
 
361 dpurdie 371
=item 1
315 dpurdie 372
 
361 dpurdie 373
Display additional JATS related information.
374
 
375
=item 2
376
 
377
Display all the Environment variables.
378
 
315 dpurdie 379
=back
380
 
381
=back
382
 
383
=head1 DESCRIPTION
384
 
361 dpurdie 385
This program will display the values of all JATS related L<environment
386
variables|POD::EnvVars>.
315 dpurdie 387
 
388
Many of the variables will be displayed with sanity information. If the
389
variable is a PATH and and the PATH does not exist, then the displayed value
361 dpurdie 390
will be prefixed with a '*'
315 dpurdie 391
 
392
=cut
393