From 4c7b5746f4abb5e5abc0e9e4be85e7df77a676bb Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Thu, 27 Mar 2025 15:12:31 +0100 Subject: [PATCH] workaround for ms windows dowload with wget --- inc_functions.php | 84 +++++++++++++++++++++++------------------------ installer.php | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/inc_functions.php b/inc_functions.php index 98f016b..0de2d8f 100644 --- a/inc_functions.php +++ b/inc_functions.php @@ -64,57 +64,57 @@ function _chdir(string $sDir): void * * @return int */ -function _exec(string $cmd, bool $bAbortOnError=true): int +function _exec(string $cmd, bool $bAbortOnError=true, $bForceExec=false): int { global $aCol; echo "$aCol[blue]cmd > $cmd$aCol[reset]\n"; $iStart=microtime(true); - /* - exec("$cmd 2>&1", $aOut, $rc); - $iEnd=microtime(true); - if (!count($aOut)) { - $aOut = ["-- no output --"]; - } - echo implode("\n", $aOut) . "\n"; - */ - - // show output in real-time - $descriptorspec = [ - 0 => ["pipe", "r"], // stdin - 1 => ["pipe", "w"], // stdout - 2 => ["pipe", "w"] // stderr - ]; - - $process = proc_open($cmd, $descriptorspec, $pipes); - - if (is_resource($process)) { - // Close stdin pipe - fclose($pipes[0]); - - // Read stdout and stderr in real-time - while ($output = fgets($pipes[1])) { - echo " | $output"; - flush(); - } - fclose($pipes[1]); - - while ($error = fgets($pipes[2])) { - echo " 2| $error"; - flush(); - } - fclose($pipes[2]); - - // Close the process - $rc=proc_close($process); + if($bForceExec) { + exec("$cmd 2>&1", $aOut, $rc); $iEnd=microtime(true); + if (!count($aOut)) { + $aOut = ["-- no output --"]; + } + echo implode("\n", $aOut) . "\n"; } else { - if($bAbortOnError){ - _abort("Unable to execute command."); + + // show output in real-time + $descriptorspec = [ + 0 => ["pipe", "r"], // stdin + 1 => ["pipe", "w"], // stdout + 2 => ["pipe", "w"] // stderr + ]; + + $process = proc_open($cmd, $descriptorspec, $pipes); + + if (is_resource($process)) { + // Close stdin pipe + fclose($pipes[0]); + + // Read stdout and stderr in real-time + while ($output = fgets($pipes[1])) { + echo " | $output"; + flush(); + } + fclose($pipes[1]); + + while ($error = fgets($pipes[2])) { + echo " 2| $error"; + flush(); + } + fclose($pipes[2]); + + // Close the process + $rc=proc_close($process); + $iEnd=microtime(true); + } else { + if($bAbortOnError){ + _abort("Unable to execute command."); + } + _skip("Unable to execute command."); } - _skip("Unable to execute command."); } - $sTime= "... â±ï¸ Time: " . round($iEnd-$iStart, 3) . "s\n"; if ($rc != 0) { diff --git a/installer.php b/installer.php index 4abdbaa..7e9e55e 100755 --- a/installer.php +++ b/installer.php @@ -163,7 +163,7 @@ _exec("php -l \"$incfile\""); _h1("Get / update spc"); _chdir("$selfdir/$dirExternal/bin"); if(!file_exists($SPC)){ - _exec("wget -O $SPC \"$spcUrl\""); + _exec("wget -O $SPC \"$spcUrl\"", true, ($myos == "windows")); } else { _skip("download of spc."); } -- GitLab