ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/ConfigArea.pm
(Generate patch)

Comparing COMP/SCRAM/src/Configuration/ConfigArea.pm (file contents):
Revision 1.13.2.1 by williamc, Tue Apr 25 11:38:31 2000 UTC vs.
Revision 1.13.2.2 by williamc, Thu Apr 27 11:43:54 2000 UTC

# Line 15 | Line 15
15   # Interface
16   # ---------
17   # new()                         : A new ConfigArea object
18 # top()                         : return the very top directory of the area
18   # location([dir])               : set/return the location of the work area
19   # bootstrapfromlocation([location]): bootstrap the object based on location.
20   #                                 no location specified - cwd used
21 + #                                 return 0 if succesful 1 otherwise
22   # searchlocation([startdir])    : returns the location directory. search starts
23   #                                 from cwd if not specified
24   # defaultdirname()              : return the default directory name string
# Line 26 | Line 26
26   #                                 area
27   # configurationdir()            : return the location of the project
28   #                                 configuration directory
29 + # copy(location)                : copy a configuration
30 + # copysetup(location)           : copy the architecture specific tool setup
31 + #                                 returns 0 if successful, 1 otherwise
32 + # copyenv($ref)                 : copy the areas environment into the hashref
33  
34   package Configuration::ConfigArea;
35   require 5.004;
# Line 38 | Line 42 | sub new {
42          my $class=shift;
43          my $self={};
44          bless $self, $class;
41        return $self;
42 }
45  
46 < sub top {
47 <        my $self=shift;
46 <        use File::Basename;
46 >        # data init
47 >        $self->{admindir}=".SCRAM";
48  
49 <        return dirname($self->location());
49 >        return $self;
50   }
51  
52   sub configurationdir {
# Line 63 | Line 64 | sub configurationdir {
64   sub scramversion {
65          my $self=shift;
66          if ( ! defined $self->{scramversion} ) {
67 <          my $filename=$self->top()."/".$self->configurationdir()."/".
67 >          my $filename=$self->location()."/".$self->configurationdir()."/".
68                                                          "scram_version";
69            if ( -f $filename ) {
70              use FileHandle;
# Line 80 | Line 81 | sub scramversion {
81  
82   sub bootstrapfromlocation {
83          my $self=shift;
84 +
85 +        my $rv=0;
86          
87          if ( ! defined $self->location(@_) ) {
88 <          $self->error("Unable to locate the top of local configuration area");
88 >         $rv=1;
89 >         $self->verbose("Unable to locate the top of local configuration area");
90 >        }
91 >        else {
92 >         $self->verbose("Found top ".$self->location());
93 >         my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat";
94 >         $self->_LoadEnvFile();
95          }
96 <        $self->verbose("Found top ".$self->location());
88 <        my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat";
96 >        return $rv;
97   }
98  
99   sub location {
# Line 124 | Line 132 | sub searchlocation {
132          return $rv?$thispath:undef;
133   }
134  
135 + sub copy {
136 +        my $self=shift;
137 +        my $destination=shift;
138 +
139 +        # copy across the admin dir
140 +        my $temp=$self->location()."/".$self->{admindir};
141 +        AddDir::copydir($temp,"$destination/".$self->{admindir});
142 + }
143 +
144 + sub copysetup {
145 +        my $self=shift;
146 +        my $dest=shift;
147 +
148 +        my $rv=1;
149 +        # copy across the admin dir
150 +        my $temp=$self->location()."/".$self->{admindir}."/".$self->arch();
151 +        my $temp2=$dest."/".$self->{admindir}."/".$self->arch();
152 +        if ( $temp ne $temp2 ) {
153 +         if ( -d $temp ) {
154 +          AddDir::copydir($temp,$temp2);
155 +          $rv=0;
156 +         }
157 +        }
158 +        return $rv;
159 + }
160 +
161 + sub copyenv {
162 +        my $self=shift;
163 +        my $hashref=shift;
164 +        
165 +        foreach $elem ( keys %{$self->{ENV}} ) {
166 +           $$hashref{$elem}=$self->{ENV}{$elem};
167 +        }
168 + }
169 +
170 + sub arch {
171 +        my $self=shift;
172 +        return $ENV{SCRAM_ARCH};
173 + }
174 +
175   # ---- support routines
176   sub _LoadEnvFile {
177          my $self=shift;
178  
179          use FileHandle;
180          my $fh=FileHandle->new();
181 <        open ( $fh, "<".$self->location()."/Environment" );
181 >        open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
182 >                "Environment" ) or
183 >                $self->error("Area Corrupted ".$self->location());
184          while ( <$fh> ) {
185             chomp;
186             next if /^#/;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines