Index: ../../lib/Ocsinventory/Agent/Option/Download.pm =================================================================== RCS file: /cvsroot/ocsinventory/unified_unix_agent/lib/Ocsinventory/Agent/Option/Download.pm,v retrieving revision 1.11 diff -u -r1.11 Download.pm --- ../../lib/Ocsinventory/Agent/Option/Download.pm 11 Jun 2008 17:12:35 -0000 1.11 +++ ../../lib/Ocsinventory/Agent/Option/Download.pm 25 Jun 2008 01:14:02 -0000 @@ -31,6 +31,9 @@ use Socket; use Net::SSLeay qw(die_now die_if_ssl_error); +# # include the backend logger for work-around logging +use Ocsinventory::Logger; + # Can be missing. By default, we use MD5 # You have to install it if you want to use SHA1 digest eval{ require Digest::SHA1 }; @@ -60,16 +63,21 @@ my $config; my $error; my $debug; +my $logger; # Read prolog response sub download_prolog_reader{ $current_context = shift; my $prolog = shift; - $debug = $::debug; - - &log($prolog); - + $logger = $current_context->{'OCS_AGENT_LOGGER'}; + + # terrible, I know, but somewhow we need to find the name of the vardir that was created and copy + # our cacert.pem there... the installer script moves it to /var/lib, then this moves it into the right directory + unless(-e $current_context->{'vardir'}.'/cacert.pem'){ + system("cp /var/lib/ocsinventory-agent/cacert.pem $current_context->{'OCS_AGENT_INSTALL_PATH'}/cacert.pem"); + } + $prolog = XML::Simple::XMLin( $prolog, ForceArray => ['OPTION', 'PARAM']); my $option; # Create working directory @@ -637,7 +645,10 @@ if(-e $p->{'NAME'}){ &log("Launching $p->{'NAME'}..."); chmod(0755, $p->{'NAME'}) or die("Cannot chmod: $!"); - $exit_code = system( "./".$exe_line ); + my $cmd = "installer -target / -pkg ./".$exe_line; + &log('launching installer with cmd: '.$cmd); + $exit_code = system($cmd); + unless($exit_code == 0) { &log('installer fialed'); die(); } }else{ die(); } @@ -665,7 +676,7 @@ &log("Storing package to $p->{'PATH'}..."); # Stefano Brandimarte => Stevenson! - system(&_get_path('cp')." -dpr * ".$p->{'PATH'}) and die(); + system(&_get_path('cp')." -R * ".$p->{'PATH'}) and die(); } }; if($@){ @@ -703,7 +714,7 @@ if(-f "./$id/$id-$i"){ # We make a tmp working directory if($i==1){ - open PACKAGE, ">$tmp/build.tar.gz" or return 1; + open PACKAGE, ">$tmp/build.zip" or return 1; } # We write each fragment in the final package open FRAGMENT, "./$id/$id-$i" or return 1; @@ -718,18 +729,18 @@ } close(PACKAGE); # - if(check_signature($p->{'DIGEST'}, "$tmp/build.tar.gz", $p->{'DIGEST_ALGO'}, $p->{'DIGEST_ENCODE'})){ + if(check_signature($p->{'DIGEST'}, "$tmp/build.zip", $p->{'DIGEST_ALGO'}, $p->{'DIGEST_ENCODE'})){ download_message($p, ERR_BAD_DIGEST); return 1; } - if( system( &_get_path("tar")." -xvzf $tmp/build.tar.gz -C $tmp") ){ + if( system( &_get_path("unzip")." -o $tmp/build.zip -d $tmp/") ){ &log("Cannot extract $p->{'ID'}."); download_message($p, ERR_BUILD); return 1; } &log("Building of $p->{'ID'}... Success."); - unlink("$tmp/build.tar.gz") or die ("Cannot remove build file: $!\n"); + unlink("$tmp/build.zip") or die ("Cannot remove build file: $!\n"); return 0; } @@ -900,9 +911,19 @@ } sub log{ - return 0 unless $debug; + #return 0 unless $debug; my $message = shift; - print "DOWNLOAD: $message\n"; -} + my ($package, $filename, $line, $subr, $has_args, $wantarray) = caller(1); + my $name = $0; + if ($name =~ /([^\/]+)$/) { + $name = $1; + } + $package = "$name" unless defined($package); + $subr = "$name(main)" unless defined($subr); + $line = (caller(0))[2] unless defined($line); + + my $s = sprintf("[DOWNLOAD] ${subr} [$line]: %s", $message); + $logger->debug($s); +} 1;