ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scram
Revision: 1.7
Committed: Thu Mar 18 08:01:59 1999 UTC (26 years, 1 month ago) by williamc
Branch: MAIN
Changes since 1.6: +12 -2 lines
Log Message:
Add -d option to project command. This allows one to specify the project location directory instead of the current directory - also add a notifier of position and a RETURN to exit for netscape users

File Contents

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