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