ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scram
(Generate patch)

Comparing COMP/SCRAM/src/scram (file contents):
Revision 1.21 by williamc, Thu Apr 1 09:55:00 1999 UTC vs.
Revision 1.27 by williamc, Fri Dec 17 10:56:29 1999 UTC

# Line 1 | Line 1
1 < #!/usr/local/bin/perl5
1 > #!/usr/local/bin/perl5 -w
2   #
3   # User Interface
4   #
5  
6 < $inputcmd=shift;
7 < $found='false';
8 < $bold  = "\033[1m";
9 < $normal = "\033[0m";
10 < @allowed_commands=qw(project build install version list arch setup);
11 <
12 < if ( $inputcmd ne "" ) {
13 < foreach $command ( @allowed_commands ) {
14 <         if ( $command=~/^$inputcmd/i) {
15 <                # Deal with a help request
16 <                do{     helpheader($command);
17 <                        &{"help_".$command}; exit; } if $ARGV[0]=~/help/i;
18 <                &$command; $found='true';
19 <                last;
20 <         }
21 < }
22 < }
23 <
24 < if ( ! ( $found=~/true/ ) ) {
25 <        helpheader('Recognised Commands');
26 <        foreach $command ( @allowed_commands ) {
27 <        print "      $bold scram ".$command.$normal."\n";      
28 <        }
29 <        print "\n";
30 <        print "Help on individual commands available through\n\n";
31 <        print "$bold       scram".$normal." command$bold help $normal\n\n";
32 < }
33 <
34 < sub help_build {
35 <        &build;
36 < }
37 < sub build {
38 <        # is this a based or free release?
39 <        FullEnvInit();
40 <        use BuildSetup;
41 <        $ENV{MAKETARGETS}=join ' ',@ARGV;
42 <        BuildSetup($ENV{THISDIR},@ARGV);
43 < #       system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV);
44 < }
45 <
46 < sub project {
47 <        # process options
48 <        while ( $ARGV[0]=~"^-" ) {
49 <         if ( (shift @ARGV)=~/-d/ ) {  #installation area directory
50 <          chdir $ARGV[0];
51 <          shift @ARGV;
52 <         }
53 <        }
54 <        my $project=shift @ARGV;
55 <        my $version=shift @ARGV;
56 <        environmentinit();
57 <        use File::Copy;
58 <        use Utilities::AddDir;
59 <        
60 <           use BootStrapProject;
61 <           # get the bootstrap files downloaded
62 <           BootStrapProject("$project\?\?$version");
63 <           # Go setup the rest of the environement, now we can
64 <           chdir $ENV{LOCALTOP};
65 <           &localtop;
66 <           LoadEnvFile();
67 <           #
68 <           # Now create the directories specified in the interface
69 <           #
70 <           foreach $key ( keys %ENV ) {
71 <                if ( $key=~/^INT/ ) {
72 <                        AddDir::adddir($ENV{$key});
73 <                }
74 <           }
75 <           if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) {
76 <                system("cp", "-r", "$ENV{RELEASETOP}/$ENV{projconfigdir}",
77 <                                "$ENV{LOCALTOP}/$ENV{projconfigdir}");
78 <           }
79 <           use clientfile;
80 <           BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
81 <           use Cwd;
82 <           print "\nInstallation Procedure Complete. \n".
83 <                        "Installation Located at:\n".cwd()."\n";
84 < }
85 <
86 < sub FullEnvInit {
87 <    environmentinit();
88 <    localtop();
89 <    LoadEnvFile();
90 < }
91 <
92 < sub environmentinit {
93 <        use Utilities::setarchitecture;
94 <        my $name;
95 <        my $value;
96 <
97 <        $ENV{LatestBuildFile}=""; # stop recursive behaviour in make
98 <        setarchitecture::setarch();
99 <        $ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}";
100 <        $ENV{INTlib}="lib/$ENV{SCRAM_ARCH}";
101 <        $ENV{INTsrc}="src";
102 <        $ENV{INTbin}="bin/$ENV{SCRAM_ARCH}";
103 <        $ENV{INTlog}="logs";
104 <
105 <        if ( ! ( exists $ENV{SCRAM_HOME}) ){
106 <         $ENV{SCRAM_HOME}="/afs/cern.ch/cms/Releases";
107 <         print "Warning : Environment Variable SCRAM_HOME not set.\n";
108 <         print "Defaulting to $ENV{SCRAM_HOME}\n";
109 <        }
110 <         if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){
111 <                $ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration";
112 <        }
113 <        if ( ! ( exists $ENV{TOOL_HOME} ) ){
114 <                $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
115 <        }
116 <        if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){
117 <                $ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup";
118 <        }
119 < }
120 <
121 < sub localtop {
122 <        # find localtop
123 <        use Cwd;
124 <        my $thispath=cwd;
125 <        block: {
126 <        do {
127 <          if ( -e "$thispath/.SCRAM" ) {
128 <                $ENV{LOCALTOP}=$thispath;
129 <                last block;
130 <          }
131 <        } while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./  );
132 <        if ( ! (defined $ENV{LOCALTOP}) ) {
133 <         print "Unable to locate the top of local release. Exiting\n";
134 <         exit 1;
135 <        }
136 <        } #end block
137 <        ($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//;
138 <        $ENV{THISDIR}=~s/^\///;
139 <        $ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM";
140 < }
141 <
142 < sub LoadEnvFile {
143 <        open ( SCRAMENV, "<$ENV{SCRAM_WORKDIR}/Environment" ) ||
144 <                die "Cant find Environment file $!\n";
145 <        while ( <SCRAMENV> ) {
146 <           chomp;
147 <           next if /^#/;
148 <           next if /^\s*$/ ;
149 <           ($name, $value)=split /=/;
150 <           eval "\$ENV{${name}}=\"$value\"";
151 <        }
152 <        close SCRAMENV;
153 < }
154 <
155 < sub env {
156 <   print "Sorry - Not yet\n";
157 < }
158 <
159 < #
160 < # Create a lookup tag in the site database
161 < #
162 < sub install ( $tagname, $version ) {
163 <        my $tagname=shift @ARGV;
164 <        my $version=shift @ARGV;
165 <
166 <        # create database entry
167 <        &FullEnvInit;
168 <        if ( $version eq "" ) {
169 <           $version=$ENV{SCRAM_PROJVERSION};
170 <        }
171 <        if ( $tagname eq "" ) {
172 <           $tagname=$ENV{SCRAM_PROJECTNAME};
173 <        }
174 <        my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
175 <        my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp";
176 <        open ( LOCALLOOKUPDB, "<$filename" );
177 <        open ( OUTFILE , ">$outfile" ) or die "Unable to open $outfile $!\n";
178 <        while ( <LOCALLOOKUPDB> ) {
179 <            if ( /^$tagname/ ) {
180 <                print "Related tag :".$_."\n";
181 <                if ( /$version/) {
182 <                  print "$tagname $version already exists. Overwrite (y/n)\n";
183 <                  if ( ! (<STDIN>=~/y/i ) ) {
184 <                        print "Aborting install ...\n";
185 <                        close OUTFILE;
186 <                        close LOCALLOOKUPDB;
187 <                        exit 1;
188 <                  }
189 <                }
190 <                else {
191 <                        print OUTFILE $_;
192 <                }
193 <            }
194 <            else {
195 <                print OUTFILE $_;
196 <            }
197 <        }
198 <        print OUTFILE "$tagname:$version:file:$ENV{LOCALTOP}".
199 <                "/.SCRAM/InstallFile\n";
200 <        close OUTFILE;
201 <        close LOCALLOOKUPDB;
202 <        copy ( "$outfile", "$filename" )
203 <                || die "Unable to copy $! \n";
204 <
205 < }
206 <
207 < sub help_install()  {
208 <
209 < print <<ENDTEXT;
210 < Associates a label with the current release in the SCRAM database.
211 < This allows other users to refer to a centrally installed project by
212 < this label rather than a remote url reference.
213 <
214 < Usage:
215 <
216 <                 scram install [[label] [version]]
217 <
218 < label   : override default label (the project name of the current release)
219 < version : the version tag of the current release. If version is not
220 <          specified the base release version will be taken by default.
221 <
222 < ENDTEXT
223 < exit;
224 < }
225 <
226 < sub helpheader ($label) {
227 <        my $label=shift;
228 < print <<ENDTEXT;
229 < *************************************************************************
230 <                   SCRAM HELP --------- $label
231 < *************************************************************************
232 < ENDTEXT
233 < }
234 <
235 < sub version {
236 <        print "Scram version : prototype\n";
237 < }
238 <
239 < sub list {
240 <        &environmentinit;
241 <        my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
242 <        open ( LOCALLOOKUPDB, "<$filename" );
243 <        print "Installed Projects\n";
244 <        print "------------------\n";
245 <        print "|Project Name  | Project Version |\n";
246 <        print "----------------------------------\n";
247 <        while ( <LOCALLOOKUPDB> ) {
248 <          ( $name, $version, $type, $url ) = split ":", $_;
249 <          printf "%1s",$name;
250 <          printf "%25s\n",$version;
251 <          printf "--> %25s\n",$type.":".$url;
252 <        }
253 <        close LOCALLOOKUPDB;
254 < }
255 <
256 < sub arch {
257 <        &environmentinit();
258 <        print "$ENV{SCRAM_ARCH}\n";
259 < }
260 <
261 <
262 < #
263 < # Setup a new tool
264 < #
265 <
266 < sub setup {
267 <        my $toolname=shift @ARGV;
268 <
269 <        &FullEnvInit;
270 <        if ( $ENV{SCRAM_BootStrapFiles}!~/$ENV{LOCALTOP}\/\.SCRAM/ ) {
271 <          $ENV{SCRAM_BootStrapFiles}="$ENV{LOCALTOP}/.SCRAM:".
272 <                        $ENV{SCRAM_BootStrapFiles};
273 <        }
274 <        # If no toolname specified then its a full setup
275 <        if ( $toolname eq "" ) {
276 <           my $filebase="$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}";
277 <           rename "$filebase/clientsettings", "$filebase/clientsettings.old";
278 <           rename "$filebase/clientsettings_reqs",
279 <                                "$filebase/clientsettings_reqs.old";
280 <           use clientfile;
281 <           BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
282 <        }
283 <        else {
284 <          # Check for the correct toolfile
285 <          # ideally try and download it if not already in .SCRAM
286 <          # Only scram toolbox files supported so far
287 <          if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) {
288 <                &urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/"
289 <                        .$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ;
290 <          }
291 <          # Parse the toolfile and update the clientsettings file
292 <          # currently just append to the end
293 <          use clientfile;
294 <          clientfile::openclientfile('add');
295 <          clientfile::_tool("file:$toolname");
296 <          closeclientfile;
297 <        }
298 < }
299 <
300 < sub help_setup {
301 <
302 < print <<ENDTEXT;
303 < Allows installation of a new tool/external package into an already
304 < existing area. If not toolname is specified, the complete installation
305 < process is initiated.
306 <
307 < Usage:
308 <
309 <                 $bold scram setup $normal [toolname]
310 <
311 < toolname : The name of the tool setup file required.
312 < ENDTEXT
313 < exit;
314 < }
315 <
316 < sub help_list {
317 < print <<ENDTEXT;
318 < Create an entry in the SCRAM database so that an installed project can be
319 < referenced in the 'project' command by a tag/version combination.
320 < Usage: (command to be issued from inside an installed project)
321 <
322 <        $bold   scram install $normal [project_tag [version_tag]]
323 <
324 < If not specified the project_tag and version_tag default to the project
325 < name and version of the installation.
326 < ENDTEXT
327 < exit;
328 < }
329 < sub help_project {
330 < print <<ENDTEXT;
331 < Setup a new project development area. The new area will appear in the current
332 < working directory.
333 < Usage:
334 <
335 <        $bold scram project [-d install_area] $normal project_url [project_version]
336 <
337 < Options:
338 <
339 < project_url: The url of a scram bootstrap file.
340 <             Currently supported types are:
341 <                $bold Database label $normal
342 <                        Labels can be assigned to bootstrap files for easy
343 <                        access (See "scram install" command). If you
344 <                        specify a label you must also specify a project_version.
345 <                        e.g.
346 <
347 <                           scram project SCRAM V1_0
348 <                                
349 <                           scram project ORCA ORCA_1_1_1
350 <
351 <                        To see the list of installed projects use the
352 <                        "scram list" command.
353 <
354 <                $bold file: $normal A regular file on an accessable file system
355 <                        e.g.
356 <
357 <                           file:~/myprojects/projecta/config/BootStrapFile
358 <
359 < project_version:
360 <                 Only for use with a database label
361 <
362 < -d install_area:
363 <                 Indicate a project installation area into which the new
364 <                 project area should appear. Default is the current working
365 <                 directory.
366 <        
367 < ENDTEXT
368 < }
369 <
370 < sub help_version {
371 < print <<ENDTEXT;
372 < Print the version number of scram
373 < Usage:
374 <                $bold scram version $normal
375 <
376 < ENDTEXT
377 < }
378 <
379 < sub help_arch {
380 < print <<ENDTEXT;
381 < Print out the architecture flag for the current machine.
382 <
383 < Usage:
384 <        $bold   scram arch $normal
385 < ENDTEXT
386 < }
6 > #use Scram::SCRAM;
7 > use ActiveDoc::CommandLineInterface;
8 > use ActiveDoc::SimpleUserInterface;
9 > use Utilities::PathMod;
10 > use Configuration::Tool;
11 >
12 > # Set up our scram objects
13 > $self={};
14 > $self->{UI}=ActiveDoc::SimpleUserInterface->new();
15 > # Search for configuration resource file
16 > $self->{configpath}="$ENV{HOME}:$ENV{SCRAM_HOME}/configuration";
17 > $self->{PathMod}=Utilities::PathMod->new();
18 > $self->{file}=$self->{PathMod}->SearchPath(
19 >                        $self->{configpath},".scramrc");
20 >
21 > #$self->{cli}=ActiveDoc::CommandLineInterface->new(qw(Scram::SCRAM ActiveDoc::UserInterface_basic));
22 > $self->{cli}=ActiveDoc::CommandLineInterface->new(qw(Scram::SCRAM), $self->{UI});
23 > $self->{cli}->parse(@ARGV)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines