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.5 by williamc, Wed Mar 3 17:04:14 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 -I$SCRAM_HOME/src -I/afs/cern.ch/user/w/williamc/public/SCRAM/src
2 <
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?
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 <        use Utilities::AddDir;
37 <        
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 <                        AddDir::adddir($ENV{$key});
53 <                }
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 <        use Utilities::setarchitecture;
66 <        my $name;
67 <        my $value;
68 <
69 <        $ENV{LatestBuildFile}=""; # stop recursive behaviour in make
70 <        setarchitecture::setarch();
71 <        $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 <         $ENV{SCRAM_HOME}="/afs/cern.ch/user/w/williamc/public/SCRAM";
79 <         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 <                $ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration";
84 <        }
85 <        if ( ! ( exists $ENV{TOOL_HOME} ) ){
86 <                $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
87 <        }
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 < }
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