More for GHC 6.10

This commit is contained in:
alson
2009-01-31 23:29:21 +00:00
parent 9d431c68a3
commit a0391e5cd3
3 changed files with 9 additions and 35 deletions

View File

@ -52,11 +52,11 @@ module System.Plugins.Env (
import System.Plugins.LoadTypes (Module)
import System.Plugins.PackageAPI {- everything -}
import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix )
import System.Plugins.Consts ( sysPkgConf, sysPkgSuffix )
import Data.IORef ( writeIORef, readIORef, newIORef, IORef() )
import Data.Maybe ( isJust, isNothing, fromMaybe )
import Data.List ( isPrefixOf, isInfixOf, nub )
import Data.List ( isInfixOf, nub )
import System.IO.Unsafe ( unsafePerformIO )
import System.IO ( hGetContents )
@ -311,35 +311,10 @@ grabDefaultPkgConf = do
--
readPackageConf :: FilePath -> IO [PackageConfig]
readPackageConf f = do
-- s <- readFile f
-- let p = map parseInstalledPackageInfo $ splitPkgs s
-- return $ flip map p $ \p' -> case p' of
-- ParseFailed e -> error $ show e
-- ParseOk _ c -> expand_libdir c
pc <- configureAllKnownPrograms silent defaultProgramConfiguration
pkgIndex <- getInstalledPackages silent (SpecificPackageDB f) pc
return $ allPackages pkgIndex
where
expand_libdir :: PackageConfig -> PackageConfig
expand_libdir pk =
let pk' = updImportDirs (\idirs -> map expand idirs) pk
pk'' = updLibraryDirs (\ldirs -> map expand ldirs) pk'
in pk''
expand :: FilePath -> FilePath
expand s | "$libdir" `isPrefixOf` s = ghcLibraryPath ++ drop 7 s
expand s = s
splitPkgs :: String -> [String]
splitPkgs = map unlines . splitWith ("---" ==) . lines
where
splitWith :: (a -> Bool) -> [a] -> [[a]]
splitWith p xs = ys : case zs of
[] -> []
_:ws -> splitWith p ws
where (ys,zs) = break p xs
-- -----------------------------------------------------------
-- Static package management stuff. A static package is linked with the base
-- application and we should therefore not link with any of the DLLs it requires.

View File

@ -14,7 +14,7 @@ import Control.Concurrent (forkIO)
import qualified Posix as P
#endif
import qualified Control.Exception
import qualified Control.OldException as E
--
-- slight wrapper over popen for calls that don't care about stdin to the program
@ -38,7 +38,7 @@ type ProcessID = ProcessHandle
--
popen :: FilePath -> [String] -> Maybe String -> IO (String,String,ProcessID)
popen file args minput =
Control.Exception.handle (\e -> return ([],show e,error (show e))) $ do
E.handle (\e -> return ([],show e, error (show e))) $ do
(inp,out,err,pid) <- runInteractiveProcess file args Nothing Nothing
@ -55,8 +55,8 @@ popen file args minput =
-- data gets pulled as it becomes available. you have to force the
-- output strings before waiting for the process to terminate.
--
forkIO (Control.Exception.evaluate (length output) >> return ())
forkIO (Control.Exception.evaluate (length errput) >> return ())
forkIO (E.evaluate (length output) >> return ())
forkIO (E.evaluate (length errput) >> return ())
-- And now we wait. We must wait after we read, unsurprisingly.
exitCode <- waitForProcess pid -- blocks without -threaded, you're warned.
@ -79,7 +79,7 @@ popen file args minput =
--
popen :: FilePath -> [String] -> Maybe String -> IO (String,String,P.ProcessID)
popen f s m =
Control.Exception.handle (\e -> return ([], show e, error $ show e )) $ do
E.handle (\e -> return ([], show e, error $ show e )) $ do
x@(_,_,pid) <- P.popen f s m
b <- P.getProcessStatus True False pid -- wait
return $ case b of