197 |
|
sub coresetup() |
198 |
|
{ |
199 |
|
my $self=shift; |
200 |
< |
my ($toolname, $toolversion, $toolfile) = @_; |
200 |
> |
my ($toolname, $toolversion, $toolfile, $force) = @_; |
201 |
|
my ($toolcheck, $toolparser); |
202 |
|
|
203 |
|
print "\n"; |
213 |
|
} $self->rawtools(); |
214 |
|
|
215 |
|
# Tool not known so we create a new ToolParser object and parse it: |
216 |
< |
if ($toolcheck != 1) |
216 |
> |
if ($toolcheck != 1 || $force == 1) |
217 |
|
{ |
218 |
|
$toolparser = BuildSystem::ToolParser->new(); |
219 |
|
# We only want to store the stuff relevant for one particular version: |
220 |
|
$toolparser->parse($toolname, $toolversion, $toolfile); |
221 |
|
# Store the ToolParser object in the cache: |
222 |
|
$self->store($toolparser); |
223 |
+ |
print "\nFile $toolfile reparsed (modified)","\n",if ($ENV{SCRAM_DEBUG}); |
224 |
|
} |
225 |
|
|
226 |
|
# Next, set up the tool: |
251 |
|
my ($arealocation, $toolname, $toolversion, $toolurl) = @_; |
252 |
|
my ($urlcache, $url, $filename, $tfname); |
253 |
|
my $toolfile; |
254 |
+ |
my $force = 0; # we may have to force a reparse of a tool file |
255 |
|
|
256 |
|
$toolname =~ tr[A-Z][a-z]; |
257 |
|
$toolversion ||= $self->defaultversion($toolname); |
280 |
|
if ($proto eq 'file') |
281 |
|
{ |
282 |
|
# Check to see if there is a ~ and substitute the user |
283 |
< |
# home directory if there is: |
284 |
< |
my ($urlpath) = ($urlv =~ m|^\~/(.*)$|); |
285 |
< |
$urlv = $ENV{HOME}."/".$urlpath; |
286 |
< |
|
283 |
> |
# home directory if there is (file:~/xyz): |
284 |
> |
if (my ($urlpath) = ($urlv =~ m|^\~/(.*)$|)) |
285 |
> |
{ |
286 |
> |
$urlv = $ENV{HOME}."/".$urlpath; |
287 |
> |
} |
288 |
> |
elsif (my ($urlpath) = ($urlv =~ m|^\./(.*)$|)) |
289 |
> |
{ |
290 |
> |
# Relative to current directory (file:./xyz): |
291 |
> |
use Cwd qw(&cwd); |
292 |
> |
$urlv = cwd()."/".$urlpath; |
293 |
> |
} |
294 |
> |
|
295 |
|
# If the tool url is a file and the file exists, |
296 |
|
# copy it to .SCRAM/InstalledTools and set the |
297 |
|
# filename accordingly: |
301 |
|
copy($urlv, $filename); |
302 |
|
my $mode = 0644; chmod $mode, $filename; |
303 |
|
$toolfile=$filename; |
304 |
+ |
# Here we must account for the fact that the file tool doc may be |
305 |
+ |
# a modified version of an existing tool in the current config. we |
306 |
+ |
# make sure that this file is reparsed, even if there is already a |
307 |
+ |
# ToolParser object for the tool: |
308 |
+ |
$force = 1; |
309 |
|
} |
310 |
|
else |
311 |
|
{ |
312 |
< |
$::scram->scramerror("Unable to set up $toolname from URL $toolurl-- $urlv does not exist!"); |
312 |
> |
$::scram->scramerror("Unable to set up $toolname from URL \"$toolurl\" - $urlv does not exist!"); |
313 |
|
} |
314 |
|
} |
315 |
|
elsif ($proto eq 'http') |
318 |
|
# Download from WWW first: |
319 |
|
use LWP::Simple qw(&getstore); |
320 |
|
my $http_response_val = &getstore($toolurl, $filename); |
321 |
< |
|
321 |
> |
|
322 |
|
# Check the HTTP status. If doc not found, exit: |
323 |
|
if ($http_response_val != 200) |
324 |
|
{ |
379 |
|
} |
380 |
|
|
381 |
|
# Run the core setup routine: |
382 |
< |
$self->coresetup($toolname, $toolversion, $toolfile); |
382 |
> |
$self->coresetup($toolname, $toolversion, $toolfile,$force); |
383 |
|
return $self; |
384 |
|
} |
385 |
|
|
592 |
|
} |
593 |
|
} |
594 |
|
|
595 |
< |
sub updatecompiler() |
595 |
> |
sub updatetool() |
596 |
|
{ |
597 |
|
my $self=shift; |
598 |
< |
my ($compilername, $compilerobj) = @_; |
598 |
> |
my ($name, $obj) = @_; |
599 |
|
|
600 |
|
# Replace the existing copy of the tool with the new one: |
601 |
< |
if (exists $self->{SETUP}->{$compilername}) |
601 |
> |
if (exists $self->{SETUP}->{$name}) |
602 |
|
{ |
603 |
|
# Check to make sure that we were really passed a compiler with |
604 |
|
# the desired name: |
605 |
< |
if ($compilerobj->toolname() eq $compilername) |
605 |
> |
if ($obj->toolname() eq $name) |
606 |
|
{ |
607 |
< |
print "ToolManager: Updating the cached copy of ".$compilername."\n"; |
608 |
< |
delete $self->{SETUP}->{$compilername}; |
609 |
< |
$self->{SETUP}->{$compilername} = $compilerobj; |
607 |
> |
print "ToolManager: Updating the cached copy of ".$name."\n"; |
608 |
> |
delete $self->{SETUP}->{$name}; |
609 |
> |
$self->{SETUP}->{$name} = $obj; |
610 |
|
$self->writecache(); |
611 |
|
} |
612 |
|
else |
613 |
|
{ |
614 |
< |
print "WARNING: compiler name (".$compilername.") and tool obj name (".$compilerobj->toolname().") don't match!","\n"; |
614 |
> |
print "WARNING: Tool name (".$name.") and tool obj name (".$obj->toolname().") don't match!","\n"; |
615 |
|
print " Not making any changes.","\n"; |
616 |
|
} |
617 |
|
} |
618 |
|
else |
619 |
|
{ |
620 |
< |
print "WARNING: No entry in cache for ".$compilername.". Not making any updates.\n"; |
620 |
> |
print "WARNING: No entry in cache for ".$name.". Not making any updates.\n"; |
621 |
|
} |
622 |
|
} |
623 |
|
|