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