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