1 |
< |
#!/usr/local/bin/perl5 -I$ENV{SCRAM_HOME}/src |
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"; |
16 |
< |
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 |
|
|
37 |
– |
print "Warning : - you are entering a development zone.". |
38 |
– |
" Don't complain if it don't work\n"; |
58 |
|
use BootStrapProject; |
59 |
|
# get the bootstrap files downloaded |
60 |
|
BootStrapProject("$project\?\?$version"); |
67 |
|
# |
68 |
|
foreach $key ( keys %ENV ) { |
69 |
|
if ( $key=~/^INT/ ) { |
70 |
< |
adddir($ENV{$key}); |
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 |
|
} |
82 |
+ |
|
83 |
|
sub FullEnvInit { |
84 |
|
environmentinit(); |
85 |
|
localtop(); |
92 |
|
my $value; |
93 |
|
|
94 |
|
$ENV{LatestBuildFile}=""; # stop recursive behaviour in make |
95 |
< |
setarch(); |
95 |
> |
setarchitecture::setarch(); |
96 |
|
$ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}"; |
97 |
|
$ENV{INTlib}="lib/$ENV{SCRAM_ARCH}"; |
98 |
|
$ENV{INTsrc}="src"; |
100 |
|
$ENV{INTlog}="logs"; |
101 |
|
|
102 |
|
if ( ! ( exists $ENV{SCRAM_HOME}) ){ |
103 |
< |
$ENV{SCRAM_HOME}="/afs/cern.ch/user/w/williamc/public/ConfigMan"; |
103 |
> |
$ENV{SCRAM_HOME}="/afs/cern.ch/cms/Releases"; |
104 |
|
print "Warning : Environment Variable SCRAM_HOME not set.\n"; |
105 |
|
print "Defaulting to $ENV{SCRAM_HOME}\n"; |
106 |
|
} |
107 |
|
if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){ |
108 |
< |
$ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/Configuration"; |
108 |
> |
$ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration"; |
109 |
|
} |
110 |
|
if ( ! ( exists $ENV{TOOL_HOME} ) ){ |
111 |
< |
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/toolbox"; |
111 |
> |
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src"; |
112 |
|
} |
113 |
|
if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){ |
114 |
|
$ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup"; |
128 |
|
} while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./ ); |
129 |
|
if ( ! (defined $ENV{LOCALTOP}) ) { |
130 |
|
print "Unable to locate the top of local release. Exiting\n"; |
131 |
< |
exit 1 |
131 |
> |
exit 1; |
132 |
|
} |
133 |
|
} #end block |
134 |
< |
($ENV{THISDIR}=cwd)=~s/^$ENV{LOCALTOP}//; |
134 |
> |
($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//; |
135 |
|
$ENV{THISDIR}=~s/^\///; |
136 |
|
$ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM"; |
137 |
|
} |
161 |
|
my $version=shift @ARGV; |
162 |
|
|
163 |
|
# create database entry |
138 |
– |
do { &help_install; } if $tagname=~/help/i; |
164 |
|
&FullEnvInit; |
165 |
|
if ( $version eq "" ) { |
166 |
|
$version=$ENV{SCRAM_PROJVERSION}; |
171 |
|
my $filename="$ENV{SCRAM_CONFIG}/project.lookup"; |
172 |
|
my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp"; |
173 |
|
open ( LOCALLOOKUPDB, "<$filename" ); |
174 |
< |
open ( OUTFILE , ">$outfile" ); |
174 |
> |
open ( OUTFILE , ">$outfile" ) or die "Unable to open $outfile $!\n"; |
175 |
|
while ( <LOCALLOOKUPDB> ) { |
176 |
|
if ( /^$tagname/ ) { |
177 |
|
print "Related tag :".$_."\n"; |
203 |
|
|
204 |
|
sub help_install() { |
205 |
|
|
181 |
– |
helpheader("install"); |
206 |
|
print <<ENDTEXT; |
207 |
|
Associates a label with the current release in the SCRAM database. |
208 |
|
This allows other users to refer to a centrally installed project by |
254 |
|
&environmentinit(); |
255 |
|
print "$ENV{SCRAM_ARCH}\n"; |
256 |
|
} |
257 |
+ |
|
258 |
+ |
|
259 |
+ |
# |
260 |
+ |
# Setup a new tool |
261 |
+ |
# |
262 |
+ |
|
263 |
+ |
sub setup { |
264 |
+ |
my $toolname=shift @ARGV; |
265 |
+ |
|
266 |
+ |
&FullEnvInit; |
267 |
+ |
if ( $ENV{SCRAM_BootStrapFiles}!~/$ENV{LOCALTOP}\/\.SCRAM/ ) { |
268 |
+ |
$ENV{SCRAM_BootStrapFiles}="$ENV{LOCALTOP}/.SCRAM:". |
269 |
+ |
$ENV{SCRAM_BootStrapFiles}; |
270 |
+ |
} |
271 |
+ |
# Check for the correct toolfile |
272 |
+ |
# ideally try and download it if not already in .SCRAM |
273 |
+ |
# Only scram toolbox files supported so far |
274 |
+ |
if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) { |
275 |
+ |
&urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/" |
276 |
+ |
.$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ; |
277 |
+ |
} |
278 |
+ |
# Parse the toolfile and update the clientsettings file |
279 |
+ |
# currently just append to the end |
280 |
+ |
use clientfile; |
281 |
+ |
clientfile::openclientfile('add'); |
282 |
+ |
clientfile::_tool("file:$toolname"); |
283 |
+ |
closeclientfile; |
284 |
+ |
} |
285 |
+ |
|
286 |
+ |
sub help_setup { |
287 |
+ |
|
288 |
+ |
print <<ENDTEXT; |
289 |
+ |
Allows installation of a new tool/external package into an already |
290 |
+ |
existing area. |
291 |
+ |
|
292 |
+ |
Usage: |
293 |
+ |
|
294 |
+ |
$bold scram setup $normal toolname |
295 |
+ |
|
296 |
+ |
toolname : The name of the tool setup file required. |
297 |
+ |
ENDTEXT |
298 |
+ |
exit; |
299 |
+ |
} |
300 |
+ |
|
301 |
+ |
sub help_list { |
302 |
+ |
print <<ENDTEXT; |
303 |
+ |
Create an entry in the SCRAM database so that an installed project can be |
304 |
+ |
referenced in the 'project' command by a tag/version combination. |
305 |
+ |
Usage: (command to be issued from inside an installed project) |
306 |
+ |
|
307 |
+ |
$bold scram install $normal [project_tag [version_tag]] |
308 |
+ |
|
309 |
+ |
If not specified the project_tag and version_tag default to the project |
310 |
+ |
name and version of the installation. |
311 |
+ |
ENDTEXT |
312 |
+ |
exit; |
313 |
+ |
} |
314 |
+ |
sub help_project { |
315 |
+ |
print <<ENDTEXT; |
316 |
+ |
Setup a new project development area. The new area will appear in the current |
317 |
+ |
working directory. |
318 |
+ |
Usage: |
319 |
+ |
|
320 |
+ |
$bold scram project [-d install_area] $normal project_url [project_version] |
321 |
+ |
|
322 |
+ |
Options: |
323 |
+ |
|
324 |
+ |
project_url: The url of a scram bootstrap file. |
325 |
+ |
Currently supported types are: |
326 |
+ |
$bold Database label $normal |
327 |
+ |
Labels can be assigned to bootstrap files for easy |
328 |
+ |
access (See "scram install" command). If you |
329 |
+ |
specify a label you must also specify a project_version. |
330 |
+ |
e.g. |
331 |
+ |
|
332 |
+ |
scram project SCRAM V1_0 |
333 |
+ |
|
334 |
+ |
scram project ORCA ORCA_1_1_1 |
335 |
+ |
|
336 |
+ |
To see the list of installed projects use the |
337 |
+ |
"scram list" command. |
338 |
+ |
|
339 |
+ |
$bold file: $normal A regular file on an accessable file system |
340 |
+ |
e.g. |
341 |
+ |
|
342 |
+ |
file:~/myprojects/projecta/config/BootStrapFile |
343 |
+ |
|
344 |
+ |
project_version: |
345 |
+ |
Only for use with a database label |
346 |
+ |
|
347 |
+ |
-d install_area: |
348 |
+ |
Indicate a project installation area into which the new |
349 |
+ |
project area should appear. Default is the current working |
350 |
+ |
directory. |
351 |
+ |
|
352 |
+ |
ENDTEXT |
353 |
+ |
} |
354 |
+ |
|
355 |
+ |
sub help_version { |
356 |
+ |
print <<ENDTEXT; |
357 |
+ |
Print the version number of scram |
358 |
+ |
Usage: |
359 |
+ |
$bold scram version $normal |
360 |
+ |
|
361 |
+ |
ENDTEXT |
362 |
+ |
} |
363 |
+ |
|
364 |
+ |
sub help_arch { |
365 |
+ |
print <<ENDTEXT; |
366 |
+ |
Print out the architecture flag for the current machine. |
367 |
+ |
|
368 |
+ |
Usage: |
369 |
+ |
$bold scram arch $normal |
370 |
+ |
ENDTEXT |
371 |
+ |
} |