Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
315 dpurdie 1
########################################################################
2
# Copyright (C) 2010 ERG Limited, All rights reserved
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;
32
my $indent = 17;
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) = @_;
115
    pvar $var, $ENV{$var} || '';
116
}
117
 
118
# Display a variable extracted from the environment with dir sanity check
119
sub denv
120
{
121
    my ($var) = @_;
122
    dvar $var, $ENV{$var} || '';
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";
199
    lenv    "GBE_DPKG_CACHE";
200
    lenv    "GBE_DPKG_LOCAL";
201
    lenv    "GBE_DPKG_SBOX";
202
    lenv    "GBE_DPLY";
203
    penv    "GBE_PLATFORM";
204
    penv    "GBE_BUILDFILTER";
205
    penv    "GBE_ABT";
206
    denv    "GBE_VIEWBASE";
361 dpurdie 207
    penv    "GBE_VCS";
315 dpurdie 208
    penv    "GBE_HOSTNAME";
209
    dvar    "CWD", $CWD;
210
 
211
    penv    "COMSPEC";
212
    penv    "SHELL";
213
    penv    "USER";
214
    lenv    "PATH";
215
 
216
    #
217
    #   Display variables used by various "known" toolsets
218
    #   These do cause grief sometime, so only do it for verbose
219
    #
220
    if ( $opt_verbose )
221
    {
222
 
223
        print "\nPerl Environment\n";
224
        pvar  "VERSION"         ,$];
225
        penv  "PERL5SHELL";
226
        penv  "PERL5OPT";
227
        lenv  "PERL5LIB";
228
        alist "INC"             ,@INC;
229
 
230
        print "\nJava Environment\n";
231
        foreach my $var ( sort grep ( {/^JAVA_HOME/ } keys %ENV) )
232
        {
233
            denv  $var;
234
        }
235
        denv  "ANT_HOME";
236
        denv  "JATS_HOME";
237
        lenv  "CLASSPATH";
238
    }
239
 
240
    if ( $opt_verbose || $ENV{GBE_ABT} )
241
    {
242
        print "\nRelease Manager Environment\n";
243
        penv    "GBE_RM_LOCATION";
244
        penv    "GBE_RM_USERNAME";
245
        penv    "GBE_RM_PASSWORD";
246
        penv    "GBE_RM_URL";
247
        penv    "GBE_DM_LOCATION";
248
        penv    "GBE_DM_USERNAME";
249
        penv    "GBE_DM_PASSWORD";
250
        penv    "GBE_DM_URL";
4612 dpurdie 251
        print "\nJira Environment\n";
252
        penv    "GBE_JIRA_URL";
253
        penv    "GBE_JIRA_USERNAME";
254
        penv    "GBE_JIRA_PASSWORD";
4466 dpurdie 255
        print "\nClearQuest Environment\n";
256
        penv    "GBE_CQ_LOCATION";
257
        penv    "GBE_CQ_USERNAME";
258
        penv    "GBE_CQ_PASSWORD";
315 dpurdie 259
    }
260
 
353 dpurdie 261
    if ( $opt_verbose || $ENV{GBE_SVN_USERNAME} || $ENV{GBE_SVN_PATH} )
315 dpurdie 262
    {
341 dpurdie 263
        print "\nSubVersion\n";
315 dpurdie 264
        denv    "GBE_SVN_PATH";
265
        penv    "GBE_SVN_USERNAME";
266
        penv    "GBE_SVN_PASSWORD";
353 dpurdie 267
        print "\nSubVersion Repository Paths\n";
268
        push @indents, $indent;
269
        $indent = 24;
270
        foreach ( sort keys %ENV )
271
        {
272
            penv    $_ if ( m ~^GBE_SVN_URL~ );
273
        }
274
        $indent = pop @indents;
315 dpurdie 275
    }
276
 
277
    if ( $opt_verbose && ! $GBE_UNIX)
278
    {
279
        print "\nWindows Environment\n";
280
        denv  "TEMP";
281
        denv  "TMP";
282
 
283
        print "\nMicrosoft Studio Variables\n";
284
        denv  "PROGRAMFILES";
285
        denv  "WINDIR";
286
        denv  "MSVCDir";
287
 
288
        print "\nMicroTec Compiler Variables\n";
289
        denv "MRI_68K";
290
        denv "MRI_CF";
291
        denv "VISIONCLICK";
292
 
293
        print "\nPCLint Variables\n";
294
        denv "PCLINT";
295
        penv "LINTPACKAGE";
296
    }
297
}
298
 
299
#-------------------------------------------------------------------------------
300
#   Documentation
301
#
302
 
303
=pod
304
 
305
=head1 NAME
306
 
307
vars - Display Jats Related Environment Variables
308
 
309
=head1 SYNOPSIS
310
 
311
  jats vars [options]
312
 
313
 Options:
314
    -help              - brief help message
315
    -help -help        - Detailed help message
316
    -man               - Full documentation
317
    -verbose[=n]       - Verbose operation
318
 
319
=head1 OPTIONS
320
 
321
=over 8
322
 
323
=item B<-help>
324
 
325
Print a brief help message and exits.
326
 
327
=item B<-help -help>
328
 
329
Print a detailed help message with an explanation for each option.
330
 
331
=item B<-man>
332
 
333
Prints the manual page and exits.
334
This is the same as -help=3.
335
 
336
=item B<-man[=n]>
337
 
338
Set the help level directly. Valid values are 0,1,2 and 3.
339
 
340
=item B<-verbose[=n]>
341
 
342
This option will increase the level of verbosity of the command.
343
 
344
The allowed verbosity levels are:
345
 
346
=over 4
347
 
361 dpurdie 348
=item 0
315 dpurdie 349
 
361 dpurdie 350
Basic variable display
315 dpurdie 351
 
361 dpurdie 352
=item 1
315 dpurdie 353
 
361 dpurdie 354
Display additional JATS related information.
355
 
356
=item 2
357
 
358
Display all the Environment variables.
359
 
315 dpurdie 360
=back
361
 
362
=back
363
 
364
=head1 DESCRIPTION
365
 
361 dpurdie 366
This program will display the values of all JATS related L<environment
367
variables|POD::EnvVars>.
315 dpurdie 368
 
369
Many of the variables will be displayed with sanity information. If the
370
variable is a PATH and and the PATH does not exist, then the displayed value
361 dpurdie 371
will be prefixed with a '*'
315 dpurdie 372
 
373
=cut
374