Skip to content

Commit

Permalink
Patch for a patch: option for sandbox work on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgajda committed Jan 15, 2014
1 parent d89bbba commit ca12b44
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Distribution/Cab/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,17 @@ uninstall nmver opts _ = do
purge :: Bool -> [Option] -> (String,String) -> IO ()
purge doit opts (name,ver) = do
putStrLn $ "Deleting " ++ name ++ " " ++ ver
sandboxOpts <- getSandboxOpts2 <$> getSandbox
sandboxOpts <- (makeOptList . getSandboxOpts2) <$> getSandbox
libdirs <- queryGhcPkg sandboxOpts "library-dirs"
haddoc <- cutTrailing "html" `fmap` queryGhcPkg sandboxOpts "haddock-html"
unregister doit opts (name,ver)
putStrLn $ unwords ["Removing dirs:", libdirs, haddoc]
when doit . void . system . unwords $ ["rm -rf ", libdirs, haddoc]

where
makeOptList "" = []
makeOptList x = [x]
queryGhcPkg sandboxOpts field = do
let options = ["field", sandboxOpts, name ++ "-" ++ ver, field]
let options = ["field"] ++ sandboxOpts ++ [name ++ "-" ++ ver, field]
unwords . tail . words <$> readProcess "ghc-pkg" options ""
cutTrailing suffix s
| suffix `isSuffixOf` s = reverse . drop (length suffix) . reverse $ s
Expand Down

0 comments on commit ca12b44

Please sign in to comment.