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