summaryrefslogtreecommitdiff
path: root/Build/TestConfig.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-14 15:52:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-14 16:07:59 -0400
commit3780a5eb0a01e3d31fc0de2410f7b01518710a0e (patch)
tree0b187086ee7cb6ed6dd1c49b4dd0871c856a27cd /Build/TestConfig.hs
parentd6adaf499124c11e3d79252821ef400d2a87b155 (diff)
move thirdparty program installation for standalone bundle into haskell program
This allows it to use Build.SysConfig to always install the programs configure detected. Amoung other fixes, this ensures the right uuid generator and checksum programs are installed. I also cleaned up the handling of lsof's path; configure now checks for it in PATH, but falls back to looking for it in sbin directories.
Diffstat (limited to 'Build/TestConfig.hs')
-rw-r--r--Build/TestConfig.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Build/TestConfig.hs b/Build/TestConfig.hs
index 92f6f6843..9937f799f 100644
--- a/Build/TestConfig.hs
+++ b/Build/TestConfig.hs
@@ -2,9 +2,14 @@
module Build.TestConfig where
+import Utility.Path
+import Utility.Monad
+
import System.IO
import System.Cmd
import System.Exit
+import System.FilePath
+import System.Directory
type ConfigKey = String
data ConfigValue =
@@ -98,6 +103,23 @@ searchCmd success failure cmdsparams = search cmdsparams
then success c
else search cs
+{- Finds a command, either in PATH or perhaps in a sbin directory not in
+ - PATH. If it's in PATH the config is set to just the command name,
+ - but if it's found outside PATH, the config is set to the full path to
+ - the command. -}
+findCmdPath :: ConfigKey -> String -> Test
+findCmdPath k command = do
+ ifM (inPath command)
+ ( return $ Config k $ MaybeStringConfig $ Just command
+ , do
+ r <- getM find ["/usr/sbin", "/sbin", "/usr/local/sbin"]
+ return $ Config k $ MaybeStringConfig r
+ )
+ where
+ find d =
+ let f = d </> command
+ in ifM (doesFileExist f) ( return (Just f), return Nothing )
+
quiet :: String -> String
quiet s = s ++ " >/dev/null 2>&1"