cab 0.2.15 → 0.2.16
raw patch · 5 files changed
+81/−32 lines, 5 filesdep ~CabalPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: Cabal
API changes (from Hackage documentation)
- Distribution.Cab.VerDB: instance Eq VerDB
- Distribution.Cab.VerDB: instance Show VerDB
- Distribution.Cab.Version: instance Eq Ver
- Distribution.Cab.Version: instance Ord Ver
- Distribution.Cab.Version: instance Read Ver
- Distribution.Cab.Version: instance Show Ver
+ Distribution.Cab.VerDB: instance GHC.Classes.Eq Distribution.Cab.VerDB.VerDB
+ Distribution.Cab.VerDB: instance GHC.Show.Show Distribution.Cab.VerDB.VerDB
+ Distribution.Cab.Version: instance GHC.Classes.Eq Distribution.Cab.Version.Ver
+ Distribution.Cab.Version: instance GHC.Classes.Ord Distribution.Cab.Version.Ver
+ Distribution.Cab.Version: instance GHC.Read.Read Distribution.Cab.Version.Ver
+ Distribution.Cab.Version: instance GHC.Show.Show Distribution.Cab.Version.Ver
- Distribution.Cab.PkgDB: type PkgDB = PackageIndex
+ Distribution.Cab.PkgDB: type PkgDB = InstalledPackageIndex
Files
- Distribution/Cab/Commands.hs +2/−2
- Distribution/Cab/PkgDB.hs +10/−6
- Distribution/Cab/Printer.hs +23/−22
- Distribution/Cab/Utils.hs +44/−0
- cab.cabal +2/−2
Distribution/Cab/Commands.hs view
@@ -126,9 +126,9 @@ getDirs :: (String,String) -> [String] -> IO [FilePath] getDirs (name,ver) sandboxOpts = do- libdirs <- queryGhcPkg "library-dirs"+ importDirs <- queryGhcPkg "import-dirs" haddock <- map docDir <$> queryGhcPkg "haddock-html"- return $ topDir $ libdirs ++ haddock+ return $ topDir $ importDirs ++ haddock where nameVer = name ++ "-" ++ ver queryGhcPkg field = do
Distribution/Cab/PkgDB.hs view
@@ -21,12 +21,12 @@ , verOfPkgInfo ) where -import Distribution.Cab.Utils (fromDotted)+import Distribution.Cab.Utils (fromDotted, installedUnitId) import Distribution.Cab.Version import Distribution.Cab.VerDB (PkgName) import Distribution.Version (Version(..)) import Distribution.InstalledPackageInfo- (InstalledPackageInfo_(..), InstalledPackageInfo)+ (InstalledPackageInfo, sourcePackageId) import Distribution.Package (PackageName(..), PackageIdentifier(..)) import Distribution.Simple.Compiler (PackageDB(..)) import Distribution.Simple.GHC (configure, getInstalledPackages, getPackageDBContents)@@ -74,8 +74,12 @@ getDBs :: [PackageDB] -> IO PkgDB getDBs specs = do- (_,_,pro) <- configure normal Nothing Nothing defaultProgramDb- getInstalledPackages normal specs pro+ (_comp,_,pro) <- configure normal Nothing Nothing defaultProgramDb+ getInstalledPackages normal+#if MIN_VERSION_Cabal(1,23,0)+ _comp+#endif+ specs pro getDB :: PackageDB -> IO PkgDB getDB spec = do@@ -130,7 +134,7 @@ ---------------------------------------------------------------- topSortedPkgs :: PkgInfo -> PkgDB -> [PkgInfo]-topSortedPkgs pkgi db = topSort $ pkgids [pkgi]+topSortedPkgs pkgi db = topSort $ unitids [pkgi] where- pkgids = map installedPackageId+ unitids = map installedUnitId topSort = topologicalOrder . fromList . reverseDependencyClosure db
Distribution/Cab/Printer.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Distribution.Cab.Printer ( printDeps , printRevDeps@@ -11,21 +12,21 @@ import qualified Data.Map as M import Distribution.Cab.PkgDB import Distribution.Cab.Version-import Distribution.InstalledPackageInfo (InstalledPackageInfo_(..))+import Distribution.Cab.Utils (UnitId, installedUnitId, lookupUnitId)+import Distribution.InstalledPackageInfo (author, depends, license) import Distribution.License (License(..))-import Distribution.Package (InstalledPackageId)-import Distribution.Simple.PackageIndex (lookupInstalledPackageId, allPackages)+import Distribution.Simple.PackageIndex (allPackages) ---------------------------------------------------------------- -type RevDB = Map InstalledPackageId [InstalledPackageId]+type RevDB = Map UnitId [UnitId] makeRevDepDB :: PkgDB -> RevDB makeRevDepDB db = M.fromList revdeps where pkgs = allPackages db deps = map idDeps pkgs- idDeps pkg = (installedPackageId pkg, depends pkg)+ idDeps pkg = (installedUnitId pkg, depends pkg) kvs = sort $ concatMap decomp deps decomp (k,vs) = map (\v -> (v,k)) vs kvss = groupBy ((==) `on` fst) kvs@@ -37,14 +38,14 @@ printDeps :: Bool -> Bool -> PkgDB -> Int -> PkgInfo -> IO () printDeps rec info db n pkgi = mapM_ (printDep rec info db n) $ depends pkgi -printDep :: Bool -> Bool -> PkgDB -> Int -> InstalledPackageId -> IO ()-printDep rec info db n pid = case lookupInstalledPackageId db pid of- Nothing -> return ()- Just pkgi -> do- putStr $ prefix ++ fullNameOfPkgInfo pkgi- extraInfo info pkgi+printDep :: Bool -> Bool -> PkgDB -> Int -> UnitId -> IO ()+printDep rec info db n uid = case lookupUnitId db uid of+ Nothing -> return ()+ Just uniti -> do+ putStr $ prefix ++ fullNameOfPkgInfo uniti+ extraInfo info uniti putStrLn ""- when rec $ printDeps rec info db (n+1) pkgi+ when rec $ printDeps rec info db (n+1) uniti where prefix = replicate (n * 4) ' ' @@ -56,20 +57,20 @@ revdb = makeRevDepDB db printRevDeps' :: Bool -> Bool -> PkgDB -> RevDB -> Int -> PkgInfo -> IO ()-printRevDeps' rec info db revdb n pkgi = case M.lookup pkgid revdb of+printRevDeps' rec info db revdb n pkgi = case M.lookup unitid revdb of Nothing -> return ()- Just pkgids -> mapM_ (printRevDep' rec info db revdb n) pkgids+ Just unitids -> mapM_ (printRevDep' rec info db revdb n) unitids where- pkgid = installedPackageId pkgi+ unitid = installedUnitId pkgi -printRevDep' :: Bool -> Bool -> PkgDB -> RevDB -> Int -> InstalledPackageId -> IO ()-printRevDep' rec info db revdb n pid = case lookupInstalledPackageId db pid of- Nothing -> return ()- Just pkgi -> do- putStr $ prefix ++ fullNameOfPkgInfo pkgi- extraInfo info pkgi+printRevDep' :: Bool -> Bool -> PkgDB -> RevDB -> Int -> UnitId -> IO ()+printRevDep' rec info db revdb n uid = case lookupUnitId db uid of+ Nothing -> return ()+ Just uniti -> do+ putStr $ prefix ++ fullNameOfPkgInfo uniti+ extraInfo info uniti putStrLn ""- when rec $ printRevDeps' rec info db revdb (n+1) pkgi+ when rec $ printRevDeps' rec info db revdb (n+1) uniti where prefix = replicate (n * 4) ' '
Distribution/Cab/Utils.hs view
@@ -1,7 +1,27 @@+{-# LANGUAGE CPP #-} module Distribution.Cab.Utils where import Data.List +import Distribution.InstalledPackageInfo (InstalledPackageInfo)+#if MIN_VERSION_Cabal(1,21,0) && !(MIN_VERSION_Cabal(1,23,0))+import Distribution.Package (PackageInstalled)+#endif+import Distribution.Simple.PackageIndex (PackageIndex)+#if MIN_VERSION_Cabal(1,23,0)+import qualified Distribution.InstalledPackageInfo as Cabal+ (installedUnitId)+import qualified Distribution.Package as Cabal (UnitId)+import qualified Distribution.Simple.PackageIndex as Cabal+ (lookupUnitId)+#else+import qualified Distribution.InstalledPackageInfo as Cabal+ (installedPackageId)+import qualified Distribution.Package as Cabal (InstalledPackageId)+import qualified Distribution.Simple.PackageIndex as Cabal+ (lookupInstalledPackageId)+#endif+ -- | -- >>> fromDotted "1.2.3" -- [1,2,3]@@ -16,3 +36,27 @@ -- "1.2.3" toDotted :: [Int] -> String toDotted = intercalate "." . map show++#if MIN_VERSION_Cabal(1,23,0)+type UnitId = Cabal.UnitId+#else+type UnitId = Cabal.InstalledPackageId+#endif++installedUnitId :: InstalledPackageInfo -> UnitId+#if MIN_VERSION_Cabal(1,23,0)+installedUnitId = Cabal.installedUnitId+#else+installedUnitId = Cabal.installedPackageId+#endif++#if MIN_VERSION_Cabal(1,23,0)+lookupUnitId :: PackageIndex a -> UnitId -> Maybe a+lookupUnitId = Cabal.lookupUnitId+#elif MIN_VERSION_Cabal(1,21,0)+lookupUnitId :: PackageInstalled a => PackageIndex a -> UnitId -> Maybe a+lookupUnitId = Cabal.lookupInstalledPackageId+#else+lookupUnitId :: PackageIndex -> UnitId -> Maybe InstalledPackageInfo+lookupUnitId = Cabal.lookupInstalledPackageId+#endif
cab.cabal view
@@ -1,5 +1,5 @@ Name: cab-Version: 0.2.15+Version: 0.2.16 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3@@ -21,7 +21,7 @@ Default-Language: Haskell2010 GHC-Options: -Wall Build-Depends: base >= 4.0 && < 5- , Cabal >= 1.18 && < 1.23+ , Cabal >= 1.18 && < 1.25 , attoparsec >= 0.10 , bytestring , conduit >= 1.1