From: Shinjiman Date: Wed, 1 Jul 2009 13:48:11 +0000 (+0000) Subject: added whereis path support instead of the hardcoded local binary path to get the... X-Git-Tag: 1.31.0-rc.0~41152 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=30b850f740b4112547ad7fea8a93dbb678e66b9d;p=lhc%2Fweb%2Fwiklou.git added whereis path support instead of the hardcoded local binary path to get the directory of executeable files, when available. link to r52547, r52527 and r52525 for CodeReview if any comments are added. --- diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index a4b6dbd313..414aa8ae16 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -203,7 +203,6 @@ class SpecialVersion extends SpecialPage { // Look for TeX support and print the software version info if ( $wgUseTeX ) { $binPath = '/usr/bin/'; - $binPathLocal = '/usr/local/bin/'; $swMathName = Array( 'ocaml' => 'OCaml', 'gs' => 'Ghostscript', @@ -233,7 +232,15 @@ class SpecialVersion extends SpecialPage { 'imagemagick' => '-version', ); foreach ( $swMathExec as $swMath => $swMathCmd ) { - if ( file_exists( $binPath . $swMathCmd ) || file_exists( $binPathLocal . $swMathCmd ) ) { + $wBinPath = ''; + if ( file_exists( $binPath . 'whereis' ) ) { + $swWhereIsInfo = self::execOutput( $binPath . 'whereis -b ' . $swMathCmd ); + $swWhereIsLine = explode( "\n", $swWhereIsInfo, 2); + $swWhereIsFirstLine = $swWhereIsLine[0]; + $swWhereIsBinPath = explode( ' ', $swWhereIsFirstLine, 3); + $wBinPath = dirname( $swWhereIsBinPath[1] ); + } + if ( file_exists( $binPath . $swMathCmd ) || file_exists( $wBinPath . $swMathCmd ) ) { $swMathInfo = self::execOutput( $swMathCmd . ' ' . $swMathParam[$swMath] ); $swMathLine = explode( "\n", $swMathInfo, 2); $swMathVerInfo = $swMathLine[0]; @@ -246,8 +253,8 @@ class SpecialVersion extends SpecialPage { list( $head, $tail ) = explode( 'ImageMagick', $swMathVerInfo ); list( $swMathVerInfo ) = explode('http://www.imagemagick.org', $tail ); } - $swMathVer[$swMath] = $swMathVerInfo; - $software["[$swMathURL[$swMath] $swMathName[$swMath]]"] = trim ( $swMathVer[$swMath] ); + $swMathVer[$swMath] = trim( $swMathVerInfo ); + $software["[$swMathURL[$swMath] $swMathName[$swMath]]"] = $swMathVer[$swMath]; } } }