1 |
williamc |
1.8 |
#!/usr/local/bin/perl5
|
2 |
williamc |
1.1 |
#
|
3 |
|
|
# User Interface
|
4 |
|
|
#
|
5 |
|
|
|
6 |
|
|
$inputcmd=shift;
|
7 |
|
|
$found='false';
|
8 |
williamc |
1.13 |
$bold = "\033[1m";
|
9 |
|
|
$normal = "\033[0m";
|
10 |
williamc |
1.24 |
@allowed_commands=qw(project build install version list arch setup runtime devtest);
|
11 |
williamc |
1.1 |
|
12 |
williamc |
1.21 |
if ( $inputcmd ne "" ) {
|
13 |
|
|
foreach $command ( @allowed_commands ) {
|
14 |
|
|
if ( $command=~/^$inputcmd/i) {
|
15 |
williamc |
1.13 |
# Deal with a help request
|
16 |
williamc |
1.24 |
do{ &helpheader($command);
|
17 |
williamc |
1.13 |
&{"help_".$command}; exit; } if $ARGV[0]=~/help/i;
|
18 |
|
|
&$command; $found='true';
|
19 |
|
|
last;
|
20 |
|
|
}
|
21 |
williamc |
1.21 |
}
|
22 |
williamc |
1.1 |
}
|
23 |
|
|
|
24 |
|
|
if ( ! ( $found=~/true/ ) ) {
|
25 |
williamc |
1.15 |
helpheader('Recognised Commands');
|
26 |
williamc |
1.1 |
foreach $command ( @allowed_commands ) {
|
27 |
williamc |
1.15 |
print " $bold scram ".$command.$normal."\n";
|
28 |
williamc |
1.1 |
}
|
29 |
williamc |
1.15 |
print "\n";
|
30 |
|
|
print "Help on individual commands available through\n\n";
|
31 |
|
|
print "$bold scram".$normal." command$bold help $normal\n\n";
|
32 |
williamc |
1.1 |
}
|
33 |
|
|
|
34 |
williamc |
1.24 |
sub devtest {
|
35 |
|
|
use Utilities::testclass;
|
36 |
|
|
my $class;
|
37 |
|
|
my $tester;
|
38 |
|
|
|
39 |
|
|
$class=shift @ARGV;
|
40 |
|
|
$tester=testclass->new($class);
|
41 |
|
|
$tester->dotest(@ARGV);
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
sub test_setup {
|
45 |
|
|
my $tool;
|
46 |
|
|
my $toolversion;
|
47 |
|
|
my $interactive=0;
|
48 |
|
|
my $listonly=0;
|
49 |
|
|
|
50 |
|
|
# process options
|
51 |
|
|
while ( $ARGV[0]=~"^-" ) { # turn on interactive setup mode
|
52 |
|
|
if ( $ARGV[0]=~/-i/ ) {
|
53 |
|
|
shift @ARGV;
|
54 |
|
|
$interactive=1;
|
55 |
|
|
print "Entering Interactive Setup Mode\n";
|
56 |
|
|
next;
|
57 |
|
|
}
|
58 |
|
|
if ( $ARGV[0]=~/-r/ ) {
|
59 |
|
|
shift @ARGV;
|
60 |
|
|
$listonly=1;
|
61 |
|
|
print "---------------- Project Requirements List -----------\n";
|
62 |
|
|
next;
|
63 |
|
|
}
|
64 |
|
|
print "Error : Unknown Option $ARGV[0]\n";
|
65 |
|
|
help_setup();
|
66 |
|
|
exit 1;
|
67 |
|
|
}
|
68 |
|
|
my $toolname=shift @ARGV;
|
69 |
|
|
my $version=shift @ARGV;
|
70 |
|
|
|
71 |
|
|
&FullEnvInit();
|
72 |
|
|
&RequirementsInit;
|
73 |
|
|
|
74 |
|
|
if ( $toolname ne "" ) {
|
75 |
|
|
_setuptool($interactive, $toolname, $version);
|
76 |
|
|
}
|
77 |
|
|
else {
|
78 |
|
|
$reqobj->IteratorReset;
|
79 |
|
|
while ( ( $toolname=$reqobj->IteratorNext() ) ne "" ) {
|
80 |
|
|
if ( $listonly ) {
|
81 |
|
|
print $bold.$toolname.$normal.
|
82 |
|
|
" version ".$reqobj->Version($toolname)."\n";
|
83 |
|
|
}
|
84 |
|
|
else {
|
85 |
|
|
_setuptool
|
86 |
|
|
($interactive, $toolname, $reqobj->Version("$toolname"));
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
sub _setuptool {
|
93 |
|
|
my $tool;
|
94 |
|
|
my $toolversion;
|
95 |
|
|
my $interactive=shift;
|
96 |
|
|
my $toolname=shift;
|
97 |
|
|
my $version=shift;
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
if ( ( $version eq "" ) && ( $interactive == 0 )) {
|
101 |
|
|
#if not specified set to that of req. doc
|
102 |
|
|
$version=$reqobj->Version($toolname);
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
# ideally try and download it if not already in .SCRAM
|
106 |
|
|
# Only scram toolbox files supported so far
|
107 |
|
|
if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) {
|
108 |
|
|
&urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/"
|
109 |
|
|
.$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ;
|
110 |
|
|
}
|
111 |
|
|
use ToolSetup;
|
112 |
|
|
$tool=ToolSetup->new("$ENV{LOCALTOP}/.SCRAM/$toolname");
|
113 |
|
|
|
114 |
|
|
# check we have a version
|
115 |
|
|
if ( $interactive == 0 ) {
|
116 |
|
|
$tool->UnSetInteractive();
|
117 |
|
|
}
|
118 |
|
|
else {
|
119 |
|
|
$tool->SetInteractive();
|
120 |
|
|
}
|
121 |
|
|
$tool->Setup($toolname, $version);
|
122 |
|
|
|
123 |
|
|
}
|
124 |
|
|
|
125 |
williamc |
1.14 |
sub help_build {
|
126 |
|
|
&build;
|
127 |
|
|
}
|
128 |
williamc |
1.1 |
sub build {
|
129 |
|
|
# is this a based or free release?
|
130 |
|
|
FullEnvInit();
|
131 |
|
|
use BuildSetup;
|
132 |
williamc |
1.10 |
$ENV{MAKETARGETS}=join ' ',@ARGV;
|
133 |
williamc |
1.1 |
BuildSetup($ENV{THISDIR},@ARGV);
|
134 |
|
|
# system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV);
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
sub project {
|
138 |
williamc |
1.7 |
# process options
|
139 |
|
|
while ( $ARGV[0]=~"^-" ) {
|
140 |
williamc |
1.23 |
if ( $ARGV[0]=~/-n/ ) {
|
141 |
|
|
shift @ARGV;
|
142 |
|
|
$ENV{devareaname}=shift @ARGV;
|
143 |
|
|
}
|
144 |
|
|
if ( $ARGV[0]=~/-d/ ) { #installation area directory
|
145 |
|
|
shift @ARGV;
|
146 |
williamc |
1.7 |
chdir $ARGV[0];
|
147 |
|
|
shift @ARGV;
|
148 |
|
|
}
|
149 |
|
|
}
|
150 |
williamc |
1.1 |
my $project=shift @ARGV;
|
151 |
|
|
my $version=shift @ARGV;
|
152 |
|
|
environmentinit();
|
153 |
|
|
use File::Copy;
|
154 |
williamc |
1.2 |
use Utilities::AddDir;
|
155 |
williamc |
1.1 |
|
156 |
williamc |
1.24 |
use BootStrapProject2;
|
157 |
williamc |
1.1 |
# get the bootstrap files downloaded
|
158 |
williamc |
1.24 |
# BootStrapProject("$project\?\?$version");
|
159 |
|
|
$bootstrapper->BootStrap("$project\?\?$version");
|
160 |
williamc |
1.1 |
# Go setup the rest of the environement, now we can
|
161 |
williamc |
1.23 |
chdir $ENV{LOCALTOP};
|
162 |
|
|
&localtop;
|
163 |
williamc |
1.1 |
LoadEnvFile();
|
164 |
|
|
#
|
165 |
|
|
# Now create the directories specified in the interface
|
166 |
|
|
#
|
167 |
|
|
foreach $key ( keys %ENV ) {
|
168 |
|
|
if ( $key=~/^INT/ ) {
|
169 |
williamc |
1.5 |
AddDir::adddir($ENV{$key});
|
170 |
williamc |
1.1 |
}
|
171 |
|
|
}
|
172 |
williamc |
1.6 |
if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) {
|
173 |
|
|
system("cp", "-r", "$ENV{RELEASETOP}/$ENV{projconfigdir}",
|
174 |
|
|
"$ENV{LOCALTOP}/$ENV{projconfigdir}");
|
175 |
|
|
}
|
176 |
williamc |
1.1 |
use clientfile;
|
177 |
|
|
BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
|
178 |
williamc |
1.7 |
use Cwd;
|
179 |
williamc |
1.20 |
print "\nInstallation Procedure Complete. \n".
|
180 |
|
|
"Installation Located at:\n".cwd()."\n";
|
181 |
williamc |
1.1 |
}
|
182 |
williamc |
1.7 |
|
183 |
williamc |
1.24 |
sub runtime {
|
184 |
|
|
my $shell;
|
185 |
|
|
environmentinit();
|
186 |
|
|
localtop();
|
187 |
|
|
|
188 |
|
|
# process options
|
189 |
|
|
while ( $ARGV[0]=~"^-" ) {
|
190 |
|
|
if ( $ARGV[0]=~/-sh/ ) {
|
191 |
|
|
shift @ARGV;
|
192 |
|
|
$shell="sh";
|
193 |
|
|
next;
|
194 |
|
|
}
|
195 |
|
|
if ( $ARGV[0]=~/-csh/ ) { #installation area directory
|
196 |
|
|
shift @ARGV;
|
197 |
|
|
$shell="csh";
|
198 |
|
|
next;
|
199 |
|
|
}
|
200 |
|
|
print "Unknown Option $ARGV[0]\n";
|
201 |
|
|
exit 1;
|
202 |
|
|
}
|
203 |
|
|
open (file, "$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings" )
|
204 |
|
|
or die "Unable to open file ".
|
205 |
|
|
"$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings $!";
|
206 |
|
|
while( <file> ) {
|
207 |
|
|
chomp;
|
208 |
|
|
next if /^#/;
|
209 |
|
|
next if /^\s*$/;
|
210 |
|
|
($product, $version, $type, $variable, $value, @junk)=split /:/;
|
211 |
|
|
next if ( $variable=~/\&/ );
|
212 |
|
|
if ( $type=~/^R/ ) {
|
213 |
|
|
if ( ( $type=~/path/ ) ) { #type Rtype
|
214 |
|
|
addvar($variable,$value,":"); # Colon seperated
|
215 |
|
|
}
|
216 |
|
|
else { #type R
|
217 |
|
|
addvar($variable,$value," "); # Add with spaces
|
218 |
|
|
}
|
219 |
|
|
}
|
220 |
|
|
}
|
221 |
|
|
close file;
|
222 |
|
|
addvar("LD_LIBRARY_PATH","$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}",":");
|
223 |
|
|
addvar("PATH","$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}",":");
|
224 |
|
|
# We have to clean up from the last runtime cmd - use env history
|
225 |
|
|
foreach $variable ( %ENV ) {
|
226 |
|
|
if ( $variable=~/^SCRAMRT_(.*)/ ) { #SCRAMRT are history retaining
|
227 |
|
|
$ENV{$1}=~s/\Q$ENV{$variable}\N\:*//;
|
228 |
|
|
delete $ENV{$variable};
|
229 |
|
|
}
|
230 |
|
|
}
|
231 |
|
|
# create new SCRAMRT history vars.
|
232 |
|
|
foreach $variable ( keys %EnvRuntime ) {
|
233 |
|
|
addvar("SCRAMRT_$variable", $EnvRuntime{$variable}, "");
|
234 |
|
|
}
|
235 |
|
|
# Now adapt as necessary - include base environment as well
|
236 |
|
|
addvar("LD_LIBRARY_PATH","$ENV{LD_LIBRARY_PATH}",":");
|
237 |
|
|
addvar("PATH","$ENV{PATH}",":");
|
238 |
|
|
# Print out as reqd
|
239 |
|
|
foreach $variable ( keys %EnvRuntime ) {
|
240 |
|
|
if ( $shell eq "csh" ) {
|
241 |
|
|
print "setenv $variable \"$EnvRuntime{$variable}\";\n";
|
242 |
|
|
}
|
243 |
|
|
elsif ( $shell eq "sh" ) {
|
244 |
|
|
print "export $variable=$EnvRuntime{$variable};\n";
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
# Support rt for runtime
|
250 |
|
|
sub addvar {
|
251 |
|
|
my $name=shift;
|
252 |
|
|
my $val=shift;
|
253 |
|
|
my $sep=shift;
|
254 |
|
|
|
255 |
|
|
if ( $val ne "" ) {
|
256 |
|
|
if ( defined $EnvRuntime{$name} ) {
|
257 |
|
|
$EnvRuntime{$name}=$EnvRuntime{$name}.$sep.$val;
|
258 |
|
|
}
|
259 |
|
|
else {
|
260 |
|
|
$EnvRuntime{$name}=$val;
|
261 |
|
|
}
|
262 |
|
|
}
|
263 |
|
|
}
|
264 |
|
|
|
265 |
williamc |
1.1 |
sub FullEnvInit {
|
266 |
|
|
environmentinit();
|
267 |
|
|
localtop();
|
268 |
|
|
LoadEnvFile();
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
sub environmentinit {
|
272 |
williamc |
1.2 |
use Utilities::setarchitecture;
|
273 |
williamc |
1.1 |
my $name;
|
274 |
|
|
my $value;
|
275 |
|
|
|
276 |
|
|
$ENV{LatestBuildFile}=""; # stop recursive behaviour in make
|
277 |
williamc |
1.4 |
setarchitecture::setarch();
|
278 |
williamc |
1.1 |
$ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}";
|
279 |
|
|
$ENV{INTlib}="lib/$ENV{SCRAM_ARCH}";
|
280 |
|
|
$ENV{INTsrc}="src";
|
281 |
|
|
$ENV{INTbin}="bin/$ENV{SCRAM_ARCH}";
|
282 |
|
|
$ENV{INTlog}="logs";
|
283 |
|
|
|
284 |
|
|
if ( ! ( exists $ENV{SCRAM_HOME}) ){
|
285 |
williamc |
1.8 |
$ENV{SCRAM_HOME}="/afs/cern.ch/cms/Releases";
|
286 |
williamc |
1.1 |
print "Warning : Environment Variable SCRAM_HOME not set.\n";
|
287 |
|
|
print "Defaulting to $ENV{SCRAM_HOME}\n";
|
288 |
|
|
}
|
289 |
|
|
if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){
|
290 |
williamc |
1.3 |
$ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration";
|
291 |
williamc |
1.1 |
}
|
292 |
|
|
if ( ! ( exists $ENV{TOOL_HOME} ) ){
|
293 |
williamc |
1.4 |
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
|
294 |
williamc |
1.1 |
}
|
295 |
|
|
if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){
|
296 |
|
|
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup";
|
297 |
|
|
}
|
298 |
|
|
}
|
299 |
|
|
|
300 |
|
|
sub localtop {
|
301 |
|
|
# find localtop
|
302 |
|
|
use Cwd;
|
303 |
|
|
my $thispath=cwd;
|
304 |
|
|
block: {
|
305 |
|
|
do {
|
306 |
|
|
if ( -e "$thispath/.SCRAM" ) {
|
307 |
|
|
$ENV{LOCALTOP}=$thispath;
|
308 |
|
|
last block;
|
309 |
|
|
}
|
310 |
|
|
} while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./ );
|
311 |
|
|
if ( ! (defined $ENV{LOCALTOP}) ) {
|
312 |
|
|
print "Unable to locate the top of local release. Exiting\n";
|
313 |
williamc |
1.18 |
exit 1;
|
314 |
williamc |
1.1 |
}
|
315 |
|
|
} #end block
|
316 |
williamc |
1.19 |
($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//;
|
317 |
williamc |
1.1 |
$ENV{THISDIR}=~s/^\///;
|
318 |
|
|
$ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM";
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
sub LoadEnvFile {
|
322 |
|
|
open ( SCRAMENV, "<$ENV{SCRAM_WORKDIR}/Environment" ) ||
|
323 |
|
|
die "Cant find Environment file $!\n";
|
324 |
|
|
while ( <SCRAMENV> ) {
|
325 |
|
|
chomp;
|
326 |
|
|
next if /^#/;
|
327 |
|
|
next if /^\s*$/ ;
|
328 |
|
|
($name, $value)=split /=/;
|
329 |
|
|
eval "\$ENV{${name}}=\"$value\"";
|
330 |
|
|
}
|
331 |
|
|
close SCRAMENV;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
sub env {
|
335 |
|
|
print "Sorry - Not yet\n";
|
336 |
|
|
}
|
337 |
|
|
|
338 |
williamc |
1.24 |
sub RequirementsInit {
|
339 |
|
|
use Requirements;
|
340 |
|
|
$reqobj=Requirements->new($ENV{SCRAM_ProjReqsDoc});
|
341 |
|
|
}
|
342 |
|
|
|
343 |
williamc |
1.1 |
#
|
344 |
|
|
# Create a lookup tag in the site database
|
345 |
|
|
#
|
346 |
|
|
sub install ( $tagname, $version ) {
|
347 |
|
|
my $tagname=shift @ARGV;
|
348 |
|
|
my $version=shift @ARGV;
|
349 |
|
|
|
350 |
|
|
# create database entry
|
351 |
|
|
&FullEnvInit;
|
352 |
|
|
if ( $version eq "" ) {
|
353 |
|
|
$version=$ENV{SCRAM_PROJVERSION};
|
354 |
|
|
}
|
355 |
|
|
if ( $tagname eq "" ) {
|
356 |
|
|
$tagname=$ENV{SCRAM_PROJECTNAME};
|
357 |
|
|
}
|
358 |
|
|
my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
|
359 |
|
|
my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp";
|
360 |
|
|
open ( LOCALLOOKUPDB, "<$filename" );
|
361 |
williamc |
1.16 |
open ( OUTFILE , ">$outfile" ) or die "Unable to open $outfile $!\n";
|
362 |
williamc |
1.1 |
while ( <LOCALLOOKUPDB> ) {
|
363 |
|
|
if ( /^$tagname/ ) {
|
364 |
|
|
print "Related tag :".$_."\n";
|
365 |
|
|
if ( /$version/) {
|
366 |
|
|
print "$tagname $version already exists. Overwrite (y/n)\n";
|
367 |
|
|
if ( ! (<STDIN>=~/y/i ) ) {
|
368 |
|
|
print "Aborting install ...\n";
|
369 |
|
|
close OUTFILE;
|
370 |
|
|
close LOCALLOOKUPDB;
|
371 |
|
|
exit 1;
|
372 |
|
|
}
|
373 |
|
|
}
|
374 |
|
|
else {
|
375 |
|
|
print OUTFILE $_;
|
376 |
|
|
}
|
377 |
|
|
}
|
378 |
|
|
else {
|
379 |
|
|
print OUTFILE $_;
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
print OUTFILE "$tagname:$version:file:$ENV{LOCALTOP}".
|
383 |
|
|
"/.SCRAM/InstallFile\n";
|
384 |
|
|
close OUTFILE;
|
385 |
|
|
close LOCALLOOKUPDB;
|
386 |
|
|
copy ( "$outfile", "$filename" )
|
387 |
|
|
|| die "Unable to copy $! \n";
|
388 |
|
|
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
sub help_install() {
|
392 |
|
|
|
393 |
|
|
print <<ENDTEXT;
|
394 |
|
|
Associates a label with the current release in the SCRAM database.
|
395 |
|
|
This allows other users to refer to a centrally installed project by
|
396 |
|
|
this label rather than a remote url reference.
|
397 |
|
|
|
398 |
|
|
Usage:
|
399 |
|
|
|
400 |
|
|
scram install [[label] [version]]
|
401 |
|
|
|
402 |
|
|
label : override default label (the project name of the current release)
|
403 |
|
|
version : the version tag of the current release. If version is not
|
404 |
|
|
specified the base release version will be taken by default.
|
405 |
|
|
|
406 |
|
|
ENDTEXT
|
407 |
|
|
exit;
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
sub helpheader ($label) {
|
411 |
|
|
my $label=shift;
|
412 |
|
|
print <<ENDTEXT;
|
413 |
|
|
*************************************************************************
|
414 |
|
|
SCRAM HELP --------- $label
|
415 |
|
|
*************************************************************************
|
416 |
|
|
ENDTEXT
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
sub version {
|
420 |
williamc |
1.24 |
my $version=shift @ARGV;
|
421 |
|
|
my $thisversion;
|
422 |
|
|
my $scram_top;
|
423 |
|
|
my $cvsobject;
|
424 |
|
|
|
425 |
|
|
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
|
426 |
|
|
$scram_top=$1;
|
427 |
|
|
if ( $version eq "" ) {
|
428 |
|
|
print "$thisversion\n";
|
429 |
|
|
}
|
430 |
|
|
else {
|
431 |
|
|
if ( -d $scram_top."/".$version ) {
|
432 |
|
|
print "Version $version exists\n";
|
433 |
|
|
}
|
434 |
|
|
else {
|
435 |
|
|
print "Version $version not available locally\n";
|
436 |
|
|
print "Attempting download from the SCRAM repository";
|
437 |
|
|
# set up and configure the cvs module for SCRAM
|
438 |
|
|
use Utilities::cvsmodule;
|
439 |
|
|
$cvsobject=cvsmodule->new();
|
440 |
|
|
$cvsobject->set_base(
|
441 |
|
|
"cmscvs.cern.ch:/cvs_server/repositories/SCRAM");
|
442 |
|
|
$cvsobject->set_auth("pserver");
|
443 |
|
|
$cvsobject->set_user("anonymous");
|
444 |
|
|
$cvsobject->set_passkey("AA_:yZZ3e");
|
445 |
|
|
# Now check it out in the right place
|
446 |
|
|
chdir $scram_top or die "Unable to change to $scram_top $!\n";
|
447 |
|
|
$cvsobject->invokecvs( ( split / /,
|
448 |
|
|
"co -d $version -r $version SCRAM" ));
|
449 |
|
|
|
450 |
|
|
# Get rid of cvs object now weve finished
|
451 |
|
|
$cvsobject=undef;
|
452 |
|
|
print "\n";
|
453 |
|
|
}
|
454 |
|
|
}
|
455 |
williamc |
1.1 |
}
|
456 |
|
|
|
457 |
|
|
sub list {
|
458 |
|
|
&environmentinit;
|
459 |
|
|
my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
|
460 |
|
|
open ( LOCALLOOKUPDB, "<$filename" );
|
461 |
|
|
print "Installed Projects\n";
|
462 |
|
|
print "------------------\n";
|
463 |
|
|
print "|Project Name | Project Version |\n";
|
464 |
|
|
print "----------------------------------\n";
|
465 |
|
|
while ( <LOCALLOOKUPDB> ) {
|
466 |
|
|
( $name, $version, $type, $url ) = split ":", $_;
|
467 |
|
|
printf "%1s",$name;
|
468 |
|
|
printf "%25s\n",$version;
|
469 |
|
|
printf "--> %25s\n",$type.":".$url;
|
470 |
|
|
}
|
471 |
|
|
close LOCALLOOKUPDB;
|
472 |
|
|
}
|
473 |
|
|
|
474 |
|
|
sub arch {
|
475 |
|
|
&environmentinit();
|
476 |
|
|
print "$ENV{SCRAM_ARCH}\n";
|
477 |
williamc |
1.11 |
}
|
478 |
|
|
|
479 |
williamc |
1.12 |
|
480 |
|
|
#
|
481 |
|
|
# Setup a new tool
|
482 |
|
|
#
|
483 |
|
|
|
484 |
|
|
sub setup {
|
485 |
|
|
my $toolname=shift @ARGV;
|
486 |
williamc |
1.24 |
my $insert=0;
|
487 |
williamc |
1.12 |
|
488 |
|
|
&FullEnvInit;
|
489 |
williamc |
1.24 |
if ( $ENV{SCRAM_BootStrapFiles}!~/\Q$ENV{LOCALTOP}\N\/\.SCRAM/ ) {
|
490 |
williamc |
1.12 |
$ENV{SCRAM_BootStrapFiles}="$ENV{LOCALTOP}/.SCRAM:".
|
491 |
|
|
$ENV{SCRAM_BootStrapFiles};
|
492 |
|
|
}
|
493 |
williamc |
1.24 |
my $filebase="$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}";
|
494 |
|
|
rename "$filebase/clientsettings", "$filebase/clientsettings.old";
|
495 |
|
|
chdir $ENV{LOCALTOP}; # make sure we do this from the top dir
|
496 |
williamc |
1.20 |
# If no toolname specified then its a full setup
|
497 |
|
|
if ( $toolname eq "" ) {
|
498 |
|
|
rename "$filebase/clientsettings_reqs",
|
499 |
|
|
"$filebase/clientsettings_reqs.old";
|
500 |
|
|
use clientfile;
|
501 |
|
|
BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
|
502 |
williamc |
1.24 |
# Work-around for Broken ARCH directories
|
503 |
|
|
use Utilities::AddDir;
|
504 |
|
|
AddDir::adddir("$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}");
|
505 |
|
|
AddDir::adddir("$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}");
|
506 |
williamc |
1.20 |
}
|
507 |
|
|
else {
|
508 |
|
|
# Check for the correct toolfile
|
509 |
|
|
# ideally try and download it if not already in .SCRAM
|
510 |
|
|
# Only scram toolbox files supported so far
|
511 |
|
|
if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) {
|
512 |
williamc |
1.12 |
&urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/"
|
513 |
|
|
.$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ;
|
514 |
williamc |
1.20 |
}
|
515 |
|
|
# Parse the toolfile and update the clientsettings file
|
516 |
|
|
# currently just append to the end
|
517 |
|
|
use clientfile;
|
518 |
williamc |
1.24 |
#create a new clientfile containing just the tool
|
519 |
williamc |
1.20 |
clientfile::openclientfile('add');
|
520 |
|
|
clientfile::_tool("file:$toolname");
|
521 |
williamc |
1.24 |
clientfile::closeclientfile();
|
522 |
|
|
#Now splice it in to the original - replacing the previous one if
|
523 |
|
|
#necessary - a bit of a hack to say the least -fortunately is
|
524 |
|
|
# already rewrittten for the next release!
|
525 |
|
|
|
526 |
|
|
open FILEIN, "$filebase/clientsettings" or die "$!\n";
|
527 |
|
|
while ( <FILEIN> ) {
|
528 |
|
|
push @filelines, $_;
|
529 |
|
|
next, if /^\s*#/;
|
530 |
|
|
chomp;
|
531 |
|
|
($toolkey=$_)=~s/(.*?:).*/$1/;
|
532 |
|
|
}
|
533 |
|
|
close FILEIN;
|
534 |
|
|
open FILEIN, "<$filebase/clientsettings.old";
|
535 |
|
|
open FILEOUT, ">$filebase/clientsettings.tmp";
|
536 |
|
|
while ( <FILEIN> ) {
|
537 |
|
|
if ( ( $_=~/^$toolkey/ ) ) {
|
538 |
|
|
if ( $insert==0 ) {
|
539 |
|
|
foreach $line ( @filelines ) {
|
540 |
|
|
print FILEOUT $line;
|
541 |
|
|
}
|
542 |
|
|
$insert=1;
|
543 |
|
|
}
|
544 |
|
|
next;
|
545 |
|
|
}
|
546 |
|
|
else {
|
547 |
|
|
print FILEOUT $_;
|
548 |
|
|
}
|
549 |
|
|
}
|
550 |
|
|
if ( $insert==0 ) {
|
551 |
|
|
foreach $line ( @filelines ) {
|
552 |
|
|
print FILEOUT $line;
|
553 |
|
|
}
|
554 |
|
|
}
|
555 |
|
|
close FILEOUT;
|
556 |
|
|
close FILE;
|
557 |
|
|
rename "$filebase/clientsettings.tmp", "$filebase/clientsettings";
|
558 |
williamc |
1.12 |
}
|
559 |
williamc |
1.24 |
|
560 |
williamc |
1.12 |
}
|
561 |
|
|
|
562 |
williamc |
1.13 |
sub help_setup {
|
563 |
williamc |
1.12 |
|
564 |
|
|
print <<ENDTEXT;
|
565 |
williamc |
1.24 |
Allows installation/re-installation of a new tool/external package into an
|
566 |
|
|
already existing development area. If not toolname is specified,
|
567 |
|
|
the complete installation process is initiated.
|
568 |
williamc |
1.12 |
|
569 |
|
|
Usage:
|
570 |
|
|
|
571 |
williamc |
1.20 |
$bold scram setup $normal [toolname]
|
572 |
williamc |
1.12 |
|
573 |
|
|
toolname : The name of the tool setup file required.
|
574 |
|
|
ENDTEXT
|
575 |
|
|
exit;
|
576 |
williamc |
1.13 |
}
|
577 |
|
|
|
578 |
|
|
sub help_list {
|
579 |
|
|
print <<ENDTEXT;
|
580 |
|
|
Create an entry in the SCRAM database so that an installed project can be
|
581 |
|
|
referenced in the 'project' command by a tag/version combination.
|
582 |
|
|
Usage: (command to be issued from inside an installed project)
|
583 |
|
|
|
584 |
williamc |
1.14 |
$bold scram install $normal [project_tag [version_tag]]
|
585 |
williamc |
1.13 |
|
586 |
|
|
If not specified the project_tag and version_tag default to the project
|
587 |
|
|
name and version of the installation.
|
588 |
|
|
ENDTEXT
|
589 |
|
|
exit;
|
590 |
|
|
}
|
591 |
|
|
sub help_project {
|
592 |
|
|
print <<ENDTEXT;
|
593 |
|
|
Setup a new project development area. The new area will appear in the current
|
594 |
|
|
working directory.
|
595 |
|
|
Usage:
|
596 |
|
|
|
597 |
williamc |
1.24 |
$bold scram project [-d install_area] [-n directory_name]$normal project_url [project_version]
|
598 |
williamc |
1.13 |
|
599 |
|
|
Options:
|
600 |
|
|
|
601 |
|
|
project_url: The url of a scram bootstrap file.
|
602 |
|
|
Currently supported types are:
|
603 |
|
|
$bold Database label $normal
|
604 |
|
|
Labels can be assigned to bootstrap files for easy
|
605 |
|
|
access (See "scram install" command). If you
|
606 |
|
|
specify a label you must also specify a project_version.
|
607 |
|
|
e.g.
|
608 |
|
|
|
609 |
|
|
scram project SCRAM V1_0
|
610 |
|
|
|
611 |
|
|
scram project ORCA ORCA_1_1_1
|
612 |
|
|
|
613 |
|
|
To see the list of installed projects use the
|
614 |
|
|
"scram list" command.
|
615 |
|
|
|
616 |
|
|
$bold file: $normal A regular file on an accessable file system
|
617 |
|
|
e.g.
|
618 |
|
|
|
619 |
|
|
file:~/myprojects/projecta/config/BootStrapFile
|
620 |
|
|
|
621 |
|
|
project_version:
|
622 |
|
|
Only for use with a database label
|
623 |
|
|
|
624 |
|
|
-d install_area:
|
625 |
|
|
Indicate a project installation area into which the new
|
626 |
|
|
project area should appear. Default is the current working
|
627 |
|
|
directory.
|
628 |
williamc |
1.24 |
|
629 |
|
|
-n directory_name:
|
630 |
|
|
Specify the name of the SCRAM development area you wish to
|
631 |
|
|
create.
|
632 |
williamc |
1.13 |
|
633 |
williamc |
1.24 |
-n dir_name :
|
634 |
|
|
Specify name of the new development area directory
|
635 |
williamc |
1.14 |
ENDTEXT
|
636 |
|
|
}
|
637 |
|
|
|
638 |
|
|
sub help_version {
|
639 |
|
|
print <<ENDTEXT;
|
640 |
williamc |
1.24 |
With now $bold[version] $normal argument given, this command will simply
|
641 |
|
|
print to standard output the current version number.
|
642 |
|
|
|
643 |
|
|
Providing a version argument will cause that version to be downloaded and
|
644 |
|
|
installed, if not already locally available.
|
645 |
|
|
[Coming soon: When available locally, your current development area will
|
646 |
|
|
then be associated with the specified scram version rather than the default]
|
647 |
|
|
|
648 |
|
|
|
649 |
williamc |
1.14 |
Usage:
|
650 |
williamc |
1.24 |
$bold scram version [version]$normal
|
651 |
williamc |
1.14 |
|
652 |
|
|
ENDTEXT
|
653 |
|
|
}
|
654 |
|
|
|
655 |
|
|
sub help_arch {
|
656 |
|
|
print <<ENDTEXT;
|
657 |
|
|
Print out the architecture flag for the current machine.
|
658 |
|
|
|
659 |
|
|
Usage:
|
660 |
|
|
$bold scram arch $normal
|
661 |
williamc |
1.24 |
ENDTEXT
|
662 |
|
|
}
|
663 |
|
|
|
664 |
|
|
sub help_devtest {
|
665 |
|
|
print <<ENDTEXT;
|
666 |
|
|
For SCRAM development only. Allows testing of new features.
|
667 |
|
|
|
668 |
|
|
Usage:
|
669 |
|
|
$bold scram devtest
|
670 |
|
|
ENDTEXT
|
671 |
|
|
}
|
672 |
|
|
|
673 |
|
|
sub help_runtime {
|
674 |
|
|
print <<ENDTEXT;
|
675 |
|
|
Echo to Standard Output the Runtime Environment for the current development area
|
676 |
|
|
Output available in csh or sh flavours
|
677 |
|
|
|
678 |
|
|
Usage:
|
679 |
|
|
$bold scram runtime [-csh|-sh] $normal
|
680 |
|
|
|
681 |
|
|
Examples:
|
682 |
|
|
|
683 |
|
|
Setup the current environment to include the project Runtime Environment
|
684 |
|
|
in a csh environment
|
685 |
|
|
|
686 |
|
|
$bold eval `scram runtime -csh` $normal
|
687 |
|
|
|
688 |
|
|
Setup the current environment to include the project Runtime Environment in a
|
689 |
|
|
sh environment
|
690 |
|
|
|
691 |
|
|
$bold `scram runtime -sh` $normal
|
692 |
|
|
|
693 |
williamc |
1.13 |
ENDTEXT
|
694 |
williamc |
1.1 |
}
|