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 |
|
$inputcmd=shift; |
7 |
|
$found='false'; |
8 |
< |
@allowed_commands=qw(project build env install version list arch); |
8 |
> |
$bold = "\033[1m"; |
9 |
> |
$normal = "\033[0m"; |
10 |
> |
@allowed_commands=qw(project build install version list arch setup); |
11 |
|
|
12 |
|
foreach $command ( @allowed_commands ) { |
13 |
< |
do { &$command; $found='true'; last;} if ( $inputcmd=~/^$command\Z/i); |
13 |
> |
if ( $inputcmd=~/^$command\Z/i) { |
14 |
> |
# Deal with a help request |
15 |
> |
do{ helpheader($command); |
16 |
> |
&{"help_".$command}; exit; } if $ARGV[0]=~/help/i; |
17 |
> |
&$command; $found='true'; |
18 |
> |
last; |
19 |
> |
} |
20 |
|
} |
21 |
|
|
22 |
|
if ( ! ( $found=~/true/ ) ) { |
23 |
< |
print "scram help\n--------\n"; |
17 |
< |
print "Recognised Commands: \n"; |
23 |
> |
helpheader('Recognised Commands'); |
24 |
|
foreach $command ( @allowed_commands ) { |
25 |
< |
print " ".$command."\n"; |
25 |
> |
print " $bold scram ".$command.$normal."\n"; |
26 |
|
} |
27 |
+ |
print "\n"; |
28 |
+ |
print "Help on individual commands available through\n\n"; |
29 |
+ |
print "$bold scram".$normal." command$bold help $normal\n\n"; |
30 |
|
} |
31 |
|
|
32 |
+ |
sub help_build { |
33 |
+ |
&build; |
34 |
+ |
} |
35 |
|
sub build { |
36 |
|
# is this a based or free release? |
37 |
|
FullEnvInit(); |
38 |
|
use BuildSetup; |
39 |
+ |
$ENV{MAKETARGETS}=join ' ',@ARGV; |
40 |
|
BuildSetup($ENV{THISDIR},@ARGV); |
41 |
|
# system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV); |
42 |
|
} |
43 |
|
|
44 |
|
sub project { |
45 |
+ |
# process options |
46 |
+ |
while ( $ARGV[0]=~"^-" ) { |
47 |
+ |
if ( (shift @ARGV)=~/-d/ ) { #installation area directory |
48 |
+ |
chdir $ARGV[0]; |
49 |
+ |
shift @ARGV; |
50 |
+ |
} |
51 |
+ |
} |
52 |
|
my $project=shift @ARGV; |
53 |
|
my $version=shift @ARGV; |
54 |
|
environmentinit(); |
55 |
|
use File::Copy; |
56 |
|
use Utilities::AddDir; |
57 |
|
|
38 |
– |
print "Warning : - you are entering a development zone.". |
39 |
– |
" Don't complain if it don't work\n"; |
58 |
|
use BootStrapProject; |
59 |
|
# get the bootstrap files downloaded |
60 |
|
BootStrapProject("$project\?\?$version"); |
70 |
|
AddDir::adddir($ENV{$key}); |
71 |
|
} |
72 |
|
} |
73 |
+ |
if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) { |
74 |
+ |
system("cp", "-r", "$ENV{RELEASETOP}/$ENV{projconfigdir}", |
75 |
+ |
"$ENV{LOCALTOP}/$ENV{projconfigdir}"); |
76 |
+ |
} |
77 |
|
use clientfile; |
78 |
|
BuildClientFile( $ENV{SCRAM_ProjReqsDoc} ); |
79 |
+ |
use Cwd; |
80 |
+ |
print "Installation Located at:\n".cwd()."\n"; |
81 |
+ |
ReturnToContinue(); |
82 |
|
} |
83 |
+ |
|
84 |
|
sub FullEnvInit { |
85 |
|
environmentinit(); |
86 |
|
localtop(); |
101 |
|
$ENV{INTlog}="logs"; |
102 |
|
|
103 |
|
if ( ! ( exists $ENV{SCRAM_HOME}) ){ |
104 |
< |
$ENV{SCRAM_HOME}="/afs/cern.ch/user/w/williamc/public/SCRAM"; |
104 |
> |
$ENV{SCRAM_HOME}="/afs/cern.ch/cms/Releases"; |
105 |
|
print "Warning : Environment Variable SCRAM_HOME not set.\n"; |
106 |
|
print "Defaulting to $ENV{SCRAM_HOME}\n"; |
107 |
|
} |
129 |
|
} while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./ ); |
130 |
|
if ( ! (defined $ENV{LOCALTOP}) ) { |
131 |
|
print "Unable to locate the top of local release. Exiting\n"; |
132 |
< |
exit 1 |
132 |
> |
ReturnToContinue(); |
133 |
|
} |
134 |
|
} #end block |
135 |
|
($ENV{THISDIR}=cwd)=~s/^$ENV{LOCALTOP}//; |
162 |
|
my $version=shift @ARGV; |
163 |
|
|
164 |
|
# create database entry |
139 |
– |
do { &help_install; } if $tagname=~/help/i; |
165 |
|
&FullEnvInit; |
166 |
|
if ( $version eq "" ) { |
167 |
|
$version=$ENV{SCRAM_PROJVERSION}; |
204 |
|
|
205 |
|
sub help_install() { |
206 |
|
|
182 |
– |
helpheader("install"); |
207 |
|
print <<ENDTEXT; |
208 |
|
Associates a label with the current release in the SCRAM database. |
209 |
|
This allows other users to refer to a centrally installed project by |
255 |
|
&environmentinit(); |
256 |
|
print "$ENV{SCRAM_ARCH}\n"; |
257 |
|
} |
258 |
+ |
|
259 |
+ |
sub ReturnToContinue { |
260 |
+ |
print "Press RETURN to exit\n"; |
261 |
+ |
$junk=<STDIN>; |
262 |
+ |
} |
263 |
+ |
|
264 |
+ |
# |
265 |
+ |
# Setup a new tool |
266 |
+ |
# |
267 |
+ |
|
268 |
+ |
sub setup { |
269 |
+ |
my $toolname=shift @ARGV; |
270 |
+ |
|
271 |
+ |
&FullEnvInit; |
272 |
+ |
if ( $ENV{SCRAM_BootStrapFiles}!~/$ENV{LOCALTOP}\/\.SCRAM/ ) { |
273 |
+ |
$ENV{SCRAM_BootStrapFiles}="$ENV{LOCALTOP}/.SCRAM:". |
274 |
+ |
$ENV{SCRAM_BootStrapFiles}; |
275 |
+ |
} |
276 |
+ |
# Check for the correct toolfile |
277 |
+ |
# ideally try and download it if not already in .SCRAM |
278 |
+ |
# Only scram toolbox files supported so far |
279 |
+ |
if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) { |
280 |
+ |
&urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/" |
281 |
+ |
.$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ; |
282 |
+ |
} |
283 |
+ |
# Parse the toolfile and update the clientsettings file |
284 |
+ |
# currently just append to the end |
285 |
+ |
use clientfile; |
286 |
+ |
clientfile::openclientfile('add'); |
287 |
+ |
clientfile::_tool("file:$toolname"); |
288 |
+ |
closeclientfile; |
289 |
+ |
} |
290 |
+ |
|
291 |
+ |
sub help_setup { |
292 |
+ |
|
293 |
+ |
print <<ENDTEXT; |
294 |
+ |
Allows installation of a new tool/external package into an already |
295 |
+ |
existing area. |
296 |
+ |
|
297 |
+ |
Usage: |
298 |
+ |
|
299 |
+ |
$bold scram setup $normal toolname |
300 |
+ |
|
301 |
+ |
toolname : The name of the tool setup file required. |
302 |
+ |
ENDTEXT |
303 |
+ |
exit; |
304 |
+ |
} |
305 |
+ |
|
306 |
+ |
sub help_list { |
307 |
+ |
print <<ENDTEXT; |
308 |
+ |
Create an entry in the SCRAM database so that an installed project can be |
309 |
+ |
referenced in the 'project' command by a tag/version combination. |
310 |
+ |
Usage: (command to be issued from inside an installed project) |
311 |
+ |
|
312 |
+ |
$bold scram install $normal [project_tag [version_tag]] |
313 |
+ |
|
314 |
+ |
If not specified the project_tag and version_tag default to the project |
315 |
+ |
name and version of the installation. |
316 |
+ |
ENDTEXT |
317 |
+ |
exit; |
318 |
+ |
} |
319 |
+ |
sub help_project { |
320 |
+ |
print <<ENDTEXT; |
321 |
+ |
Setup a new project development area. The new area will appear in the current |
322 |
+ |
working directory. |
323 |
+ |
Usage: |
324 |
+ |
|
325 |
+ |
$bold scram project [-d install_area] $normal project_url [project_version] |
326 |
+ |
|
327 |
+ |
Options: |
328 |
+ |
|
329 |
+ |
project_url: The url of a scram bootstrap file. |
330 |
+ |
Currently supported types are: |
331 |
+ |
$bold Database label $normal |
332 |
+ |
Labels can be assigned to bootstrap files for easy |
333 |
+ |
access (See "scram install" command). If you |
334 |
+ |
specify a label you must also specify a project_version. |
335 |
+ |
e.g. |
336 |
+ |
|
337 |
+ |
scram project SCRAM V1_0 |
338 |
+ |
|
339 |
+ |
scram project ORCA ORCA_1_1_1 |
340 |
+ |
|
341 |
+ |
To see the list of installed projects use the |
342 |
+ |
"scram list" command. |
343 |
+ |
|
344 |
+ |
$bold file: $normal A regular file on an accessable file system |
345 |
+ |
e.g. |
346 |
+ |
|
347 |
+ |
file:~/myprojects/projecta/config/BootStrapFile |
348 |
+ |
|
349 |
+ |
project_version: |
350 |
+ |
Only for use with a database label |
351 |
+ |
|
352 |
+ |
-d install_area: |
353 |
+ |
Indicate a project installation area into which the new |
354 |
+ |
project area should appear. Default is the current working |
355 |
+ |
directory. |
356 |
+ |
|
357 |
+ |
ENDTEXT |
358 |
+ |
} |
359 |
+ |
|
360 |
+ |
sub help_version { |
361 |
+ |
print <<ENDTEXT; |
362 |
+ |
Print the version number of scram |
363 |
+ |
Usage: |
364 |
+ |
$bold scram version $normal |
365 |
+ |
|
366 |
+ |
ENDTEXT |
367 |
+ |
} |
368 |
+ |
|
369 |
+ |
sub help_arch { |
370 |
+ |
print <<ENDTEXT; |
371 |
+ |
Print out the architecture flag for the current machine. |
372 |
+ |
|
373 |
+ |
Usage: |
374 |
+ |
$bold scram arch $normal |
375 |
+ |
ENDTEXT |
376 |
+ |
} |