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.8 by williamc, Mon Mar 22 18:01:31 1999 UTC vs.
Revision 1.26 by williamc, Mon Sep 20 16:29:05 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);
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 <        BuildSetup($ENV{THISDIR},@ARGV);
27 < #       system("$ENV{TOOL_HOME}/BuildSetup",$ENV{THISDIR},@ARGV);
28 < }
29 <
30 < sub project {
31 <        # process options
32 <        while ( $ARGV[0]=~"^-" ) {
33 <         if ( (shift @ARGV)=~/-d/ ) {  #installation area directory
34 <          chdir $ARGV[0];
35 <          shift @ARGV;
36 <         }
37 <        }
38 <        my $project=shift @ARGV;
39 <        my $version=shift @ARGV;
40 <        environmentinit();
41 <        use File::Copy;
42 <        use Utilities::AddDir;
43 <        
44 <           use BootStrapProject;
45 <           # get the bootstrap files downloaded
46 <           BootStrapProject("$project\?\?$version");
47 <           # Go setup the rest of the environement, now we can
48 <           chdir $ENV{LOCALTOP};
49 <           &localtop;
50 <           LoadEnvFile();
51 <           #
52 <           # Now create the directories specified in the interface
53 <           #
54 <           foreach $key ( keys %ENV ) {
55 <                if ( $key=~/^INT/ ) {
56 <                        AddDir::adddir($ENV{$key});
57 <                }
58 <           }
59 <           if ( ! -e "$ENV{LOCALTOP}/$ENV{projconfigdir}" ) {
60 <                system("cp", "-r", "$ENV{RELEASETOP}/$ENV{projconfigdir}",
61 <                                "$ENV{LOCALTOP}/$ENV{projconfigdir}");
62 <           }
63 <           use clientfile;
64 <           BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
65 <           use Cwd;
66 <           print "Installation Located at:\n".cwd()."\n";
67 <           print "Press RETURN to exit\n";
68 <           $junk=<STDIN>;
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 <         exit 1
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 < }
6 > #use Scram::SCRAM;
7 > use ActiveDoc::CommandLineInterface;
8 > use Utilities::PathMod;
9 >
10 > # Set up our scram objects
11 > $self={};
12 >
13 > # Search for configuration resource file
14 > $self->{configpath}="$ENV{HOME}:$ENV{SCRAM_HOME}/configuration";
15 > $self->{PathMod}=Utilities::PathMod->new();
16 > $self->{file}=$self->{PathMod}->SearchPath(
17 >                        $self->{configpath},".scramrc");
18 >
19 > #$self->{cli}=ActiveDoc::CommandLineInterface->new(qw(file:$self->{file} UserInterface_basic));
20 > $self->{cli}=ActiveDoc::CommandLineInterface->new(qw(Scram::SCRAM ActiveDoc::UserInterface_basic));
21 >
22 > $self->{cli}->parse(@ARGV)
23 >
24 > #@allowed_commands=qw(project build install version list arch setup runtime devtest);
25  
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 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines