ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scram
Revision: 1.15
Committed: Thu Mar 25 15:55:14 1999 UTC (26 years, 1 month ago) by williamc
Branch: MAIN
CVS Tags: V0_2
Changes since 1.14: +6 -4 lines
Log Message:
Update help files

File Contents

# User Rev Content
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.15 @allowed_commands=qw(project build install version list arch setup);
11 williamc 1.1
12     foreach $command ( @allowed_commands ) {
13 williamc 1.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 williamc 1.1 }
21    
22     if ( ! ( $found=~/true/ ) ) {
23 williamc 1.15 helpheader('Recognised Commands');
24 williamc 1.1 foreach $command ( @allowed_commands ) {
25 williamc 1.15 print " $bold scram ".$command.$normal."\n";
26 williamc 1.1 }
27 williamc 1.15 print "\n";
28     print "Help on individual commands available through\n\n";
29     print "$bold scram".$normal." command$bold help $normal\n\n";
30 williamc 1.1 }
31    
32 williamc 1.14 sub help_build {
33     &build;
34     }
35 williamc 1.1 sub build {
36     # is this a based or free release?
37     FullEnvInit();
38     use BuildSetup;
39 williamc 1.10 $ENV{MAKETARGETS}=join ' ',@ARGV;
40 williamc 1.1 BuildSetup($ENV{THISDIR},@ARGV);
41     # system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV);
42     }
43    
44     sub project {
45 williamc 1.7 # process options
46     while ( $ARGV[0]=~"^-" ) {
47     if ( (shift @ARGV)=~/-d/ ) { #installation area directory
48     chdir $ARGV[0];
49     shift @ARGV;
50     }
51     }
52 williamc 1.1 my $project=shift @ARGV;
53     my $version=shift @ARGV;
54     environmentinit();
55     use File::Copy;
56 williamc 1.2 use Utilities::AddDir;
57 williamc 1.1
58     use BootStrapProject;
59     # get the bootstrap files downloaded
60     BootStrapProject("$project\?\?$version");
61     # Go setup the rest of the environement, now we can
62     chdir $ENV{LOCALTOP};
63     &localtop;
64     LoadEnvFile();
65     #
66     # Now create the directories specified in the interface
67     #
68     foreach $key ( keys %ENV ) {
69     if ( $key=~/^INT/ ) {
70 williamc 1.5 AddDir::adddir($ENV{$key});
71 williamc 1.1 }
72     }
73 williamc 1.6 if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) {
74     system("cp", "-r", "$ENV{RELEASETOP}/$ENV{projconfigdir}",
75     "$ENV{LOCALTOP}/$ENV{projconfigdir}");
76     }
77 williamc 1.1 use clientfile;
78     BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
79 williamc 1.7 use Cwd;
80     print "Installation Located at:\n".cwd()."\n";
81 williamc 1.11 ReturnToContinue();
82 williamc 1.1 }
83 williamc 1.7
84 williamc 1.1 sub FullEnvInit {
85     environmentinit();
86     localtop();
87     LoadEnvFile();
88     }
89    
90     sub environmentinit {
91 williamc 1.2 use Utilities::setarchitecture;
92 williamc 1.1 my $name;
93     my $value;
94    
95     $ENV{LatestBuildFile}=""; # stop recursive behaviour in make
96 williamc 1.4 setarchitecture::setarch();
97 williamc 1.1 $ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}";
98     $ENV{INTlib}="lib/$ENV{SCRAM_ARCH}";
99     $ENV{INTsrc}="src";
100     $ENV{INTbin}="bin/$ENV{SCRAM_ARCH}";
101     $ENV{INTlog}="logs";
102    
103     if ( ! ( exists $ENV{SCRAM_HOME}) ){
104 williamc 1.8 $ENV{SCRAM_HOME}="/afs/cern.ch/cms/Releases";
105 williamc 1.1 print "Warning : Environment Variable SCRAM_HOME not set.\n";
106     print "Defaulting to $ENV{SCRAM_HOME}\n";
107     }
108     if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){
109 williamc 1.3 $ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration";
110 williamc 1.1 }
111     if ( ! ( exists $ENV{TOOL_HOME} ) ){
112 williamc 1.4 $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
113 williamc 1.1 }
114     if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){
115     $ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup";
116     }
117     }
118    
119     sub localtop {
120     # find localtop
121     use Cwd;
122     my $thispath=cwd;
123     block: {
124     do {
125     if ( -e "$thispath/.SCRAM" ) {
126     $ENV{LOCALTOP}=$thispath;
127     last block;
128     }
129     } while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./ );
130     if ( ! (defined $ENV{LOCALTOP}) ) {
131     print "Unable to locate the top of local release. Exiting\n";
132 williamc 1.11 ReturnToContinue();
133 williamc 1.1 }
134     } #end block
135     ($ENV{THISDIR}=cwd)=~s/^$ENV{LOCALTOP}//;
136     $ENV{THISDIR}=~s/^\///;
137     $ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM";
138     }
139    
140     sub LoadEnvFile {
141     open ( SCRAMENV, "<$ENV{SCRAM_WORKDIR}/Environment" ) ||
142     die "Cant find Environment file $!\n";
143     while ( <SCRAMENV> ) {
144     chomp;
145     next if /^#/;
146     next if /^\s*$/ ;
147     ($name, $value)=split /=/;
148     eval "\$ENV{${name}}=\"$value\"";
149     }
150     close SCRAMENV;
151     }
152    
153     sub env {
154     print "Sorry - Not yet\n";
155     }
156    
157     #
158     # Create a lookup tag in the site database
159     #
160     sub install ( $tagname, $version ) {
161     my $tagname=shift @ARGV;
162     my $version=shift @ARGV;
163    
164     # create database entry
165     &FullEnvInit;
166     if ( $version eq "" ) {
167     $version=$ENV{SCRAM_PROJVERSION};
168     }
169     if ( $tagname eq "" ) {
170     $tagname=$ENV{SCRAM_PROJECTNAME};
171     }
172     my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
173     my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp";
174     open ( LOCALLOOKUPDB, "<$filename" );
175     open ( OUTFILE , ">$outfile" );
176     while ( <LOCALLOOKUPDB> ) {
177     if ( /^$tagname/ ) {
178     print "Related tag :".$_."\n";
179     if ( /$version/) {
180     print "$tagname $version already exists. Overwrite (y/n)\n";
181     if ( ! (<STDIN>=~/y/i ) ) {
182     print "Aborting install ...\n";
183     close OUTFILE;
184     close LOCALLOOKUPDB;
185     exit 1;
186     }
187     }
188     else {
189     print OUTFILE $_;
190     }
191     }
192     else {
193     print OUTFILE $_;
194     }
195     }
196     print OUTFILE "$tagname:$version:file:$ENV{LOCALTOP}".
197     "/.SCRAM/InstallFile\n";
198     close OUTFILE;
199     close LOCALLOOKUPDB;
200     copy ( "$outfile", "$filename" )
201     || die "Unable to copy $! \n";
202    
203     }
204    
205     sub help_install() {
206    
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
210     this label rather than a remote url reference.
211    
212     Usage:
213    
214     scram install [[label] [version]]
215    
216     label : override default label (the project name of the current release)
217     version : the version tag of the current release. If version is not
218     specified the base release version will be taken by default.
219    
220     ENDTEXT
221     exit;
222     }
223    
224     sub helpheader ($label) {
225     my $label=shift;
226     print <<ENDTEXT;
227     *************************************************************************
228     SCRAM HELP --------- $label
229     *************************************************************************
230     ENDTEXT
231     }
232    
233     sub version {
234     print "Scram version : prototype\n";
235     }
236    
237     sub list {
238     &environmentinit;
239     my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
240     open ( LOCALLOOKUPDB, "<$filename" );
241     print "Installed Projects\n";
242     print "------------------\n";
243     print "|Project Name | Project Version |\n";
244     print "----------------------------------\n";
245     while ( <LOCALLOOKUPDB> ) {
246     ( $name, $version, $type, $url ) = split ":", $_;
247     printf "%1s",$name;
248     printf "%25s\n",$version;
249     printf "--> %25s\n",$type.":".$url;
250     }
251     close LOCALLOOKUPDB;
252     }
253    
254     sub arch {
255     &environmentinit();
256     print "$ENV{SCRAM_ARCH}\n";
257 williamc 1.11 }
258    
259     sub ReturnToContinue {
260     print "Press RETURN to exit\n";
261     $junk=<STDIN>;
262 williamc 1.12 }
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 williamc 1.13 sub help_setup {
292 williamc 1.12
293     print <<ENDTEXT;
294 williamc 1.14 Allows installation of a new tool/external package into an already
295     existing area.
296 williamc 1.12
297     Usage:
298    
299 williamc 1.14 $bold scram setup $normal toolname
300 williamc 1.12
301     toolname : The name of the tool setup file required.
302     ENDTEXT
303     exit;
304 williamc 1.13 }
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 williamc 1.14 $bold scram install $normal [project_tag [version_tag]]
313 williamc 1.13
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 williamc 1.14 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 williamc 1.13 ENDTEXT
376 williamc 1.1 }