diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php
index 5658728c6a0..233bf9be7fd 100644
--- a/htdocs/admin/tools/update.php
+++ b/htdocs/admin/tools/update.php
@@ -75,20 +75,33 @@ if (GETPOST('action','alpha')=='install')
$result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']);
if ($result > 0)
{
- $rutax=DOL_DOCUMENT_ROOT_ALT;
- $result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$rutax);
- if ($result==2)
+ $documentrootalt=DOL_DOCUMENT_ROOT_ALT;
+ $result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$documentrootalt);
+ if (! empty($result['error']))
{
- $langs->load("errors");
- $mesg = "".$langs->trans("ErrorOSSystem")."";
+ if ($result['error'] == -1)
+ {
+ $langs->load("errors");
+ $mesg = '
'.$langs->trans("ErrorBadFileFormat").'
';
+ }
+ elseif ($result['error'] == -2)
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorOSSystem").'
';
+ }
+ elseif ($result['error'] == -3)
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name']).'
';
+ }
+ elseif ($result['error'] == -4)
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name']).'
';
+ }
}
- elseif ($result==3)
+ else
{
- $langs->load("errors");
- $mesg = "".$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name'])."";
- }
-
- else {
$mesg = "".$langs->trans("SetupIsReadyForUse")."";
}
}
@@ -146,7 +159,7 @@ print ''.$langs->trans("StepNb",3).': ';
print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'
';
if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE))
{
- if ($vale == 1 && $dirins != 'DOL_DOCUMENT_ROOT_ALT' && ($system=="Linux"))
+ if ($vale == 1 && $dirins != 'DOL_DOCUMENT_ROOT_ALT' && ($system=="Linux" || $system=="Darwin"))
{
print '';
+if (! empty($result['return']))
+{
+ print '
';
+
+ foreach($result['return'] as $value)
+ {
+ echo $value.'
';
+ }
+}
+
llxFooter();
$db->close();
?>
\ No newline at end of file
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 40897263a4f..85cd1c1eb7e 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -629,14 +629,16 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
function dol_uncompress($newfile,$typefile,$dstdir)
{
global $conf;
- $error=0;
+
+ $error=0;
+ $output=array();
$system=PHP_OS;
//TODO: See best method for this
- if ($system=="Linux")
+ if ($system=="Linux" || $system=="Darwin")
{
- if ($typefile == 'application/x-gzip')
+ if ($typefile == 'application/x-gzip' || $typefile == 'application/x-gtar')
{
$prog= "tar -xzvf ";
}
@@ -646,22 +648,33 @@ function dol_uncompress($newfile,$typefile,$dstdir)
}
else
{
- $error=1;
+ $output['error'] = -1;
+ $error++;
}
}
else
{
- $error=2;
+ $output['error'] = -2;
+ $error++;
}
- $original_file=basename($_FILES["fileinstall"]["name"]);
- $diruncom=$conf->admin->dir_temp.'/'.$original_file;
- $ruta=$diruncom.'/'.$original_file;
- chdir ($dstdir);
- $command= $prog.$ruta;
- $res=exec($command);
- if (! $res) $error=3;
- return $error;
+ if (! $error)
+ {
+ $original_file=basename($_FILES["fileinstall"]["name"]);
+ $dir=$conf->admin->dir_temp.'/'.$original_file;
+ $file=$dir.'/'.$original_file;
+ $command= $prog.$file.' 2>&1';
+
+ chdir($dstdir);
+
+ exec($command, $out, $return_var);
+ if ($return_var == 1) $output['error'] = -3; // OK with Warning
+ elseif ($return_var == 127) $output['error'] = -4; // KO
+
+ $output['return'] = $out;
+ }
+
+ return $output;
}
/**