ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/bin/scram
Revision: 1.7
Committed: Thu Mar 14 10:42:00 2013 UTC (12 years, 1 month ago) by muzaffar
Branch: MAIN
CVS Tags: V2_2_5_pre2, V2_2_5_pre1, HEAD
Changes since 1.6: +5 -1 lines
Error occurred while calculating annotation data.
Log Message:
override writable scram DB path too if SCRAM_USERLOOKUPDB is set

File Contents

# Content
1 #!/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 my $dbPath = '@CMS_PATH@';
24 my $dbPathWrite = '@CMS_PATH@';
25 #### 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 $main::ORIG_SCRAM_ARCH = $ENV{SCRAM_ARCH} || "";
35 $main::FORCE_SCRAM_ARCH = "";
36 push @$main::ORIG_ARGV,@ARGV;
37 $|=1;
38
39 if (!exists $ENV{SCRAM_LOOKUPDB})
40 {
41 if (exists $ENV{SCRAM_USERLOOKUPDB})
42 {
43 $dbPath = $ENV{SCRAM_USERLOOKUPDB};
44 $dbPathWrite = $dbPath;
45 }
46 $ENV{SCRAM_LOOKUPDB} = $dbPath;
47 }
48 if (!exists $ENV{SCRAM_LOOKUPDB_WRITE})
49 {
50 if (exists $ENV{SCRAM_USERLOOKUPDB}){$dbPathWrite = $ENV{SCRAM_USERLOOKUPDB};}
51 $ENV{SCRAM_LOOKUPDB_WRITE} = $dbPathWrite;
52 }
53
54 # Test whether the output from SCRAM is being redirected, or
55 # not (prevents escape signals from being printed to STDOUT if
56 # STDOUT is redirected to a file or piped):
57 if ( -t STDIN && -t STDOUT && $^O !~ /MSWin32|cygwin/ )
58 {
59 $bold = "\033[1m";
60 $normal = "\033[0m";
61 $prompt = "\033[0;32;1m";
62 $fail = "\033[0;31;1m"; # Red
63 $pass = "\033[0;33;1m"; # Yellow
64 $good = $bold.$pass; # Status messages ([OK])
65 $error = $bold.$fail; # ([ERROR])
66 }
67
68 # Start a SCRAM session:
69 $scram = SCRAM::SCRAM->new();
70
71 # Getopt option variables:
72 my %opts;
73 my %options =
74 ("verbose|v=s" => sub { $ENV{SCRAM_VERBOSE} = $ENV{SCRAM_DEBUG} = 1; $scram->classverbosity($_[1]) },
75 "debug|d" => sub { $ENV{SCRAM_DEBUG} = 1; $scram->fullverbosity() },
76 "arch|a=s" => sub { $ENV{SCRAM_ARCH} = $_[1] ; $main::FORCE_SCRAM_ARCH = $_[1] },
77 "force|f" => sub { $opts{SCRAM_FORCE} = 1 }, # A force flag for commands that might need it
78 "help|h" => sub { print $scram->usage(); exit(0) ;}
79 );
80
81 # Get the options using Getopt:
82 Getopt::Long::config qw(default no_ignore_case require_order bundling);
83
84 if (! Getopt::Long::GetOptions(\%opts, %options))
85 {
86 $scram->scramfatal("Error parsing arguments. See \"scram help\" for usage info.");
87 exit(1);
88 }
89
90 # Check for a valid command and execute it or show an error message:
91 my $command=shift(@ARGV);
92
93 if (!$command)
94 {
95 print $scram->usage();
96 exit(1);
97 }
98 elsif($command=~/^(install|remove)$/o){exit(0);}
99 $scram->init ($opts{SCRAM_FORCE});
100
101 exit($scram->execcommand($command,@ARGV));