ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scram
Revision: 1.5
Committed: Wed Mar 3 17:04:14 1999 UTC (26 years, 2 months ago) by williamc
Branch: MAIN
Changes since 1.4: +2 -2 lines
Log Message:
Updates towardsa release

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