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 |
64 |
|
|
65 |
|
sub addarea { |
66 |
|
my $self=shift; |
67 |
+ |
my $name=shift; |
68 |
+ |
my $version=shift; |
69 |
|
my $area=shift; |
70 |
|
|
71 |
< |
my $name=$area->name(); |
72 |
< |
my $version=$area->version(); |
73 |
< |
my $type="_location"; |
74 |
< |
my $url=$area->location(); |
75 |
< |
push @{$self->{projects}}, [ ($name,$version,$type,$url) ]; |
71 |
> |
my $rv=1; |
72 |
> |
|
73 |
> |
#my $type="_location"; not ready for this yet |
74 |
> |
my $type="file"; |
75 |
> |
my $url=$area->location()."/.SCRAM/InstallFile"; |
76 |
> |
# -- check for duplicates |
77 |
> |
for ( my $index=0; $index<=$#{$self->{projects}}; $index++ ) { |
78 |
> |
if ( $self->{projects}[$index][0] eq $name ) { |
79 |
> |
if ( $self->{projects}[$index][1] eq $version ) { |
80 |
> |
print "$name $version alreay exists. Overwrite (y/n)\n"; |
81 |
> |
if ( ! (<STDIN>=~/y/i ) ) { |
82 |
> |
print "Aborting install ...\n"; |
83 |
> |
return 1; |
84 |
> |
} |
85 |
> |
else { |
86 |
> |
$rv=0; |
87 |
> |
$self->{projects}[$index]=[ ($name,$version,$type,$url) ]; |
88 |
> |
} |
89 |
> |
} |
90 |
> |
else { |
91 |
> |
print "Related Project : $name ".$self->{projects}[$index][1]."\n"; |
92 |
> |
} |
93 |
> |
} |
94 |
> |
} |
95 |
> |
if ( $rv ) { |
96 |
> |
# -- add to our list and save |
97 |
> |
push @{$self->{projects}}, [ ($name,$version,$type,$url) ]; |
98 |
> |
} |
99 |
|
$self->_save(); |
100 |
+ |
return 0; |
101 |
|
} |
102 |
|
|
103 |
|
sub list { |
147 |
|
|
148 |
|
use FileHandle; |
149 |
|
my $fh=FileHandle->new(); |
150 |
< |
my $filename=$self->{dbfile}."_tmp"; |
150 |
> |
my $filename=$self->{dbfile}; |
151 |
|
open ( $fh, ">$filename" ); |
152 |
|
# print current links |
153 |
|
foreach $db ( @{$self->{linkeddbs}} ) { |
157 |
|
my $temp; |
158 |
|
foreach $elem ( @{$self->{projects}} ) { |
159 |
|
$temp=join ":", @{$elem}; |
160 |
< |
print $fh $temp; |
160 |
> |
print $fh $temp."\n"; |
161 |
|
} |
162 |
|
undef $fh; |
163 |
|
} |