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

Comparing COMP/SCRAM/src/Scram/ScramProjectDB.pm (file contents):
Revision 1.1.2.2 by williamc, Thu May 4 07:53:18 2000 UTC vs.
Revision 1.1.2.3.2.1 by williamc, Mon Aug 7 09:55:36 2000 UTC

# Line 12 | Line 12
12   # new(dbfile)              : A new dbobject object
13   # file()                   : return the db file
14   # getarea(name,version) : return the object matching the name version
15 < # addarea(ConfigArea)   : add a project
15 > # addarea(ConfigArea)   : add a project - return 0 for success 1 for abort
16   # list()                : list areas (retunns $name,$version pairs)
17   # removearea(name,version) : remove the named project
18   # link(dblocation) : link with specified db
# Line 29 | Line 29 | sub new {
29          bless $self, $class;
30          $self->{dbfile}=shift;
31          $self->_readdbfile($self->{dbfile});
32 +        $self->{projectobjects}={};
33          return $self;
34   }
35  
# Line 46 | Line 47 | sub getarea {
47          my $index=$self->_findlocal($name,$version);
48          if ( $index != -1 ) {  
49           my $location=$self->{projects}[$index][3];
50 +         if ( defined $self->{projectobjects}{$location} ) {
51 +           $area=$self->{projectobjects}{$location};
52 +         }
53 +         else {
54           $area=Configuration::ConfigArea->new();
55           $self->verbose("Attempt to ressurect $name $version from $location");
56           if ( $area->bootstrapfromlocation($location) == 1 ) {
# Line 54 | Line 59 | sub getarea {
59           }
60           else {
61             $self->verbose("area found");
62 +           $self->{projectobjects}{$location}=$area;
63 +         }
64           }
65          }
66          else {
# Line 64 | Line 71 | sub getarea {
71  
72   sub addarea {
73          my $self=shift;
74 +        my $name=shift;
75 +        my $version=shift;
76          my $area=shift;
77  
78 <        my $name=$area->name();
79 <        my $version=$area->version();
80 <        my $type="_location";
81 <        my $url=$area->location();
82 <        push @{$self->{projects}}, [ ($name,$version,$type,$url) ];
78 >        my $rv=1;
79 >
80 >        #my $type="_location"; not ready for this yet
81 >        my $type="file";
82 >        my $url=$area->location()."/.SCRAM/InstallFile";
83 >        # -- check for duplicates
84 >        for ( my $index=0; $index<=$#{$self->{projects}}; $index++ ) {
85 >         if  ( $self->{projects}[$index][0] eq $name ) {
86 >          if ( $self->{projects}[$index][1] eq $version ) {
87 >            print "$name $version alreay exists. Overwrite (y/n)\n";
88 >            if ( ! (<STDIN>=~/y/i ) ) {
89 >                        print "Aborting install ...\n";
90 >                        return 1;
91 >            }
92 >            else {
93 >               $rv=0;
94 >               $self->{projects}[$index]=[ ($name,$version,$type,$url) ];
95 >            }
96 >          }
97 >          else {
98 >            print "Related Project : $name ".$self->{projects}[$index][1]."\n";
99 >          }
100 >         }
101 >        }
102 >        if ( $rv ) {
103 >           # -- add to our list and save
104 >           push @{$self->{projects}}, [ ($name,$version,$type,$url) ];
105 >        }
106          $self->_save();
107 +        return 0;
108   }
109  
110   sub list {
# Line 121 | Line 154 | sub _save {
154  
155          use FileHandle;
156          my $fh=FileHandle->new();
157 <        my $filename=$self->{dbfile}."_tmp";
157 >        my $filename=$self->{dbfile};
158          open ( $fh, ">$filename" );
159          # print current links
160          foreach $db ( @{$self->{linkeddbs}} ) {
# Line 131 | Line 164 | sub _save {
164          my $temp;
165          foreach $elem ( @{$self->{projects}} ) {
166            $temp=join ":", @{$elem};
167 <          print $fh $temp;
167 >          print $fh $temp."\n";
168          }
169          undef $fh;
170   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines