1 |
< |
#!/usr/local/bin/perl5 -I$SCRAM_HOME/src -I/afs/cern.ch/user/w/williamc/public/SCRAM/src |
2 |
< |
|
1 |
> |
#!/usr/local/bin/perl5 |
2 |
|
# |
3 |
|
# User Interface |
4 |
|
# |
5 |
|
|
6 |
+ |
# Make sure were running the right version |
7 |
+ |
versioncheck(); |
8 |
+ |
|
9 |
|
$inputcmd=shift; |
10 |
|
$found='false'; |
11 |
< |
@allowed_commands=qw(project build env install version list arch); |
12 |
< |
|
13 |
< |
foreach $command ( @allowed_commands ) { |
14 |
< |
do { &$command; $found='true'; last;} if ( $inputcmd=~/^$command\Z/i); |
11 |
> |
$bold = "\033[1m"; |
12 |
> |
$normal = "\033[0m"; |
13 |
> |
@allowed_commands=qw(project build install version list arch setup runtime db devtest doctest); |
14 |
> |
|
15 |
> |
use Scram::SCRAM2; |
16 |
> |
setupscram(); |
17 |
> |
if ( $inputcmd ne "" ) { |
18 |
> |
foreach $command ( @allowed_commands ) { |
19 |
> |
if ( $command=~/^$inputcmd/i) { |
20 |
> |
# Deal with a help request |
21 |
> |
do{ helpheader($command); |
22 |
> |
&{"help_".$command}; exit; } if $ARGV[0]=~/help/i; |
23 |
> |
&$command; $found='true'; |
24 |
> |
last; |
25 |
> |
} |
26 |
> |
} |
27 |
|
} |
28 |
|
|
29 |
|
if ( ! ( $found=~/true/ ) ) { |
30 |
< |
print "scram help\n--------\n"; |
17 |
< |
print "Recognised Commands: \n"; |
30 |
> |
helpheader('Recognised Commands'); |
31 |
|
foreach $command ( @allowed_commands ) { |
32 |
< |
print " ".$command."\n"; |
32 |
> |
print " $bold scram ".$command.$normal."\n"; |
33 |
> |
} |
34 |
> |
print "\n"; |
35 |
> |
print "Help on individual commands available through\n\n"; |
36 |
> |
print "$bold scram".$normal." command$bold help $normal\n\n"; |
37 |
> |
} |
38 |
> |
|
39 |
> |
sub versioncheck { |
40 |
> |
my $version; |
41 |
> |
my $thisversion; |
42 |
> |
|
43 |
> |
$thisversion=getversion(); |
44 |
> |
|
45 |
> |
if ( ! localtop_find() ) { |
46 |
> |
LoadEnvFile(); |
47 |
> |
my $versionfile=$ENV{LOCALTOP}."/$ENV{projconfigdir}/scram_version"; |
48 |
> |
if ( -f $versionfile ) { |
49 |
> |
open (VERSION, "<".$versionfile) ; |
50 |
> |
$version=<VERSION>; |
51 |
> |
chomp $version; |
52 |
> |
if ( $version ne $thisversion ) { |
53 |
> |
# first try to use the correct version |
54 |
> |
if ( -d $scram_top."/".$version ) { |
55 |
> |
$ENV{SCRAM_HOME}=$scram_top."/".$version; |
56 |
> |
system("scram", @ARGV); |
57 |
> |
exit; |
58 |
> |
} |
59 |
> |
else { # if not then simply warn |
60 |
> |
print "******* Warning : scram version inconsistent ********\n"; |
61 |
> |
print "This version: $thisversion; Required version: $version"; |
62 |
> |
print "*****************************************************\n"; |
63 |
> |
print "\n"; |
64 |
> |
} |
65 |
> |
} |
66 |
> |
} |
67 |
|
} |
68 |
|
} |
69 |
|
|
70 |
+ |
sub doctest { |
71 |
+ |
$scram->doctest(@ARGV); |
72 |
+ |
} |
73 |
+ |
|
74 |
+ |
sub help_build { |
75 |
+ |
&build; |
76 |
+ |
} |
77 |
|
sub build { |
78 |
|
# is this a based or free release? |
79 |
|
FullEnvInit(); |
80 |
|
use BuildSetup; |
81 |
+ |
$ENV{MAKETARGETS}=join ' ',@ARGV; |
82 |
|
BuildSetup($ENV{THISDIR},@ARGV); |
83 |
|
# system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV); |
84 |
|
} |
86 |
|
sub project { |
87 |
|
# process options |
88 |
|
while ( $ARGV[0]=~"^-" ) { |
89 |
< |
if ( (shift @ARGV)=~/-d/ ) { #installation area directory |
89 |
> |
if ( $ARGV[0]=~/-n/ ) { |
90 |
> |
shift @ARGV; |
91 |
> |
$ENV{devareaname}=shift @ARGV; |
92 |
> |
} |
93 |
> |
elsif ( $ARGV[0]=~/-d/ ) { #installation area directory |
94 |
> |
shift @ARGV; |
95 |
|
chdir $ARGV[0]; |
96 |
|
shift @ARGV; |
97 |
|
} |
98 |
+ |
else { |
99 |
+ |
print "scram: unknown option $ARGV[0] to project command\n"; |
100 |
+ |
exit; |
101 |
+ |
} |
102 |
+ |
} |
103 |
+ |
$scram->project(@ARGV); |
104 |
+ |
print "\nInstallation Procedure Complete. \n". |
105 |
+ |
"Installation Located at:\n".cwd()."\n"; |
106 |
+ |
} |
107 |
+ |
|
108 |
+ |
sub runtime { |
109 |
+ |
my $shell; |
110 |
+ |
FullEnvInit(); |
111 |
+ |
|
112 |
+ |
# process options |
113 |
+ |
while ( $ARGV[0]=~"^-" ) { |
114 |
+ |
if ( $ARGV[0]=~/-sh/ ) { |
115 |
+ |
shift @ARGV; |
116 |
+ |
$shell="sh"; |
117 |
+ |
next; |
118 |
+ |
} |
119 |
+ |
if ( $ARGV[0]=~/-csh/ ) { #installation area directory |
120 |
+ |
shift @ARGV; |
121 |
+ |
$shell="csh"; |
122 |
+ |
next; |
123 |
+ |
} |
124 |
+ |
print "Unknown Option $ARGV[0]\n"; |
125 |
+ |
exit 1; |
126 |
|
} |
127 |
< |
my $project=shift @ARGV; |
128 |
< |
my $version=shift @ARGV; |
129 |
< |
environmentinit(); |
130 |
< |
use File::Copy; |
131 |
< |
use Utilities::AddDir; |
132 |
< |
|
133 |
< |
use BootStrapProject; |
134 |
< |
# get the bootstrap files downloaded |
135 |
< |
BootStrapProject("$project\?\?$version"); |
136 |
< |
# Go setup the rest of the environement, now we can |
137 |
< |
chdir $ENV{LOCALTOP}; |
138 |
< |
&localtop; |
139 |
< |
LoadEnvFile(); |
140 |
< |
# |
141 |
< |
# Now create the directories specified in the interface |
142 |
< |
# |
143 |
< |
foreach $key ( keys %ENV ) { |
144 |
< |
if ( $key=~/^INT/ ) { |
145 |
< |
AddDir::adddir($ENV{$key}); |
127 |
> |
|
128 |
> |
# We have to clean up from the last runtime cmd - use env history |
129 |
> |
foreach $variable ( %ENV ) { |
130 |
> |
if ( $variable=~/^SCRAMRT_(.*)/ ) { #SCRAMRT are history retaining |
131 |
> |
my $var=$1; |
132 |
> |
$ENV{$var}=~s/\Q$ENV{$variable}\E//g; |
133 |
> |
$ENV{$var}=~s/^:*//; # Deal with any Path variables |
134 |
> |
#print "$variable : $ENV{$variable} \n$var : $ENV{$var}\n"; |
135 |
> |
delete $ENV{$variable}; |
136 |
> |
} |
137 |
> |
} |
138 |
> |
|
139 |
> |
# Set SCRAM release area paths |
140 |
> |
addpath("LD_LIBRARY_PATH","$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}"); |
141 |
> |
addpath("LD_LIBRARY_PATH","$ENV{RELEASETOP}/lib/$ENV{SCRAM_ARCH}"); |
142 |
> |
|
143 |
> |
open (file, "$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings" ) |
144 |
> |
or die "Unable to open file ". |
145 |
> |
"$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings $!"; |
146 |
> |
while( <file> ) { |
147 |
> |
chomp; |
148 |
> |
next if /^#/; |
149 |
> |
next if /^\s*$/; |
150 |
> |
($product, $version, $type, $variable, $value, @junk)=split /:/; |
151 |
> |
next if ( $variable=~/\&/ ); |
152 |
> |
if ( $type=~/^R/ ) { |
153 |
> |
if ( ( $type=~/path/ ) ) { #type Runtime_path type |
154 |
> |
#addvar($variable,$value,":"); # Colon seperated |
155 |
> |
addpath($variable,$value); # Colon seperated |
156 |
> |
} |
157 |
> |
else { #type Runtime |
158 |
> |
$EnvRuntime{$variable}=$value; # just set the variable |
159 |
> |
#addvar($variable,$value," "); # Add with spaces |
160 |
|
} |
161 |
< |
} |
162 |
< |
if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) { |
163 |
< |
system("cp", "-r", "$ENV{RELEASETOP}/$ENV{projconfigdir}", |
164 |
< |
"$ENV{LOCALTOP}/$ENV{projconfigdir}"); |
165 |
< |
} |
166 |
< |
use clientfile; |
167 |
< |
BuildClientFile( $ENV{SCRAM_ProjReqsDoc} ); |
168 |
< |
use Cwd; |
169 |
< |
print "Installation Located at:\n".cwd()."\n"; |
170 |
< |
print "Press RETURN to exit\n"; |
171 |
< |
$junk=<STDIN>; |
161 |
> |
} |
162 |
> |
} |
163 |
> |
close file; |
164 |
> |
addpath("PATH","$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}"); |
165 |
> |
addpath("PATH","$ENV{RELEASETOP}/bin/$ENV{SCRAM_ARCH}"); |
166 |
> |
|
167 |
> |
# Now get the general project environment |
168 |
> |
open ( SCRAMENV, "<$ENV{LOCALTOP}/$ENV{projconfigdir}/Runtime" ); |
169 |
> |
while ( <SCRAMENV> ) { |
170 |
> |
chomp; |
171 |
> |
next if /^#/; |
172 |
> |
next if /^\s*$/; |
173 |
> |
($name, $value)=split /=/; |
174 |
> |
addvar($name, (eval $value)," "); |
175 |
> |
} |
176 |
> |
close SCRAMENV; |
177 |
> |
|
178 |
> |
# create new SCRAMRT history vars. |
179 |
> |
foreach $variable ( keys %EnvRuntime ) { |
180 |
> |
printoutenv($shell,"SCRAMRT_$variable",$EnvRuntime{$variable}); |
181 |
> |
#addvar("SCRAMRT_$variable", $EnvRuntime{$variable}, ""); |
182 |
> |
} |
183 |
> |
# Now adapt as necessary - include base environment as well |
184 |
> |
if ( exists $ENV{LD_LIBRARY_PATH} ) { |
185 |
> |
addpath("LD_LIBRARY_PATH","$ENV{LD_LIBRARY_PATH}"); |
186 |
> |
} |
187 |
> |
if ( exists $ENV{MANPATH} ) { |
188 |
> |
addpath("MANPATH","$ENV{MANPATH}"); |
189 |
> |
} |
190 |
> |
addpath("PATH","$ENV{PATH}"); |
191 |
> |
# Print out as reqd |
192 |
> |
foreach $variable ( keys %EnvRuntime ) { |
193 |
> |
printoutenv($shell,$variable,$EnvRuntime{$variable}); |
194 |
> |
} |
195 |
> |
} |
196 |
> |
|
197 |
> |
# Support rt for runtime |
198 |
> |
|
199 |
> |
sub printoutenv { |
200 |
> |
my $shell=shift; |
201 |
> |
my $variable=shift; |
202 |
> |
my $value=shift; |
203 |
> |
|
204 |
> |
if ( $shell eq "csh" ) { |
205 |
> |
print "setenv $variable \"$value\";\n"; |
206 |
> |
} |
207 |
> |
elsif ( $shell eq "sh" ) { |
208 |
> |
print "$variable=\"$value\";\n"; |
209 |
> |
print "export $variable;\n"; |
210 |
> |
} |
211 |
> |
} |
212 |
> |
|
213 |
> |
sub addpath { |
214 |
> |
my $name=shift; |
215 |
> |
my $val=shift; |
216 |
> |
|
217 |
> |
my $n; |
218 |
> |
my @env; |
219 |
> |
@env=split /:/, $EnvRuntime{$name}; |
220 |
> |
foreach $n ( (split /:/, $val ) ){ |
221 |
> |
if ( ! grep /^\Q$n\E$/, @env ) { |
222 |
> |
addvar($name,$n,":"); |
223 |
> |
} |
224 |
> |
} |
225 |
> |
} |
226 |
> |
|
227 |
> |
sub addvar { |
228 |
> |
my $name=shift; |
229 |
> |
my $val=shift; |
230 |
> |
my $sep=shift; |
231 |
> |
|
232 |
> |
if ( $val ne "" ) { |
233 |
> |
if ( defined $EnvRuntime{$name} ) { |
234 |
> |
$EnvRuntime{$name}=$EnvRuntime{$name}.$sep.$val; |
235 |
> |
} |
236 |
> |
else { |
237 |
> |
$EnvRuntime{$name}=$val; |
238 |
> |
} |
239 |
> |
} |
240 |
|
} |
241 |
|
|
242 |
|
sub FullEnvInit { |
258 |
|
$ENV{INTbin}="bin/$ENV{SCRAM_ARCH}"; |
259 |
|
$ENV{INTlog}="logs"; |
260 |
|
|
261 |
< |
if ( ! ( exists $ENV{SCRAM_HOME}) ){ |
262 |
< |
$ENV{SCRAM_HOME}="/afs/cern.ch/user/w/williamc/public/SCRAM"; |
93 |
< |
print "Warning : Environment Variable SCRAM_HOME not set.\n"; |
94 |
< |
print "Defaulting to $ENV{SCRAM_HOME}\n"; |
95 |
< |
} |
96 |
< |
if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){ |
261 |
> |
($ENV{SCRAM_BASEDIR}=$ENV{SCRAM_HOME})=~s/(.*)\/.*/$1/; |
262 |
> |
if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){ |
263 |
|
$ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration"; |
264 |
|
} |
265 |
|
if ( ! ( exists $ENV{TOOL_HOME} ) ){ |
266 |
|
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src"; |
267 |
|
} |
268 |
|
if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){ |
269 |
< |
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup"; |
269 |
> |
if ( -d "$ENV{SCRAM_BASEDIR}/scramdb/" ) { |
270 |
> |
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_BASEDIR}/scramdb/project.lookup"; |
271 |
> |
} |
272 |
> |
else { |
273 |
> |
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup"; |
274 |
> |
} |
275 |
|
} |
276 |
+ |
$ENV{SCRAM_AVAILDIRS}=""; |
277 |
+ |
$ENV{SCRAM_AVAILFILES}=""; |
278 |
|
} |
279 |
|
|
280 |
< |
sub localtop { |
280 |
> |
sub localtop_find { |
281 |
|
# find localtop |
282 |
|
use Cwd; |
283 |
|
my $thispath=cwd; |
284 |
+ |
my $rv=1; |
285 |
+ |
|
286 |
|
block: { |
287 |
|
do { |
288 |
|
if ( -e "$thispath/.SCRAM" ) { |
289 |
|
$ENV{LOCALTOP}=$thispath; |
290 |
+ |
$ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM"; |
291 |
+ |
$rv=0; |
292 |
|
last block; |
293 |
|
} |
294 |
|
} while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./ ); |
295 |
+ |
} #end block |
296 |
+ |
return $rv; |
297 |
+ |
} |
298 |
+ |
|
299 |
+ |
sub localtop { |
300 |
+ |
localtop_find(); |
301 |
|
if ( ! (defined $ENV{LOCALTOP}) ) { |
302 |
|
print "Unable to locate the top of local release. Exiting\n"; |
303 |
< |
exit 1 |
303 |
> |
exit 1; |
304 |
|
} |
305 |
< |
} #end block |
123 |
< |
($ENV{THISDIR}=cwd)=~s/^$ENV{LOCALTOP}//; |
305 |
> |
($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//; |
306 |
|
$ENV{THISDIR}=~s/^\///; |
125 |
– |
$ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM"; |
307 |
|
} |
308 |
|
|
309 |
|
sub LoadEnvFile { |
331 |
|
my $version=shift @ARGV; |
332 |
|
|
333 |
|
# create database entry |
153 |
– |
do { &help_install; } if $tagname=~/help/i; |
334 |
|
&FullEnvInit; |
335 |
|
if ( $version eq "" ) { |
336 |
|
$version=$ENV{SCRAM_PROJVERSION}; |
338 |
|
if ( $tagname eq "" ) { |
339 |
|
$tagname=$ENV{SCRAM_PROJECTNAME}; |
340 |
|
} |
341 |
< |
my $filename="$ENV{SCRAM_CONFIG}/project.lookup"; |
342 |
< |
my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp"; |
341 |
> |
my $filename=$ENV{SCRAM_LOOKUPDB}; |
342 |
> |
my $outfile=$ENV{SCRAM_LOOKUPDB}.".tmp"; |
343 |
|
open ( LOCALLOOKUPDB, "<$filename" ); |
344 |
< |
open ( OUTFILE , ">$outfile" ); |
344 |
> |
open ( OUTFILE , ">$outfile" ) or die "Unable to open $outfile $!\n"; |
345 |
|
while ( <LOCALLOOKUPDB> ) { |
346 |
|
if ( /^$tagname/ ) { |
347 |
|
print "Related tag :".$_."\n"; |
368 |
|
close LOCALLOOKUPDB; |
369 |
|
copy ( "$outfile", "$filename" ) |
370 |
|
|| die "Unable to copy $! \n"; |
371 |
+ |
&align; |
372 |
+ |
} |
373 |
+ |
|
374 |
+ |
# |
375 |
+ |
# align variables with actual location of release |
376 |
+ |
# |
377 |
|
|
378 |
+ |
sub align { |
379 |
+ |
&localtop; |
380 |
+ |
LoadEnvFile(); |
381 |
+ |
|
382 |
+ |
use File::Copy; |
383 |
+ |
rename( "$ENV{SCRAM_WORKDIR}/Environment", |
384 |
+ |
"$ENV{SCRAM_WORKDIR}/Environment.bak"); |
385 |
+ |
open ( SCRAMENV, "<$ENV{SCRAM_WORKDIR}/Environment.bak" ) || |
386 |
+ |
die "Cant find Environment file $!\n"; |
387 |
+ |
open ( SCRAMENVOUT, ">$ENV{SCRAM_WORKDIR}/Environment" ) || |
388 |
+ |
die "Cant Open Environment file $!\n"; |
389 |
+ |
while ( <SCRAMENV> ) { |
390 |
+ |
$_=~s/\Q$ENV{RELEASETOP}\L/$ENV{LOCALTOP}/g; |
391 |
+ |
print SCRAMENVOUT $_; |
392 |
+ |
} |
393 |
+ |
close SCRAMENV; |
394 |
+ |
close SCRAMENVOUT; |
395 |
|
} |
396 |
|
|
397 |
|
sub help_install() { |
398 |
|
|
196 |
– |
helpheader("install"); |
399 |
|
print <<ENDTEXT; |
400 |
|
Associates a label with the current release in the SCRAM database. |
401 |
|
This allows other users to refer to a centrally installed project by |
403 |
|
|
404 |
|
Usage: |
405 |
|
|
406 |
< |
scram install [[label] [version]] |
406 |
> |
$bold scram install $normal [project_tag [version_tag]] |
407 |
|
|
408 |
< |
label : override default label (the project name of the current release) |
409 |
< |
version : the version tag of the current release. If version is not |
408 |
> |
porject_tag : override default label (the project name of the current release) |
409 |
> |
version_tag : the version tag of the current release. If version is not |
410 |
|
specified the base release version will be taken by default. |
411 |
|
|
412 |
|
ENDTEXT |
422 |
|
ENDTEXT |
423 |
|
} |
424 |
|
|
425 |
+ |
sub getversion { |
426 |
+ |
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///; |
427 |
+ |
$scram_top=$1; |
428 |
+ |
$scram_version=$thisversion; |
429 |
+ |
# deal with links |
430 |
+ |
my $version=readlink $ENV{SCRAM_HOME}; |
431 |
+ |
if ( defined $version) { |
432 |
+ |
$scram_version=$version; |
433 |
+ |
} |
434 |
+ |
return $scram_version; |
435 |
+ |
} |
436 |
+ |
|
437 |
|
sub version { |
438 |
< |
print "Scram version : prototype\n"; |
438 |
> |
my $version=shift @ARGV; |
439 |
> |
my $thisversion; |
440 |
> |
my $scram_top; |
441 |
> |
my $cvsobject; |
442 |
> |
|
443 |
> |
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///; |
444 |
> |
$scram_top=$1; |
445 |
> |
if ( $version eq "" ) { |
446 |
> |
print "$thisversion"; |
447 |
> |
# deal with links |
448 |
> |
$version=readlink $ENV{SCRAM_HOME}; |
449 |
> |
if ( defined $version) { |
450 |
> |
print " ---> $version"; |
451 |
> |
} |
452 |
> |
print "\n"; |
453 |
> |
} |
454 |
> |
else { |
455 |
> |
if ( -d $scram_top."/".$version ) { |
456 |
> |
print "Version $version exists\n"; |
457 |
> |
} |
458 |
> |
else { |
459 |
> |
print "Version $version not available locally\n"; |
460 |
> |
print "Attempting download from the SCRAM repository\n"; |
461 |
> |
# set up and configure the cvs module for SCRAM |
462 |
> |
use Utilities::CVSmodule; |
463 |
> |
$cvsobject=cvsmodule->new(); |
464 |
> |
$cvsobject->set_base( |
465 |
> |
"cmscvs.cern.ch:/cvs_server/repositories/SCRAM"); |
466 |
> |
$cvsobject->set_auth("pserver"); |
467 |
> |
$cvsobject->set_user("anonymous"); |
468 |
> |
$cvsobject->set_passkey("AA_:yZZ3e"); |
469 |
> |
# Now check it out in the right place |
470 |
> |
chdir $scram_top or die "Unable to change to $scram_top $!\n"; |
471 |
> |
$cvsobject->invokecvs( ( split / /, |
472 |
> |
"co -d $version -r $version SCRAM" )); |
473 |
> |
|
474 |
> |
# Get rid of cvs object now weve finished |
475 |
> |
$cvsobject=undef; |
476 |
> |
print "\n"; |
477 |
> |
} |
478 |
> |
} |
479 |
|
} |
480 |
|
|
481 |
|
sub list { |
482 |
|
&environmentinit; |
483 |
< |
my $filename="$ENV{SCRAM_CONFIG}/project.lookup"; |
230 |
< |
open ( LOCALLOOKUPDB, "<$filename" ); |
483 |
> |
my $filename="$ENV{SCRAM_LOOKUPDB}"; |
484 |
|
print "Installed Projects\n"; |
485 |
|
print "------------------\n"; |
486 |
|
print "|Project Name | Project Version |\n"; |
487 |
|
print "----------------------------------\n"; |
488 |
< |
while ( <LOCALLOOKUPDB> ) { |
489 |
< |
( $name, $version, $type, $url ) = split ":", $_; |
488 |
> |
listdb($filename); |
489 |
> |
} |
490 |
> |
|
491 |
> |
sub db { |
492 |
> |
my $subcmd=shift @ARGV; |
493 |
> |
&environmentinit; |
494 |
> |
|
495 |
> |
switch : { |
496 |
> |
if ( $subcmd eq 'link' ) { |
497 |
> |
dblink($ENV{SCRAM_LOOKUPDB},@ARGV); |
498 |
> |
last switch; |
499 |
> |
} |
500 |
> |
if ( $subcmd eq 'unlink' ) { |
501 |
> |
dbunlink($ENV{SCRAM_LOOKUPDB},@ARGV); |
502 |
> |
last switch; |
503 |
> |
} |
504 |
> |
if ( $subcmd eq 'showlinks' ) { |
505 |
> |
dblinklist($ENV{SCRAM_LOOKUPDB}); |
506 |
> |
last switch; |
507 |
> |
} |
508 |
> |
} # end switch |
509 |
> |
|
510 |
> |
} |
511 |
> |
|
512 |
> |
sub dblinklist { |
513 |
> |
my $filename=shift; |
514 |
> |
open (LOCALLOOKUPDB, "<$filename") or |
515 |
> |
die "Unable to open local database $!"; |
516 |
> |
while (<LOCALLOOKUPDB>) { |
517 |
> |
if ( $_=~/\!DB (.*)/) { |
518 |
> |
print $1,"\n"; |
519 |
> |
} |
520 |
> |
} |
521 |
> |
close LOCALLOOKUPDB; |
522 |
> |
} |
523 |
> |
|
524 |
> |
sub dblink { |
525 |
> |
my $filename=shift; |
526 |
> |
my $newdbfilename=shift; |
527 |
> |
my $exists=0; |
528 |
> |
|
529 |
> |
if ( -e $filename ) { |
530 |
> |
if ( -e $newdbfilename ) { |
531 |
> |
# Check if its already there |
532 |
> |
open (LOCALLOOKUPDB, "<$filename") or |
533 |
> |
die "Unable to open local database $!"; |
534 |
> |
while (<LOCALLOOKUPDB>) { |
535 |
> |
if ( $_=~/\!DB $newdbfilename/ ) { |
536 |
> |
$exists=1; |
537 |
> |
last; |
538 |
> |
} |
539 |
> |
} |
540 |
> |
close LOCALLOOKUPDB; |
541 |
> |
# Add it |
542 |
> |
if ( ! $exists ) { |
543 |
> |
open (LOCALLOOKUPDB, ">>$filename") or |
544 |
> |
die "Unable to open local database $!"; |
545 |
> |
print LOCALLOOKUPDB "\!DB $newdbfilename\n"; |
546 |
> |
close LOCALLOOKUPDB; |
547 |
> |
} |
548 |
> |
} |
549 |
> |
else { |
550 |
> |
print "Unknown file $newdbfilename\n"; |
551 |
> |
exit(); |
552 |
> |
} |
553 |
> |
} |
554 |
> |
else { |
555 |
> |
print "Unknown file $filename $!\n"; |
556 |
> |
exit(); |
557 |
> |
} |
558 |
> |
|
559 |
> |
} |
560 |
> |
|
561 |
> |
sub dbunlink { |
562 |
> |
my $filename=shift; |
563 |
> |
my $dbfilename=shift; |
564 |
> |
if ( -e $filename ) { |
565 |
> |
# Check if its already there |
566 |
> |
open (LOCALLOOKUPDB, "<$filename") or |
567 |
> |
die "Unable to open local database $!"; |
568 |
> |
open (DBOUTFILE, ">$filename.tmp") or |
569 |
> |
die "Unable to open working file $!"; |
570 |
> |
while (<LOCALLOOKUPDB>) { |
571 |
> |
if ( $_!~/\!DB $dbfilename/ ) { |
572 |
> |
print DBOUTFILE $_; |
573 |
> |
} |
574 |
> |
} |
575 |
> |
close LOCALLOOKUPDB; |
576 |
> |
close DBOUTFILE; |
577 |
> |
use File::Copy; |
578 |
> |
rename "$filename.tmp", $filename; |
579 |
> |
} |
580 |
> |
} |
581 |
> |
|
582 |
> |
sub listdb { |
583 |
> |
my $filename=shift; |
584 |
> |
my $map; |
585 |
> |
|
586 |
> |
use FileHandle; |
587 |
> |
my $fh=FileHandle->new(); |
588 |
> |
open ( $fh, "<$filename" ); |
589 |
> |
while ( $map=<$fh> ) { |
590 |
> |
if ( $map=~/^\!DB (.*)/ ) { # Check for other DB files |
591 |
> |
my $db=$1; |
592 |
> |
if ( -f $db ) { |
593 |
> |
listdb($db); |
594 |
> |
} |
595 |
> |
next; |
596 |
> |
} |
597 |
> |
( $name, $version, $type, $url ) = split ":", $map; |
598 |
|
printf "%1s",$name; |
599 |
|
printf "%25s\n",$version; |
600 |
|
printf "--> %25s\n",$type.":".$url; |
601 |
|
} |
602 |
< |
close LOCALLOOKUPDB; |
602 |
> |
close $fh; |
603 |
|
} |
604 |
|
|
605 |
|
sub arch { |
606 |
|
&environmentinit(); |
607 |
|
print "$ENV{SCRAM_ARCH}\n"; |
608 |
|
} |
609 |
+ |
|
610 |
+ |
sub setupscram { |
611 |
+ |
$scram=Scram::SCRAM2->new(); |
612 |
+ |
} |
613 |
+ |
|
614 |
+ |
# |
615 |
+ |
# Setup a tool |
616 |
+ |
# |
617 |
+ |
|
618 |
+ |
sub setup { |
619 |
+ |
my $toolname=shift @ARGV; |
620 |
+ |
|
621 |
+ |
if ( ! defined $toolname ) { |
622 |
+ |
# general area setup for new platform |
623 |
+ |
} |
624 |
+ |
else { |
625 |
+ |
$scram->setuptool($toolname); |
626 |
+ |
} |
627 |
+ |
|
628 |
+ |
} |
629 |
+ |
|
630 |
+ |
sub devtest { |
631 |
+ |
use Utilities::TestClass; |
632 |
+ |
my $class=shift @ARGV; |
633 |
+ |
|
634 |
+ |
$scram->devtest($class); |
635 |
+ |
} |
636 |
+ |
|
637 |
+ |
|
638 |
+ |
sub help_db { |
639 |
+ |
print <<ENDTEXT; |
640 |
+ |
scram database administration command. |
641 |
+ |
|
642 |
+ |
Usage: |
643 |
+ |
|
644 |
+ |
$bold scram db $normal subcommand |
645 |
+ |
|
646 |
+ |
subcommands: |
647 |
+ |
link : |
648 |
+ |
Make available an additional database for |
649 |
+ |
project and list operations |
650 |
+ |
|
651 |
+ |
$bold scram db link $normal /a/directory/path/project.lookup |
652 |
+ |
|
653 |
+ |
unlink : |
654 |
+ |
Remove a database from the link list. Note this does |
655 |
+ |
not remove the database, just the link to it in scram. |
656 |
+ |
|
657 |
+ |
$bold scram db unlink $normal /a/directory/path/project.lookup |
658 |
+ |
|
659 |
+ |
showlinks : |
660 |
+ |
List the databases that are linked in |
661 |
+ |
|
662 |
+ |
ENDTEXT |
663 |
+ |
} |
664 |
+ |
|
665 |
+ |
sub help_setup { |
666 |
+ |
|
667 |
+ |
print <<ENDTEXT; |
668 |
+ |
Allows installation/re-installation of a new tool/external package into an |
669 |
+ |
already existing development area. If not toolname is specified, |
670 |
+ |
the complete installation process is initiated. |
671 |
+ |
|
672 |
+ |
Usage: |
673 |
+ |
|
674 |
+ |
$bold scram setup $normal [toolname] |
675 |
+ |
|
676 |
+ |
toolname : The name of the tool setup file required. |
677 |
+ |
ENDTEXT |
678 |
+ |
exit; |
679 |
+ |
} |
680 |
+ |
|
681 |
+ |
sub help_list { |
682 |
+ |
print <<ENDTEXT; |
683 |
+ |
List the available projects and versions installed in the local SCRAM database |
684 |
+ |
(see scram install help) |
685 |
+ |
|
686 |
+ |
Usage: |
687 |
+ |
|
688 |
+ |
$bold scram list $normal |
689 |
+ |
|
690 |
+ |
ENDTEXT |
691 |
+ |
exit; |
692 |
+ |
} |
693 |
+ |
|
694 |
+ |
sub help_project { |
695 |
+ |
print <<ENDTEXT; |
696 |
+ |
Setup a new project development area. The new area will appear in the current |
697 |
+ |
working directory. |
698 |
+ |
Usage: |
699 |
+ |
|
700 |
+ |
$bold scram project [-d install_area] [-n directory_name]$normal project_url [project_version] |
701 |
+ |
|
702 |
+ |
Options: |
703 |
+ |
|
704 |
+ |
project_url: The url of a scram bootstrap file. |
705 |
+ |
Currently supported types are: |
706 |
+ |
$bold Database label $normal |
707 |
+ |
Labels can be assigned to bootstrap files for easy |
708 |
+ |
access (See "scram install" command). If you |
709 |
+ |
specify a label you must also specify a project_version. |
710 |
+ |
e.g. |
711 |
+ |
|
712 |
+ |
scram project SCRAM V1_0 |
713 |
+ |
|
714 |
+ |
scram project ORCA ORCA_1_1_1 |
715 |
+ |
|
716 |
+ |
To see the list of installed projects use the |
717 |
+ |
"scram list" command. |
718 |
+ |
|
719 |
+ |
$bold file: $normal A regular file on an accessable file system |
720 |
+ |
e.g. |
721 |
+ |
|
722 |
+ |
file:~/myprojects/projecta/config/BootStrapFile |
723 |
+ |
|
724 |
+ |
project_version: |
725 |
+ |
Only for use with a database label |
726 |
+ |
|
727 |
+ |
-d install_area: |
728 |
+ |
Indicate a project installation area into which the new |
729 |
+ |
project area should appear. Default is the current working |
730 |
+ |
directory. |
731 |
+ |
|
732 |
+ |
-n directory_name: |
733 |
+ |
Specify the name of the SCRAM development area you wish to |
734 |
+ |
create. |
735 |
+ |
|
736 |
+ |
ENDTEXT |
737 |
+ |
} |
738 |
+ |
|
739 |
+ |
sub help_version { |
740 |
+ |
print <<ENDTEXT; |
741 |
+ |
With now $bold[version] $normal argument given, this command will simply |
742 |
+ |
print to standard output the current version number. |
743 |
+ |
|
744 |
+ |
Providing a version argument will cause that version to be downloaded and |
745 |
+ |
installed, if not already locally available. |
746 |
+ |
[Coming soon: When available locally, your current development area will |
747 |
+ |
then be associated with the specified scram version rather than the default] |
748 |
+ |
|
749 |
+ |
|
750 |
+ |
Usage: |
751 |
+ |
$bold scram version [version]$normal |
752 |
+ |
|
753 |
+ |
ENDTEXT |
754 |
+ |
} |
755 |
+ |
|
756 |
+ |
sub help_arch { |
757 |
+ |
print <<ENDTEXT; |
758 |
+ |
Print out the architecture flag for the current machine. |
759 |
+ |
|
760 |
+ |
Usage: |
761 |
+ |
$bold scram arch $normal |
762 |
+ |
ENDTEXT |
763 |
+ |
} |
764 |
+ |
|
765 |
+ |
sub help_runtime { |
766 |
+ |
print <<ENDTEXT; |
767 |
+ |
Echo to Standard Output the Runtime Environment for the current development area |
768 |
+ |
Output available in csh or sh flavours |
769 |
+ |
|
770 |
+ |
Usage: |
771 |
+ |
$bold scram runtime [-csh|-sh] $normal |
772 |
+ |
|
773 |
+ |
Examples: |
774 |
+ |
|
775 |
+ |
Setup the current environment to include the project Runtime Environment |
776 |
+ |
in a csh environment |
777 |
+ |
|
778 |
+ |
$bold eval `scram runtime -csh` $normal |
779 |
+ |
|
780 |
+ |
Setup the current environment to include the project Runtime Environment in a |
781 |
+ |
sh environment |
782 |
+ |
|
783 |
+ |
$bold eval `scram runtime -sh` $normal |
784 |
+ |
|
785 |
+ |
|
786 |
+ |
ENDTEXT |
787 |
+ |
} |