cab 0.2.6 → 0.2.7
raw patch · 2 files changed
+22/−3 lines, 2 files
Files
- Distribution/Cab/Commands.hs +21/−2
- cab.cabal +1/−1
Distribution/Cab/Commands.hs view
@@ -8,7 +8,7 @@ import Control.Applicative hiding (many) import Control.Monad import Data.Char-import Data.List (isPrefixOf, intercalate)+import Data.List (isPrefixOf, isSuffixOf, intercalate) import qualified Data.Map as M import Distribution.Cab.GenPaths import Distribution.Cab.PkgDB@@ -97,10 +97,29 @@ mapM_ (hPutStrLn stderr . fullNameOfPkgInfo) (init sortedPkgs) else do unless doit $ putStrLn "The following packages are deleted without the \"-n\" option."- mapM_ (unregister doit opts . pairNameOfPkgInfo) sortedPkgs+ mapM_ (purge doit opts . pairNameOfPkgInfo) sortedPkgs where onlyOne = OptRecursive `notElem` opts doit = OptNoharm `notElem` opts++purge :: Bool -> [Option] -> (String,String) -> IO ()+purge doit opts (name,ver) = do+-- putStrLn $ "Deleting " ++ name ++ " " ++ ver+ sandboxOpts <- (makeOptList . getSandboxOpts2) <$> getSandbox+ libdirs <- queryGhcPkg sandboxOpts "library-dirs"+ haddoc <- cutTrailing "html" `fmap` queryGhcPkg sandboxOpts "haddock-html"+ unregister doit opts (name,ver)+ putStrLn $ unwords ["Deleting 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]+ unwords . tail . words <$> readProcess "ghc-pkg" options ""+ cutTrailing suffix s+ | suffix `isSuffixOf` s = reverse . drop (length suffix) . reverse $ s+ | otherwise = s unregister :: Bool -> [Option] -> (String,String) -> IO () unregister doit _ (name,ver) =
cab.cabal view
@@ -1,5 +1,5 @@ Name: cab-Version: 0.2.6+Version: 0.2.7 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3