From 30b850f740b4112547ad7fea8a93dbb678e66b9d Mon Sep 17 00:00:00 2001 From: Shinjiman Date: Wed, 1 Jul 2009 13:48:11 +0000 Subject: [PATCH] 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. --- includes/specials/SpecialVersion.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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]; } } } -- 2.20.1