diff options
author | Joey Hess <joey@kitenet.net> | 2012-12-14 15:52:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-12-14 16:07:59 -0400 |
commit | 3780a5eb0a01e3d31fc0de2410f7b01518710a0e (patch) | |
tree | 0b187086ee7cb6ed6dd1c49b4dd0871c856a27cd /Utility/Lsof.hs | |
parent | d6adaf499124c11e3d79252821ef400d2a87b155 (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 'Utility/Lsof.hs')
-rw-r--r-- | Utility/Lsof.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Utility/Lsof.hs b/Utility/Lsof.hs index 72f3e5815..9a877a3c9 100644 --- a/Utility/Lsof.hs +++ b/Utility/Lsof.hs @@ -10,8 +10,10 @@ module Utility.Lsof where import Common +import Build.SysConfig as SysConfig import System.Posix.Types +import System.Posix.Env data LsofOpenMode = OpenReadWrite | OpenReadOnly | OpenWriteOnly | OpenUnknown deriving (Show, Eq) @@ -21,6 +23,17 @@ type CmdLine = String data ProcessInfo = ProcessInfo ProcessID CmdLine deriving (Show) +{- lsof is not in PATH on all systems, so SysConfig may have the absolute + - path where the program was found. Make sure at runtime that lsof is + - available, and if it's not in PATH, adjust PATH to contain it. -} +setupLsof :: IO () +setupLsof = do + let cmd = fromMaybe "lsof" SysConfig.lsof + when (isAbsolute cmd) $ do + path <- getSearchPath + let path' = takeDirectory cmd : path + setEnv "PATH" (join [searchPathSeparator] path') True + {- Checks each of the files in a directory to find open files. - Note that this will find hard links to files elsewhere that are open. -} queryDir :: FilePath -> IO [(FilePath, LsofOpenMode, ProcessInfo)] |