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