ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/bin/scram
Revision: 1.6
Committed: Tue Feb 7 14:24:00 2012 UTC (13 years, 3 months ago) by muzaffar
Branch: MAIN
CVS Tags: V2_2_4, V2_2_4_pre9, V2_2_4_pre8, V2_2_4_pre7, V2_2_4_pre6, V2_2_4_pre5, V2_2_4_pre4
Changes since 1.5: +3 -1 lines
Log Message:
save the actual SCRAM_ARCH value for later use

File Contents

# User Rev Content
1 muzaffar 1.2 #!/usr/bin/env perl
2    
3     BEGIN
4     {
5     use File::Basename;
6     use Cwd;
7     my $installdir=dirname($0);
8     if ($installdir!~/^\//)
9     {
10     $installdir=getcwd()."/${installdir}";
11     }
12     $installdir=dirname($installdir);
13     $ENV{'SCRAM_TOOL_HOME'}="${installdir}/src";
14     $ENV{'SCRAM'}=$0;
15     unshift @INC,"$installdir", "${installdir}/src";
16     }
17    
18     use SCRAM::SCRAM;
19     use Getopt::Long ();
20    
21     #### EDIT THESE: SCRAM Installation Values #################
22     $ENV{'SCRAM_VERSION'}='@SCRAM_VERSION@';
23 muzaffar 1.3 my $dbPath = '@CMS_PATH@';
24 muzaffar 1.5 my $dbPathWrite = '@CMS_PATH@';
25 muzaffar 1.2 #### Core settings ####
26     $main::bold = "";
27     $main::normal = "";
28     $main::line = "-"x80;
29     $main::lookupdb = "";
30     $main::error = "";
31     $main::good = "";
32     $main::prompt="";
33     $main::ORIG_ARGV=[];
34 muzaffar 1.6 $main::ORIG_SCRAM_ARCH = $ENV{SCRAM_ARCH} || "";
35     $main::FORCE_SCRAM_ARCH = "";
36 muzaffar 1.2 push @$main::ORIG_ARGV,@ARGV;
37     $|=1;
38    
39 muzaffar 1.3 if (!exists $ENV{SCRAM_LOOKUPDB})
40     {
41     if (exists $ENV{SCRAM_USERLOOKUPDB}){$dbPath = $ENV{SCRAM_USERLOOKUPDB};}
42     $ENV{SCRAM_LOOKUPDB} = $dbPath;
43     }
44 muzaffar 1.5 if (!exists $ENV{SCRAM_LOOKUPDB_WRITE})
45     {
46     if (exists $ENV{SCRAM_USERLOOKUPDB}){$dbPathWrite = $ENV{SCRAM_USERLOOKUPDB};}
47     $ENV{SCRAM_LOOKUPDB_WRITE} = $dbPathWrite;
48     }
49 muzaffar 1.3
50 muzaffar 1.2 # Test whether the output from SCRAM is being redirected, or
51     # not (prevents escape signals from being printed to STDOUT if
52     # STDOUT is redirected to a file or piped):
53     if ( -t STDIN && -t STDOUT && $^O !~ /MSWin32|cygwin/ )
54     {
55     $bold = "\033[1m";
56     $normal = "\033[0m";
57     $prompt = "\033[0;32;1m";
58     $fail = "\033[0;31;1m"; # Red
59     $pass = "\033[0;33;1m"; # Yellow
60     $good = $bold.$pass; # Status messages ([OK])
61     $error = $bold.$fail; # ([ERROR])
62     }
63    
64     # Start a SCRAM session:
65     $scram = SCRAM::SCRAM->new();
66    
67     # Getopt option variables:
68     my %opts;
69     my %options =
70     ("verbose|v=s" => sub { $ENV{SCRAM_VERBOSE} = $ENV{SCRAM_DEBUG} = 1; $scram->classverbosity($_[1]) },
71     "debug|d" => sub { $ENV{SCRAM_DEBUG} = 1; $scram->fullverbosity() },
72 muzaffar 1.6 "arch|a=s" => sub { $ENV{SCRAM_ARCH} = $_[1] ; $main::FORCE_SCRAM_ARCH = $_[1] },
73 muzaffar 1.2 "force|f" => sub { $opts{SCRAM_FORCE} = 1 }, # A force flag for commands that might need it
74 muzaffar 1.3 "help|h" => sub { print $scram->usage(); exit(0) ;}
75 muzaffar 1.2 );
76    
77     # Get the options using Getopt:
78     Getopt::Long::config qw(default no_ignore_case require_order bundling);
79    
80     if (! Getopt::Long::GetOptions(\%opts, %options))
81     {
82     $scram->scramfatal("Error parsing arguments. See \"scram help\" for usage info.");
83     exit(1);
84     }
85    
86     # Check for a valid command and execute it or show an error message:
87     my $command=shift(@ARGV);
88    
89 muzaffar 1.3 if (!$command)
90 muzaffar 1.2 {
91     print $scram->usage();
92 muzaffar 1.3 exit(1);
93 muzaffar 1.2 }
94 muzaffar 1.4 elsif($command=~/^(install|remove)$/o){exit(0);}
95 muzaffar 1.2 $scram->init ($opts{SCRAM_FORCE});
96    
97 muzaffar 1.3 exit($scram->execcommand($command,@ARGV));