1 |
< |
#!/usr/local/bin/perl5 -I$ENV{SCRAM_HOME}/src |
1 |
> |
#!/usr/local/bin/perl5 |
2 |
|
# |
3 |
|
# User Interface |
4 |
|
# |
5 |
+ |
# Make sure were running the right version |
6 |
+ |
versioncheck(); |
7 |
|
|
8 |
|
$inputcmd=shift; |
9 |
|
$found='false'; |
10 |
< |
@allowed_commands=qw(project build env install version list arch); |
11 |
< |
|
12 |
< |
foreach $command ( @allowed_commands ) { |
13 |
< |
do { &$command; $found='true'; last;} if ( $inputcmd=~/^$command\Z/i); |
10 |
> |
$bold = "\033[1m"; |
11 |
> |
$rv=0; |
12 |
> |
$normal = "\033[0m"; |
13 |
> |
@allowed_commands=qw(project build install version list arch setup runtime db); |
14 |
> |
@dev_cmds=qw(devtest); |
15 |
> |
|
16 |
> |
if ( $inputcmd ne "" ) { |
17 |
> |
foreach $command ( (@allowed_commands,@dev_cmds) ) { |
18 |
> |
if ( $command=~/^$inputcmd/i) { |
19 |
> |
# Deal with a help request |
20 |
> |
do{ helpheader($command); |
21 |
> |
&{"help_".$command}; exit; } if $ARGV[0]=~/help/i; |
22 |
> |
$rv=&$command; $found='true'; |
23 |
> |
last; |
24 |
> |
} |
25 |
> |
} |
26 |
|
} |
27 |
|
|
28 |
|
if ( ! ( $found=~/true/ ) ) { |
29 |
< |
print "scram help\n--------\n"; |
16 |
< |
print "Recognised Commands: \n"; |
29 |
> |
helpheader('Recognised Commands'); |
30 |
|
foreach $command ( @allowed_commands ) { |
31 |
< |
print " ".$command."\n"; |
31 |
> |
print " $bold scram ".$command.$normal."\n"; |
32 |
> |
} |
33 |
> |
print "\n"; |
34 |
> |
print "Help on individual commands available through\n\n"; |
35 |
> |
print "$bold scram".$normal." command$bold help $normal\n\n"; |
36 |
> |
} |
37 |
> |
exit $rv; |
38 |
> |
|
39 |
> |
sub versioncheck { |
40 |
> |
my $version; |
41 |
> |
my $thisversion; |
42 |
> |
|
43 |
> |
$thisversion=getversion(); |
44 |
> |
|
45 |
> |
if ( @_ ) { |
46 |
> |
$version=shift; |
47 |
> |
} |
48 |
> |
else { |
49 |
> |
if ( ! localtop_find() ) { |
50 |
> |
LoadEnvFile(); |
51 |
> |
my $versionfile=$ENV{LOCALTOP}."/$ENV{projconfigdir}/scram_version"; |
52 |
> |
if ( -f $versionfile ) { |
53 |
> |
open (VERSION, "<".$versionfile); |
54 |
> |
$version=<VERSION>; |
55 |
> |
chomp $version; |
56 |
> |
} |
57 |
> |
} |
58 |
> |
} |
59 |
> |
if ( defined $version ) { |
60 |
> |
if ( $version ne $thisversion ) { |
61 |
> |
# first try to use the correct version |
62 |
> |
if ( -d $scram_top."/".$version ) { |
63 |
> |
$ENV{SCRAM_HOME}=$scram_top."/".$version; |
64 |
> |
my $rv=system("scram", @ARGV)/256; |
65 |
> |
exit $rv; |
66 |
> |
} |
67 |
> |
else { # if not then simply warn |
68 |
> |
print "******* Warning : scram version inconsistent ********\n"; |
69 |
> |
print "This version: $thisversion; Required version: $version"; |
70 |
> |
print "*****************************************************\n"; |
71 |
> |
print "\n"; |
72 |
> |
} |
73 |
> |
} |
74 |
|
} |
75 |
|
} |
76 |
|
|
77 |
+ |
sub help_build { |
78 |
+ |
&build; |
79 |
+ |
} |
80 |
|
sub build { |
81 |
|
# is this a based or free release? |
82 |
|
FullEnvInit(); |
83 |
< |
use BuildSetup; |
84 |
< |
BuildSetup($ENV{THISDIR},@ARGV); |
85 |
< |
# system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV); |
83 |
> |
use BuildSystem::BuildSetup; |
84 |
> |
$ENV{MAKETARGETS}=join ' ',@ARGV; |
85 |
> |
my $bs=BuildSystem::BuildSetup->new(); |
86 |
> |
$rv=$bs->BuildSetup($ENV{THISDIR},@ARGV); |
87 |
> |
$rv; |
88 |
|
} |
89 |
|
|
90 |
|
sub project { |
91 |
< |
my $project=shift @ARGV; |
92 |
< |
my $version=shift @ARGV; |
91 |
> |
my @args=@ARGV; |
92 |
> |
# process options |
93 |
> |
while ( $args[0]=~"^-" ) { |
94 |
> |
if ( $args[0]=~/-n/ ) { |
95 |
> |
shift @args; |
96 |
> |
$ENV{devareaname}=shift @args; |
97 |
> |
} |
98 |
> |
elsif ( $args[0]=~/-d/ ) { #installation area directory |
99 |
> |
shift @args; |
100 |
> |
chdir $args[0]; |
101 |
> |
shift @args; |
102 |
> |
} |
103 |
> |
else { |
104 |
> |
print "scram: unknown option $args[0] to project command\n"; |
105 |
> |
exit 1; |
106 |
> |
} |
107 |
> |
} |
108 |
> |
my $project=shift @args; |
109 |
> |
my $version=shift @args; |
110 |
> |
|
111 |
> |
# quick scram version check (hack) - |
112 |
|
environmentinit(); |
113 |
+ |
my $pjurl="$project\?\?$version"; |
114 |
+ |
require Utilities::urlhandler; |
115 |
+ |
my $bsfile=urlhandler::urlhandler($pjurl); |
116 |
+ |
my $local=0; |
117 |
+ |
my $config; |
118 |
+ |
if ( ($dir)=($bsfile=~/(.*)\/InstallFile$/) ) { # -- we have a dev area |
119 |
+ |
require Configuration::ConfigArea; |
120 |
+ |
$config=Configuration::ConfigArea->new(); |
121 |
+ |
$local=1; |
122 |
+ |
$config->bootstrapfromlocation($dir); |
123 |
+ |
unshift @ARGV, "project"; |
124 |
+ |
versioncheck($config->scramversion()); |
125 |
+ |
} |
126 |
+ |
|
127 |
|
use File::Copy; |
128 |
|
use Utilities::AddDir; |
129 |
|
|
37 |
– |
print "Warning : - you are entering a development zone.". |
38 |
– |
" Don't complain if it don't work\n"; |
130 |
|
use BootStrapProject; |
131 |
|
# get the bootstrap files downloaded |
132 |
< |
BootStrapProject("$project\?\?$version"); |
132 |
> |
BootStrapProject($pjurl); |
133 |
> |
|
134 |
|
# Go setup the rest of the environement, now we can |
135 |
|
chdir $ENV{LOCALTOP}; |
136 |
< |
&localtop; |
136 |
> |
&localtop; |
137 |
|
LoadEnvFile(); |
138 |
+ |
|
139 |
|
# |
140 |
|
# Now create the directories specified in the interface |
141 |
|
# |
142 |
|
foreach $key ( keys %ENV ) { |
143 |
|
if ( $key=~/^INT/ ) { |
144 |
< |
adddir($ENV{$key}); |
144 |
> |
AddDir::adddir($ENV{$key}); |
145 |
|
} |
146 |
|
} |
147 |
< |
use clientfile; |
148 |
< |
BuildClientFile( $ENV{SCRAM_ProjReqsDoc} ); |
147 |
> |
if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) { |
148 |
> |
AddDir::copydir("$ENV{RELEASETOP}/$ENV{projconfigdir}", |
149 |
> |
"$ENV{LOCALTOP}/$ENV{projconfigdir}"); |
150 |
> |
} |
151 |
> |
|
152 |
> |
require BuildSystem::Requirements; |
153 |
> |
my $req=_requirements(); |
154 |
> |
|
155 |
> |
$req->download(toolbox()); |
156 |
> |
if ( ! $local ) { |
157 |
> |
$req->setup(toolbox()); |
158 |
> |
} |
159 |
> |
else { |
160 |
> |
AddDir::copydir($config->location()."/".$ENV{SCRAM_ARCH}, |
161 |
> |
$ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH}); |
162 |
> |
} |
163 |
> |
use Cwd; |
164 |
> |
print "\nInstallation Procedure Complete. \n". |
165 |
> |
"Installation Located at:\n".cwd()."\n"; |
166 |
> |
} |
167 |
> |
|
168 |
> |
sub _requirements { |
169 |
> |
if ( ! defined $reqsobj ) { |
170 |
> |
require BuildSystem::Requirements; |
171 |
> |
$reqsobj=BuildSystem::Requirements->new($ENV{SCRAM_ProjReqsDoc}); |
172 |
> |
} |
173 |
> |
return $reqsobj; |
174 |
> |
} |
175 |
> |
|
176 |
> |
sub runtime { |
177 |
> |
my $shell; |
178 |
> |
require Runtime; |
179 |
> |
|
180 |
> |
# process options |
181 |
> |
while ( $ARGV[0]=~"^-" ) { |
182 |
> |
if ( $ARGV[0]=~/-sh/ ) { |
183 |
> |
shift @ARGV; |
184 |
> |
$shell="sh"; |
185 |
> |
next; |
186 |
> |
} |
187 |
> |
if ( $ARGV[0]=~/-csh/ ) { #installation area directory |
188 |
> |
shift @ARGV; |
189 |
> |
$shell="csh"; |
190 |
> |
next; |
191 |
> |
} |
192 |
> |
print "Unknown Option $ARGV[0]\n"; |
193 |
> |
exit 1; |
194 |
> |
} |
195 |
> |
|
196 |
> |
FullEnvInit(); |
197 |
> |
if ( @ARGV ) { |
198 |
> |
my $runtime=Runtime->new(); |
199 |
> |
my $arg=shift @ARGV; |
200 |
> |
|
201 |
> |
my $info=0; |
202 |
> |
if ( $arg eq "info" ) { |
203 |
> |
$arg=shift @ARGV; |
204 |
> |
$info=1; |
205 |
> |
} |
206 |
> |
|
207 |
> |
# --- determine filename |
208 |
> |
my $filename; |
209 |
> |
if ( -f $arg ) { # Is it a file? |
210 |
> |
$filename=$arg; |
211 |
> |
} |
212 |
> |
else { |
213 |
> |
# -- lets see if its a BuildFile location |
214 |
> |
$filename=_testfile($ENV{LOCALTOP}."/src/".$arg, |
215 |
> |
$ENV{RELEASETOP}."/src/".$arg, |
216 |
> |
$ENV{LOCALTOP}."/src/".$arg."/BuildFile", |
217 |
> |
$ENV{RELEASETOP}."/src/".$arg."/BuildFile"); |
218 |
> |
if ( $filename eq "" ) { |
219 |
> |
print "Unable to find a file (or BuildFile) relating to ". |
220 |
> |
$arg."\n"; |
221 |
> |
exit 1; |
222 |
> |
} |
223 |
> |
} |
224 |
> |
$runtime->file($filename); |
225 |
> |
if ( ! $info ) { |
226 |
> |
$runtime->printenv($shell); |
227 |
> |
} |
228 |
> |
else { |
229 |
> |
if ( @ARGV ) { #do we have a specific variable request? |
230 |
> |
_printvardoc($runtime,shift @ARGV); |
231 |
> |
} |
232 |
> |
else { |
233 |
> |
foreach $var ( $runtime->list() ) { |
234 |
> |
_printvardoc($runtime,$var); |
235 |
> |
} |
236 |
> |
} |
237 |
> |
} |
238 |
> |
undef $runtime; |
239 |
> |
} |
240 |
> |
else { |
241 |
> |
FullEnvInit(); |
242 |
> |
# We have to clean up from the last runtime cmd - use env history |
243 |
> |
foreach $variable ( %ENV ) { |
244 |
> |
if ( $variable=~/^SCRAMRT_(.*)/ ) { #SCRAMRT are history retaining |
245 |
> |
my $var=$1; |
246 |
> |
$ENV{$var}=~s/\Q$ENV{$variable}\E//g; |
247 |
> |
$ENV{$var}=~s/^:*//; # Deal with any Path variables |
248 |
> |
#print "$variable : $ENV{$variable} \n$var : $ENV{$var}\n"; |
249 |
> |
delete $ENV{$variable}; |
250 |
> |
} |
251 |
> |
} |
252 |
> |
|
253 |
> |
# -- Set SCRAM release area paths |
254 |
> |
addpath("LD_LIBRARY_PATH","$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}"); |
255 |
> |
addpath("LD_LIBRARY_PATH","$ENV{RELEASETOP}/lib/$ENV{SCRAM_ARCH}"); |
256 |
> |
|
257 |
> |
# -- get the tool runtime environments |
258 |
> |
my $toolbox=toolbox(); |
259 |
> |
foreach $toolpair ( $toolbox->tools() ) { |
260 |
> |
# TODO - check for doubles |
261 |
> |
$tool=$toolbox->gettool($$toolpair[0]); |
262 |
> |
|
263 |
> |
if ( defined $tool ) { |
264 |
> |
# -- get runtime paths |
265 |
> |
foreach $f ( $tool->listtype("runtime_path")) { |
266 |
> |
foreach $val ( $tool->getfeature($f) ) { |
267 |
> |
addpath($f,$val); |
268 |
> |
} |
269 |
> |
} |
270 |
> |
# -- get runtime vars |
271 |
> |
foreach $f ( $tool->listtype("runtime")) { |
272 |
> |
foreach $val ( $tool->getfeature($f) ) { |
273 |
> |
$EnvRuntime{$f}=$val; |
274 |
> |
} |
275 |
> |
} |
276 |
> |
} |
277 |
> |
} |
278 |
> |
|
279 |
> |
addpath("PATH","$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}"); |
280 |
> |
addpath("PATH","$ENV{RELEASETOP}/bin/$ENV{SCRAM_ARCH}"); |
281 |
> |
|
282 |
> |
# Now get the general project environment |
283 |
> |
open ( SCRAMENV, "<$ENV{LOCALTOP}/$ENV{projconfigdir}/Runtime" ); |
284 |
> |
while ( <SCRAMENV> ) { |
285 |
> |
chomp; |
286 |
> |
next if /^#/; |
287 |
> |
next if /^\s*$/; |
288 |
> |
($name, $value)=split /=/; |
289 |
> |
addvar($name, (eval $value)," "); |
290 |
> |
} |
291 |
> |
close SCRAMENV; |
292 |
> |
|
293 |
> |
# create new SCRAMRT history vars. |
294 |
> |
foreach $variable ( keys %EnvRuntime ) { |
295 |
> |
printoutenv($shell,"SCRAMRT_$variable",$EnvRuntime{$variable}); |
296 |
> |
#addvar("SCRAMRT_$variable", $EnvRuntime{$variable}, ""); |
297 |
> |
} |
298 |
> |
# Now adapt as necessary - include base environment as well |
299 |
> |
if ( exists $ENV{LD_LIBRARY_PATH} ) { |
300 |
> |
addpath("LD_LIBRARY_PATH","$ENV{LD_LIBRARY_PATH}"); |
301 |
> |
} |
302 |
> |
if ( exists $ENV{MANPATH} ) { |
303 |
> |
addpath("MANPATH","$ENV{MANPATH}"); |
304 |
> |
} |
305 |
> |
addpath("PATH","$ENV{PATH}"); |
306 |
> |
# Print out as reqd |
307 |
> |
foreach $variable ( keys %EnvRuntime ) { |
308 |
> |
printoutenv($shell,$variable,$EnvRuntime{$variable}); |
309 |
> |
} |
310 |
> |
} |
311 |
|
} |
312 |
+ |
|
313 |
+ |
# Support rt for runtime |
314 |
+ |
|
315 |
+ |
sub _testfile { |
316 |
+ |
my @files=@_; |
317 |
+ |
|
318 |
+ |
my $filename=""; |
319 |
+ |
foreach $file ( @files ) { |
320 |
+ |
if ( -f $file ) { |
321 |
+ |
$filename=$file; |
322 |
+ |
last; |
323 |
+ |
} |
324 |
+ |
} |
325 |
+ |
return $filename; |
326 |
+ |
} |
327 |
+ |
|
328 |
+ |
sub _printvardoc { |
329 |
+ |
my $runtime=shift; |
330 |
+ |
my $var=shift; |
331 |
+ |
|
332 |
+ |
print $var." :\n"; |
333 |
+ |
print $runtime->doc($var); |
334 |
+ |
print "\n"; |
335 |
+ |
} |
336 |
+ |
|
337 |
+ |
sub printoutenv { |
338 |
+ |
my $shell=shift; |
339 |
+ |
my $variable=shift; |
340 |
+ |
my $value=shift; |
341 |
+ |
|
342 |
+ |
if ( $shell eq "csh" ) { |
343 |
+ |
print "setenv $variable \"$value\";\n"; |
344 |
+ |
} |
345 |
+ |
elsif ( $shell eq "sh" ) { |
346 |
+ |
print "$variable=\"$value\";\n"; |
347 |
+ |
print "export $variable;\n"; |
348 |
+ |
} |
349 |
+ |
} |
350 |
+ |
|
351 |
+ |
sub addpath { |
352 |
+ |
my $name=shift; |
353 |
+ |
my $val=shift; |
354 |
+ |
|
355 |
+ |
my $n; |
356 |
+ |
my @env; |
357 |
+ |
@env=split /:/, $EnvRuntime{$name}; |
358 |
+ |
foreach $n ( (split /:/, $val ) ){ |
359 |
+ |
if ( ! grep /^\Q$n\E$/, @env ) { |
360 |
+ |
addvar($name,$n,":"); |
361 |
+ |
} |
362 |
+ |
} |
363 |
+ |
} |
364 |
+ |
|
365 |
+ |
sub addvar { |
366 |
+ |
my $name=shift; |
367 |
+ |
my $val=shift; |
368 |
+ |
my $sep=shift; |
369 |
+ |
|
370 |
+ |
if ( $val ne "" ) { |
371 |
+ |
if ( defined $EnvRuntime{$name} ) { |
372 |
+ |
$EnvRuntime{$name}=$EnvRuntime{$name}.$sep.$val; |
373 |
+ |
} |
374 |
+ |
else { |
375 |
+ |
$EnvRuntime{$name}=$val; |
376 |
+ |
} |
377 |
+ |
} |
378 |
+ |
} |
379 |
+ |
|
380 |
|
sub FullEnvInit { |
381 |
|
environmentinit(); |
382 |
|
localtop(); |
389 |
|
my $value; |
390 |
|
|
391 |
|
$ENV{LatestBuildFile}=""; # stop recursive behaviour in make |
392 |
< |
setarch(); |
392 |
> |
setarchitecture::setarch(); |
393 |
|
$ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}"; |
394 |
|
$ENV{INTlib}="lib/$ENV{SCRAM_ARCH}"; |
395 |
|
$ENV{INTsrc}="src"; |
396 |
|
$ENV{INTbin}="bin/$ENV{SCRAM_ARCH}"; |
397 |
|
$ENV{INTlog}="logs"; |
398 |
|
|
399 |
< |
if ( ! ( exists $ENV{SCRAM_HOME}) ){ |
400 |
< |
$ENV{SCRAM_HOME}="/afs/cern.ch/user/w/williamc/public/ConfigMan"; |
401 |
< |
print "Warning : Environment Variable SCRAM_HOME not set.\n"; |
79 |
< |
print "Defaulting to $ENV{SCRAM_HOME}\n"; |
80 |
< |
} |
81 |
< |
if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){ |
82 |
< |
$ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/Configuration"; |
399 |
> |
($ENV{SCRAM_BASEDIR}=$ENV{SCRAM_HOME})=~s/(.*)\/.*/$1/; |
400 |
> |
if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){ |
401 |
> |
$ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration"; |
402 |
|
} |
403 |
|
if ( ! ( exists $ENV{TOOL_HOME} ) ){ |
404 |
< |
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/toolbox"; |
404 |
> |
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src"; |
405 |
|
} |
406 |
|
if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){ |
407 |
< |
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup"; |
407 |
> |
if ( -d "$ENV{SCRAM_BASEDIR}/scramdb/" ) { |
408 |
> |
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_BASEDIR}/scramdb/project.lookup"; |
409 |
> |
} |
410 |
> |
else { |
411 |
> |
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup"; |
412 |
> |
} |
413 |
|
} |
414 |
+ |
$ENV{SCRAM_AVAILDIRS}=""; |
415 |
+ |
$ENV{SCRAM_AVAILFILES}=""; |
416 |
|
} |
417 |
|
|
418 |
< |
sub localtop { |
418 |
> |
sub localtop_find { |
419 |
|
# find localtop |
420 |
|
use Cwd; |
421 |
|
my $thispath=cwd; |
422 |
+ |
my $rv=1; |
423 |
+ |
|
424 |
|
block: { |
425 |
|
do { |
426 |
|
if ( -e "$thispath/.SCRAM" ) { |
427 |
|
$ENV{LOCALTOP}=$thispath; |
428 |
+ |
$ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM"; |
429 |
+ |
$rv=0; |
430 |
|
last block; |
431 |
|
} |
432 |
|
} while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./ ); |
433 |
+ |
} #end block |
434 |
+ |
return $rv; |
435 |
+ |
} |
436 |
+ |
|
437 |
+ |
sub localtop { |
438 |
+ |
localtop_find(); |
439 |
|
if ( ! (defined $ENV{LOCALTOP}) ) { |
440 |
|
print "Unable to locate the top of local release. Exiting\n"; |
441 |
< |
exit 1 |
441 |
> |
exit 1; |
442 |
|
} |
443 |
< |
} #end block |
108 |
< |
($ENV{THISDIR}=cwd)=~s/^$ENV{LOCALTOP}//; |
443 |
> |
($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//; |
444 |
|
$ENV{THISDIR}=~s/^\///; |
110 |
– |
$ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM"; |
445 |
|
} |
446 |
|
|
447 |
|
sub LoadEnvFile { |
461 |
|
print "Sorry - Not yet\n"; |
462 |
|
} |
463 |
|
|
464 |
+ |
sub devtest { |
465 |
+ |
require Utilities::TestClass; |
466 |
+ |
my $class=shift @ARGV; |
467 |
+ |
|
468 |
+ |
my $tester; |
469 |
+ |
my $path; |
470 |
+ |
|
471 |
+ |
#_initproject(); |
472 |
+ |
if ( $class=~/::/ ) { |
473 |
+ |
($path=$class)=~s/(.*)::.*/$1/; |
474 |
+ |
} |
475 |
+ |
$tester=Utilities::TestClass->new($class, |
476 |
+ |
"$ENV{SCRAM_HOME}/src/$path/test/testdata"); |
477 |
+ |
$tester->dotest(@_); |
478 |
+ |
} |
479 |
+ |
|
480 |
|
# |
481 |
|
# Create a lookup tag in the site database |
482 |
|
# |
485 |
|
my $version=shift @ARGV; |
486 |
|
|
487 |
|
# create database entry |
138 |
– |
do { &help_install; } if $tagname=~/help/i; |
488 |
|
&FullEnvInit; |
489 |
|
if ( $version eq "" ) { |
490 |
|
$version=$ENV{SCRAM_PROJVERSION}; |
492 |
|
if ( $tagname eq "" ) { |
493 |
|
$tagname=$ENV{SCRAM_PROJECTNAME}; |
494 |
|
} |
495 |
< |
my $filename="$ENV{SCRAM_CONFIG}/project.lookup"; |
496 |
< |
my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp"; |
495 |
> |
my $filename=$ENV{SCRAM_LOOKUPDB}; |
496 |
> |
my $outfile=$ENV{SCRAM_LOOKUPDB}.".tmp"; |
497 |
|
open ( LOCALLOOKUPDB, "<$filename" ); |
498 |
< |
open ( OUTFILE , ">$outfile" ); |
498 |
> |
open ( OUTFILE , ">$outfile" ) or die "Unable to open $outfile $!\n"; |
499 |
|
while ( <LOCALLOOKUPDB> ) { |
500 |
|
if ( /^$tagname/ ) { |
501 |
|
print "Related tag :".$_."\n"; |
522 |
|
close LOCALLOOKUPDB; |
523 |
|
copy ( "$outfile", "$filename" ) |
524 |
|
|| die "Unable to copy $! \n"; |
525 |
+ |
&align; |
526 |
+ |
} |
527 |
|
|
528 |
+ |
# |
529 |
+ |
# align variables with actual location of release |
530 |
+ |
# |
531 |
+ |
|
532 |
+ |
sub align { |
533 |
+ |
&localtop; |
534 |
+ |
LoadEnvFile(); |
535 |
+ |
|
536 |
+ |
use File::Copy; |
537 |
+ |
rename( "$ENV{SCRAM_WORKDIR}/Environment", |
538 |
+ |
"$ENV{SCRAM_WORKDIR}/Environment.bak"); |
539 |
+ |
open ( SCRAMENV, "<$ENV{SCRAM_WORKDIR}/Environment.bak" ) || |
540 |
+ |
die "Cant find Environment file $!\n"; |
541 |
+ |
open ( SCRAMENVOUT, ">$ENV{SCRAM_WORKDIR}/Environment" ) || |
542 |
+ |
die "Cant Open Environment file $!\n"; |
543 |
+ |
while ( <SCRAMENV> ) { |
544 |
+ |
$_=~s/\Q$ENV{RELEASETOP}\L/$ENV{LOCALTOP}/g; |
545 |
+ |
print SCRAMENVOUT $_; |
546 |
+ |
} |
547 |
+ |
close SCRAMENV; |
548 |
+ |
close SCRAMENVOUT; |
549 |
|
} |
550 |
|
|
551 |
|
sub help_install() { |
552 |
|
|
181 |
– |
helpheader("install"); |
553 |
|
print <<ENDTEXT; |
554 |
|
Associates a label with the current release in the SCRAM database. |
555 |
|
This allows other users to refer to a centrally installed project by |
557 |
|
|
558 |
|
Usage: |
559 |
|
|
560 |
< |
scram install [[label] [version]] |
560 |
> |
$bold scram install $normal [project_tag [version_tag]] |
561 |
|
|
562 |
< |
label : override default label (the project name of the current release) |
563 |
< |
version : the version tag of the current release. If version is not |
562 |
> |
porject_tag : override default label (the project name of the current release) |
563 |
> |
version_tag : the version tag of the current release. If version is not |
564 |
|
specified the base release version will be taken by default. |
565 |
|
|
566 |
|
ENDTEXT |
196 |
– |
exit; |
567 |
|
} |
568 |
|
|
569 |
|
sub helpheader ($label) { |
575 |
|
ENDTEXT |
576 |
|
} |
577 |
|
|
578 |
+ |
sub getversion { |
579 |
+ |
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///; |
580 |
+ |
$scram_top=$1; |
581 |
+ |
$scram_version=$thisversion; |
582 |
+ |
# deal with links |
583 |
+ |
my $version=readlink $ENV{SCRAM_HOME}; |
584 |
+ |
if ( defined $version) { |
585 |
+ |
$scram_version=$version; |
586 |
+ |
} |
587 |
+ |
return $scram_version; |
588 |
+ |
} |
589 |
+ |
|
590 |
|
sub version { |
591 |
< |
print "Scram version : prototype\n"; |
591 |
> |
my $version=shift @ARGV; |
592 |
> |
my $thisversion; |
593 |
> |
my $scram_top; |
594 |
> |
my $cvsobject; |
595 |
> |
|
596 |
> |
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///; |
597 |
> |
$scram_top=$1; |
598 |
> |
if ( $version eq "" ) { |
599 |
> |
print "$thisversion"; |
600 |
> |
# deal with links |
601 |
> |
$version=readlink $ENV{SCRAM_HOME}; |
602 |
> |
if ( defined $version) { |
603 |
> |
print " ---> $version"; |
604 |
> |
} |
605 |
> |
print "\n"; |
606 |
> |
} |
607 |
> |
else { |
608 |
> |
if ( -d $scram_top."/".$version ) { |
609 |
> |
print "Version $version exists\n"; |
610 |
> |
} |
611 |
> |
else { |
612 |
> |
print "Version $version not available locally\n"; |
613 |
> |
print "Attempting download from the SCRAM repository\n"; |
614 |
> |
# set up and configure the cvs module for SCRAM |
615 |
> |
use Utilities::cvsmodule; |
616 |
> |
$cvsobject=cvsmodule->new(); |
617 |
> |
$cvsobject->set_base( |
618 |
> |
"cmscvs.cern.ch:/cvs_server/repositories/SCRAM"); |
619 |
> |
$cvsobject->set_auth("pserver"); |
620 |
> |
$cvsobject->set_user("anonymous"); |
621 |
> |
$cvsobject->set_passkey("AA_:yZZ3e"); |
622 |
> |
# Now check it out in the right place |
623 |
> |
chdir $scram_top or die "Unable to change to $scram_top $!\n"; |
624 |
> |
$cvsobject->invokecvs( ( split / /, |
625 |
> |
"co -d $version -r $version SCRAM" )); |
626 |
> |
|
627 |
> |
# Get rid of cvs object now weve finished |
628 |
> |
$cvsobject=undef; |
629 |
> |
print "\n"; |
630 |
> |
} |
631 |
> |
} |
632 |
> |
0; |
633 |
|
} |
634 |
|
|
635 |
|
sub list { |
636 |
|
&environmentinit; |
637 |
< |
my $filename="$ENV{SCRAM_CONFIG}/project.lookup"; |
638 |
< |
open ( LOCALLOOKUPDB, "<$filename" ); |
637 |
> |
my $filename="$ENV{SCRAM_LOOKUPDB}"; |
638 |
> |
if ( ! -f $ENV{SCRAM_LOOKUPDB} ) { |
639 |
> |
print "No installation database available - perhaps no projects". |
640 |
> |
" have been installed locally\n"; |
641 |
> |
exit 1; |
642 |
> |
} |
643 |
|
print "Installed Projects\n"; |
644 |
|
print "------------------\n"; |
645 |
|
print "|Project Name | Project Version |\n"; |
646 |
|
print "----------------------------------\n"; |
647 |
< |
while ( <LOCALLOOKUPDB> ) { |
648 |
< |
( $name, $version, $type, $url ) = split ":", $_; |
647 |
> |
listdb($filename); |
648 |
> |
} |
649 |
> |
|
650 |
> |
sub db { |
651 |
> |
my $subcmd=shift @ARGV; |
652 |
> |
&environmentinit; |
653 |
> |
|
654 |
> |
switch : { |
655 |
> |
if ( $subcmd eq 'link' ) { |
656 |
> |
dblink($ENV{SCRAM_LOOKUPDB},@ARGV); |
657 |
> |
last switch; |
658 |
> |
} |
659 |
> |
if ( ! -f $ENV{SCRAM_LOOKUPDB} ) { |
660 |
> |
print "No installation database available - perhaps no projects". |
661 |
> |
"have been installed locally\n"; |
662 |
> |
exit 1; |
663 |
> |
} |
664 |
> |
if ( $subcmd eq 'unlink' ) { |
665 |
> |
dbunlink($ENV{SCRAM_LOOKUPDB},@ARGV); |
666 |
> |
last switch; |
667 |
> |
} |
668 |
> |
if ( $subcmd eq 'showlinks' ) { |
669 |
> |
dblinklist($ENV{SCRAM_LOOKUPDB}); |
670 |
> |
last switch; |
671 |
> |
} |
672 |
> |
} # end switch |
673 |
> |
|
674 |
> |
} |
675 |
> |
|
676 |
> |
sub dblinklist { |
677 |
> |
my $filename=shift; |
678 |
> |
open (LOCALLOOKUPDB, "<$filename") or |
679 |
> |
die "Unable to open local database $!"; |
680 |
> |
while (<LOCALLOOKUPDB>) { |
681 |
> |
if ( $_=~/\!DB (.*)/) { |
682 |
> |
print $1,"\n"; |
683 |
> |
} |
684 |
> |
} |
685 |
> |
close LOCALLOOKUPDB; |
686 |
> |
} |
687 |
> |
|
688 |
> |
sub dblink { |
689 |
> |
my $filename=shift; |
690 |
> |
my $newdbfilename=shift; |
691 |
> |
my $exists=0; |
692 |
> |
|
693 |
> |
if ( -e $filename ) { |
694 |
> |
if ( -e $newdbfilename ) { |
695 |
> |
# Check if its already there |
696 |
> |
open (LOCALLOOKUPDB, "<$filename") or |
697 |
> |
die "Unable to open local database $!"; |
698 |
> |
while (<LOCALLOOKUPDB>) { |
699 |
> |
if ( $_=~/\!DB $newdbfilename/ ) { |
700 |
> |
$exists=1; |
701 |
> |
last; |
702 |
> |
} |
703 |
> |
} |
704 |
> |
close LOCALLOOKUPDB; |
705 |
> |
# Add it |
706 |
> |
if ( ! $exists ) { |
707 |
> |
open (LOCALLOOKUPDB, ">>$filename") or |
708 |
> |
die "Unable to open local database $!"; |
709 |
> |
print LOCALLOOKUPDB "\!DB $newdbfilename\n"; |
710 |
> |
close LOCALLOOKUPDB; |
711 |
> |
} |
712 |
> |
} |
713 |
> |
else { |
714 |
> |
print "Unknown file $newdbfilename\n"; |
715 |
> |
exit 1; |
716 |
> |
} |
717 |
> |
} |
718 |
> |
else { |
719 |
> |
print "Unknown file $filename $!\n"; |
720 |
> |
exit 1; |
721 |
> |
} |
722 |
> |
|
723 |
> |
} |
724 |
> |
|
725 |
> |
sub dbunlink { |
726 |
> |
my $filename=shift; |
727 |
> |
my $dbfilename=shift; |
728 |
> |
if ( -e $filename ) { |
729 |
> |
# Check if its already there |
730 |
> |
open (LOCALLOOKUPDB, "<$filename") or |
731 |
> |
die "Unable to open local database $!"; |
732 |
> |
open (DBOUTFILE, ">$filename.tmp") or |
733 |
> |
die "Unable to open working file $!"; |
734 |
> |
while (<LOCALLOOKUPDB>) { |
735 |
> |
if ( $_!~/\!DB $dbfilename/ ) { |
736 |
> |
print DBOUTFILE $_; |
737 |
> |
} |
738 |
> |
} |
739 |
> |
close LOCALLOOKUPDB; |
740 |
> |
close DBOUTFILE; |
741 |
> |
use File::Copy; |
742 |
> |
rename "$filename.tmp", $filename; |
743 |
> |
} |
744 |
> |
} |
745 |
> |
|
746 |
> |
sub listdb { |
747 |
> |
my $filename=shift; |
748 |
> |
my $map; |
749 |
> |
|
750 |
> |
use FileHandle; |
751 |
> |
my $fh=FileHandle->new(); |
752 |
> |
open ( $fh, "<$filename" ); |
753 |
> |
while ( $map=<$fh> ) { |
754 |
> |
if ( $map=~/^\!DB (.*)/ ) { # Check for other DB files |
755 |
> |
my $db=$1; |
756 |
> |
if ( -f $db ) { |
757 |
> |
listdb($db); |
758 |
> |
} |
759 |
> |
next; |
760 |
> |
} |
761 |
> |
( $name, $version, $type, $url ) = split ":", $map; |
762 |
|
printf "%1s",$name; |
763 |
|
printf "%25s\n",$version; |
764 |
|
printf "--> %25s\n",$type.":".$url; |
765 |
|
} |
766 |
< |
close LOCALLOOKUPDB; |
766 |
> |
close $fh; |
767 |
> |
0; |
768 |
|
} |
769 |
|
|
770 |
|
sub arch { |
771 |
|
&environmentinit(); |
772 |
|
print "$ENV{SCRAM_ARCH}\n"; |
773 |
|
} |
774 |
+ |
|
775 |
+ |
|
776 |
+ |
# |
777 |
+ |
# Setup a new tool |
778 |
+ |
# |
779 |
+ |
|
780 |
+ |
sub setup { |
781 |
+ |
my $interactive=0; |
782 |
+ |
|
783 |
+ |
# process options |
784 |
+ |
while ( $ARGV[0]=~"^-" ) { |
785 |
+ |
if ( $ARGV[0]=~/-i/ ) { |
786 |
+ |
shift @ARGV; |
787 |
+ |
$interactive=1; |
788 |
+ |
} |
789 |
+ |
else { |
790 |
+ |
print "scram: unknown option $ARGV[0] to project command\n"; |
791 |
+ |
exit 1; |
792 |
+ |
} |
793 |
+ |
} |
794 |
+ |
|
795 |
+ |
&FullEnvInit; |
796 |
+ |
my $toolname=shift @ARGV; |
797 |
+ |
my $insert=0; |
798 |
+ |
toolbox()->interactive($interactive); |
799 |
+ |
|
800 |
+ |
if ( $ENV{SCRAM_BootStrapFiles}!~/\Q$ENV{LOCALTOP}\N\/\.SCRAM/ ) { |
801 |
+ |
$ENV{SCRAM_BootStrapFiles}="$ENV{LOCALTOP}/.SCRAM:". |
802 |
+ |
$ENV{SCRAM_BootStrapFiles}; |
803 |
+ |
} |
804 |
+ |
# If no toolname specified then its a full setup |
805 |
+ |
if ( $toolname eq "" ) { |
806 |
+ |
# -- add architecture specific directories |
807 |
+ |
use Utilities::AddDir; |
808 |
+ |
AddDir::adddir("$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}"); |
809 |
+ |
AddDir::adddir("$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}"); |
810 |
+ |
|
811 |
+ |
# -- check the releasetop area |
812 |
+ |
# if the releasetop has the files copy them |
813 |
+ |
if ( ( -d $ENV{RELEASETOP}."/.SCRAM/".$ENV{SCRAM_ARCH} ) && |
814 |
+ |
( $ENV{RELEASETOP} ne $ENV{LOCALTOP} ) ) { |
815 |
+ |
AddDir::copydir($ENV{RELEASETOP}."/.SCRAM/".$ENV{SCRAM_ARCH}, |
816 |
+ |
$ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH}); |
817 |
+ |
} |
818 |
+ |
else { #activate a full setup |
819 |
+ |
my $reqs=_requirements(); |
820 |
+ |
$reqs->setup(toolbox()); |
821 |
+ |
} |
822 |
+ |
} |
823 |
+ |
else { |
824 |
+ |
if ( my $rv=toolbox()->toolsetup($toolname,@ARGV) ) { |
825 |
+ |
if ( $rv eq 1 ) { |
826 |
+ |
print "Unknown tool $toolname @ARGV\n"; |
827 |
+ |
exit 1; |
828 |
+ |
} |
829 |
+ |
} |
830 |
+ |
} |
831 |
+ |
} |
832 |
+ |
|
833 |
+ |
# get a toolbox object for the project |
834 |
+ |
sub toolbox { |
835 |
+ |
if ( ! defined $toolbox ) { |
836 |
+ |
require BuildSystem::ToolBox; |
837 |
+ |
$toolbox=BuildSystem::ToolBox->new(); |
838 |
+ |
} |
839 |
+ |
return $toolbox; |
840 |
+ |
} |
841 |
+ |
|
842 |
+ |
sub help_db { |
843 |
+ |
print <<ENDTEXT; |
844 |
+ |
scram database administration command. |
845 |
+ |
|
846 |
+ |
Usage: |
847 |
+ |
|
848 |
+ |
$bold scram db $normal subcommand |
849 |
+ |
|
850 |
+ |
subcommands: |
851 |
+ |
link : |
852 |
+ |
Make available an additional database for |
853 |
+ |
project and list operations |
854 |
+ |
|
855 |
+ |
$bold scram db link $normal /a/directory/path/project.lookup |
856 |
+ |
|
857 |
+ |
unlink : |
858 |
+ |
Remove a database from the link list. Note this does |
859 |
+ |
not remove the database, just the link to it in scram. |
860 |
+ |
|
861 |
+ |
$bold scram db unlink $normal /a/directory/path/project.lookup |
862 |
+ |
|
863 |
+ |
showlinks : |
864 |
+ |
List the databases that are linked in |
865 |
+ |
|
866 |
+ |
ENDTEXT |
867 |
+ |
} |
868 |
+ |
|
869 |
+ |
sub help_setup { |
870 |
+ |
|
871 |
+ |
print <<ENDTEXT; |
872 |
+ |
Allows installation/re-installation of a new tool/external package into an |
873 |
+ |
already existing development area. If not toolname is specified, |
874 |
+ |
the complete installation process is initiated. |
875 |
+ |
|
876 |
+ |
Usage: |
877 |
+ |
|
878 |
+ |
$bold scram setup [-i]$normal [toolname] [[version] [url]] |
879 |
+ |
|
880 |
+ |
toolname : The name of the tool setup file required. |
881 |
+ |
version : where more than one version exists specify the version |
882 |
+ |
url : when setting up a completely new tool specify the url too |
883 |
+ |
|
884 |
+ |
The -i option turns off the automatic search mechanism allowing for more |
885 |
+ |
user interaction with the setup mechanism |
886 |
+ |
ENDTEXT |
887 |
+ |
} |
888 |
+ |
|
889 |
+ |
sub help_list { |
890 |
+ |
print <<ENDTEXT; |
891 |
+ |
List the available projects and versions installed in the local SCRAM database |
892 |
+ |
(see scram install help) |
893 |
+ |
|
894 |
+ |
Usage: |
895 |
+ |
|
896 |
+ |
$bold scram list $normal |
897 |
+ |
|
898 |
+ |
ENDTEXT |
899 |
+ |
} |
900 |
+ |
|
901 |
+ |
sub help_project { |
902 |
+ |
print <<ENDTEXT; |
903 |
+ |
Setup a new project development area. The new area will appear in the current |
904 |
+ |
working directory. |
905 |
+ |
Usage: |
906 |
+ |
|
907 |
+ |
$bold scram project [-d install_area] [-n directory_name]$normal project_url [project_version] |
908 |
+ |
|
909 |
+ |
Options: |
910 |
+ |
|
911 |
+ |
project_url: The url of a scram bootstrap file. |
912 |
+ |
Currently supported types are: |
913 |
+ |
$bold Database label $normal |
914 |
+ |
Labels can be assigned to bootstrap files for easy |
915 |
+ |
access (See "scram install" command). If you |
916 |
+ |
specify a label you must also specify a project_version. |
917 |
+ |
e.g. |
918 |
+ |
|
919 |
+ |
scram project SCRAM V1_0 |
920 |
+ |
|
921 |
+ |
scram project ORCA ORCA_1_1_1 |
922 |
+ |
|
923 |
+ |
To see the list of installed projects use the |
924 |
+ |
"scram list" command. |
925 |
+ |
|
926 |
+ |
$bold file: $normal A regular file on an accessable file system |
927 |
+ |
e.g. |
928 |
+ |
|
929 |
+ |
file:~/myprojects/projecta/config/BootStrapFile |
930 |
+ |
|
931 |
+ |
project_version: |
932 |
+ |
Only for use with a database label |
933 |
+ |
|
934 |
+ |
-d install_area: |
935 |
+ |
Indicate a project installation area into which the new |
936 |
+ |
project area should appear. Default is the current working |
937 |
+ |
directory. |
938 |
+ |
|
939 |
+ |
-n directory_name: |
940 |
+ |
Specify the name of the SCRAM development area you wish to |
941 |
+ |
create. |
942 |
+ |
|
943 |
+ |
ENDTEXT |
944 |
+ |
} |
945 |
+ |
|
946 |
+ |
sub help_version { |
947 |
+ |
print <<ENDTEXT; |
948 |
+ |
With now $bold [version] $normal argument given, this command will simply |
949 |
+ |
print to standard output the current version number. |
950 |
+ |
|
951 |
+ |
Providing a version argument will cause that version to be downloaded and |
952 |
+ |
installed, if not already locally available. |
953 |
+ |
|
954 |
+ |
|
955 |
+ |
Usage: |
956 |
+ |
$bold scram version [version]$normal |
957 |
+ |
|
958 |
+ |
ENDTEXT |
959 |
+ |
} |
960 |
+ |
|
961 |
+ |
sub help_arch { |
962 |
+ |
print <<ENDTEXT; |
963 |
+ |
Print out the architecture flag for the current machine. |
964 |
+ |
|
965 |
+ |
Usage: |
966 |
+ |
$bold scram arch $normal |
967 |
+ |
ENDTEXT |
968 |
+ |
} |
969 |
+ |
|
970 |
+ |
sub help_runtime { |
971 |
+ |
print <<ENDTEXT; |
972 |
+ |
Echo to Standard Output the Runtime Environment for the current development area |
973 |
+ |
Output available in csh or sh flavours |
974 |
+ |
|
975 |
+ |
Usage: |
976 |
+ |
1) $bold scram runtime [-csh|-sh] $normal |
977 |
+ |
or |
978 |
+ |
2) $bold scram runtime [-csh|-sh] filename $normal |
979 |
+ |
or |
980 |
+ |
3) $bold scram runtime info filename [variable]$normal |
981 |
+ |
|
982 |
+ |
1) For the general configuration environment |
983 |
+ |
2) For environment described in filename or |
984 |
+ |
areatop/src/directory/BuildFile |
985 |
+ |
3) Display information concerning the environment in the given file |
986 |
+ |
(limited to variable if specified) |
987 |
+ |
|
988 |
+ |
The file for cases 2) and 3) are searched as follows : |
989 |
+ |
a) straightforward filename |
990 |
+ |
b) filename relative to local_area/src |
991 |
+ |
c) filename relative to release_area/src |
992 |
+ |
d) BuildFile relative to local_area/src |
993 |
+ |
e) BuildFile relative to release_area/src |
994 |
+ |
|
995 |
+ |
Examples: |
996 |
+ |
|
997 |
+ |
Setup the current environment to include the project Runtime Environment |
998 |
+ |
in a csh environment |
999 |
+ |
|
1000 |
+ |
$bold eval `scram runtime -csh` $normal |
1001 |
+ |
|
1002 |
+ |
Setup the current environment to include the project Runtime Environment in a |
1003 |
+ |
sh environment |
1004 |
+ |
|
1005 |
+ |
$bold eval `scram runtime -sh` $normal |
1006 |
+ |
|
1007 |
+ |
|
1008 |
+ |
ENDTEXT |
1009 |
+ |
} |