diff --git a/Distribution/Cab/PkgDB.hs b/Distribution/Cab/PkgDB.hs index 1b160a3..fca9ff0 100644 --- a/Distribution/Cab/PkgDB.hs +++ b/Distribution/Cab/PkgDB.hs @@ -21,7 +21,7 @@ module Distribution.Cab.PkgDB ( , verOfPkgInfo ) where -import Distribution.Cab.Utils (fromDotted, installedComponentId) +import Distribution.Cab.Utils (fromDotted, installedUnitId) import Distribution.Cab.Version import Distribution.Cab.VerDB (PkgName) import Distribution.Version (Version(..)) @@ -77,7 +77,7 @@ getDBs specs = do (_comp,_,pro) <- configure normal Nothing Nothing defaultProgramDb getInstalledPackages normal #if MIN_VERSION_Cabal(1,23,0) - comp + _comp #endif specs pro @@ -134,7 +134,7 @@ verOfPkgInfo = version . pkgVersion . sourcePackageId ---------------------------------------------------------------- topSortedPkgs :: PkgInfo -> PkgDB -> [PkgInfo] -topSortedPkgs pkgi db = topSort $ pkgids [pkgi] +topSortedPkgs pkgi db = topSort $ unitids [pkgi] where - pkgids = map installedComponentId + unitids = map installedUnitId topSort = topologicalOrder . fromList . reverseDependencyClosure db diff --git a/Distribution/Cab/Printer.hs b/Distribution/Cab/Printer.hs index a21ff75..4f4d6ac 100644 --- a/Distribution/Cab/Printer.hs +++ b/Distribution/Cab/Printer.hs @@ -12,22 +12,21 @@ import Data.Map (Map) import qualified Data.Map as M import Distribution.Cab.PkgDB import Distribution.Cab.Version -import Distribution.Cab.Utils (installedComponentId, lookupComponentId) +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 (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 = (installedComponentId 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 @@ -39,14 +38,14 @@ makeRevDepDB db = M.fromList revdeps 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 lookupComponentId 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) ' ' @@ -58,20 +57,20 @@ printRevDeps rec info db n pkgi = printRevDeps' rec info db revdb n pkgi 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 = installedComponentId pkgi + unitid = installedUnitId pkgi -printRevDep' :: Bool -> Bool -> PkgDB -> RevDB -> Int -> InstalledPackageId -> IO () -printRevDep' rec info db revdb n pid = case lookupComponentId 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) ' ' diff --git a/Distribution/Cab/Utils.hs b/Distribution/Cab/Utils.hs index 90a29d8..9c83523 100644 --- a/Distribution/Cab/Utils.hs +++ b/Distribution/Cab/Utils.hs @@ -10,14 +10,14 @@ import Distribution.Package (PackageInstalled) import Distribution.Simple.PackageIndex (PackageIndex) #if MIN_VERSION_Cabal(1,23,0) import qualified Distribution.InstalledPackageInfo as Cabal - (installedComponentId) -import Distribution.Package (ComponentId) + (installedUnitId) +import qualified Distribution.Package as Cabal (UnitId) import qualified Distribution.Simple.PackageIndex as Cabal - (lookupComponentId) + (lookupUnitId) #else import qualified Distribution.InstalledPackageInfo as Cabal (installedPackageId) -import Distribution.Package (InstalledPackageId) +import qualified Distribution.Package as Cabal (InstalledPackageId) import qualified Distribution.Simple.PackageIndex as Cabal (lookupInstalledPackageId) #endif @@ -38,20 +38,25 @@ toDotted :: [Int] -> String toDotted = intercalate "." . map show #if MIN_VERSION_Cabal(1,23,0) -installedComponentId :: InstalledPackageInfo -> ComponentId -installedComponentId = Cabal.installedComponentId +type UnitId = Cabal.UnitId #else -installedComponentId :: InstalledPackageInfo -> InstalledPackageId -installedComponentId = Cabal.installedPackageId +type UnitId = Cabal.InstalledPackageId #endif +installedUnitId :: InstalledPackageInfo -> UnitId #if MIN_VERSION_Cabal(1,23,0) -lookupComponentId :: PackageIndex a -> ComponentId -> Maybe a -lookupComponentId = Cabal.lookupComponentId +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) -lookupComponentId :: PackageInstalled a => PackageIndex a -> InstalledPackageId -> Maybe a -lookupComponentId = Cabal.lookupInstalledPackageId +lookupUnitId :: PackageInstalled a => PackageIndex a -> UnitId -> Maybe a +lookupUnitId = Cabal.lookupInstalledPackageId #else -lookupComponentId :: PackageIndex -> InstalledPackageId -> Maybe InstalledPackageInfo -lookupComponentId = Cabal.lookupInstalledPackageId +lookupUnitId :: PackageIndex -> UnitId -> Maybe InstalledPackageInfo +lookupUnitId = Cabal.lookupInstalledPackageId #endif