Skip to content
Browse files

merge: search DEPENDS in according categories instead of hardcoding d…

…ev-haskell/

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
1 parent 8ad8056 commit caf3f8fab1ecc2252a585ce5cfc68ac4af1c5bde @trofi trofi committed Feb 28, 2012
Showing with 33 additions and 28 deletions.
  1. +10 −8 Cabal2Ebuild.hs
  2. +2 −1 Merge.hs
  3. +21 −19 Merge/Dependencies.hs
View
18 Cabal2Ebuild.hs
@@ -39,7 +39,9 @@ import Data.Char (toLower,isUpper)
import Portage.Dependency
import qualified Portage.PackageId as Portage
import qualified Portage.EBuild as Portage
+import qualified Portage.Resolve as Portage
import qualified Portage.EBuild as E
+import qualified Portage.Overlay as O
import Portage.Version
cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
@@ -66,18 +68,18 @@ cabal2ebuild pkg = Portage.ebuildTemplate {
then E.homepage E.ebuildTemplate
else Cabal.homepage pkg
-convertDependencies :: Portage.Category -> [Cabal.Dependency] -> [Dependency]
-convertDependencies category = concatMap (convertDependency category)
+convertDependencies :: O.Overlay -> Portage.Category -> [Cabal.Dependency] -> [Dependency]
+convertDependencies overlay category = concatMap (convertDependency overlay category)
-convertDependency :: Portage.Category -> Cabal.Dependency -> [Dependency]
-convertDependency _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
+convertDependency :: O.Overlay -> Portage.Category -> Cabal.Dependency -> [Dependency]
+convertDependency overlay _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
| pname `elem` coreLibs = [] -- no explicit dep on core libs
-convertDependency category (Cabal.Dependency pname versionRange)
+convertDependency overlay category (Cabal.Dependency pname versionRange)
= convert versionRange
where
- -- XXX: not always true, we should look properly for deps in the overlay
- -- to find the correct category
- pn = Portage.PackageName category (Portage.normalizeCabalPackageName pname)
+ pn = case Portage.resolveFullPortageName overlay pname of
+ Just r -> r
+ Nothing -> Portage.PackageName category (Portage.normalizeCabalPackageName pname)
convert :: Cabal.VersionRange -> [Dependency]
convert = Cabal.foldVersionRange'
( [AnyVersionOf pn] -- ^ @\"-any\"@ version
View
3 Merge.hs
@@ -151,6 +151,7 @@ merge verbosity repo _serverURI args overlayPath = do
mergeGenericPackageDescription :: Verbosity -> FilePath -> Portage.Category -> GenericPackageDescription -> Bool -> IO ()
mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch = do
+ overlay <- Overlay.loadLazy overlayPath
let Right (pkgDesc0, flags) =
finalizePackageDescription
[ -- XXX: common things we should enable/disable?
@@ -171,7 +172,7 @@ mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch =
, pn `notElem` excludePkgs
]
in pkgDesc0 { buildDepends = deps }
- edeps = Merge.resolveDependencies pkgDesc (Just compilerId)
+ edeps = Merge.resolveDependencies overlay pkgDesc (Just compilerId)
debug verbosity ("Selected flags: " ++ show flags)
info verbosity ("Guessing GHC version: " ++ maybe "could not guess" (display.fst) mminimumGHC)
View
40 Merge/Dependencies.hs
@@ -66,6 +66,7 @@ import Distribution.Compiler
import qualified Portage.Version as Portage
import qualified Portage.PackageId as Portage
import qualified Portage.Dependency as Portage
+import qualified Portage.Overlay as Portage
import qualified Cabal2Ebuild as C2E
import qualified Portage.GHCCore as GHCCore
@@ -90,8 +91,8 @@ emptyEDep = EDep
dep_e = []
}
-resolveDependencies :: PackageDescription -> Maybe CompilerId -> EDep
-resolveDependencies pkg mcompiler =
+resolveDependencies :: Portage.Overlay -> PackageDescription -> Maybe CompilerId -> EDep
+resolveDependencies overlay pkg mcompiler =
edeps
{
dep = Portage.simplify_deps ( dep edeps),
@@ -104,12 +105,12 @@ resolveDependencies pkg mcompiler =
hasBuildableExes p = any (buildable . buildInfo) . executables $ p
treatAsLibrary = (not . hasBuildableExes) pkg || hasLibs pkg
- haskell_deps = haskellDependencies pkg
- cabal_dep = cabalDependency pkg compiler
+ haskell_deps = haskellDependencies overlay pkg
+ cabal_dep = cabalDependency overlay pkg compiler
ghc_dep = compilerIdToDependency compiler
extra_libs = findCLibs pkg
build_tools = buildToolsDependencies pkg
- pkg_config = pkgConfigDependencies pkg
+ pkg_config = pkgConfigDependencies overlay pkg
edeps
| treatAsLibrary = emptyEDep
{
@@ -136,20 +137,21 @@ resolveDependencies pkg mcompiler =
-- Haskell packages
---------------------------------------------------------------
-haskellDependencies :: PackageDescription -> [Portage.Dependency]
-haskellDependencies pkg =
+haskellDependencies :: Portage.Overlay -> PackageDescription -> [Portage.Dependency]
+haskellDependencies overlay pkg =
Portage.simplify_deps
- $ C2E.convertDependencies (Portage.Category "dev-haskell") (buildDepends pkg)
+ $ C2E.convertDependencies overlay (Portage.Category "dev-haskell") (buildDepends pkg)
---------------------------------------------------------------
-- Cabal Dependency
---------------------------------------------------------------
-- | Select the most restrictive dependency on Cabal, either the .cabal
-- file's descCabalVersion, or the Cabal GHC shipped with.
-cabalDependency :: PackageDescription -> CompilerId -> Portage.Dependency
-cabalDependency pkg (CompilerId GHC ghcVersion@(Cabal.Version versionNumbers _)) =
- head $ C2E.convertDependency (Portage.Category "dev-haskell")
+cabalDependency :: Portage.Overlay -> PackageDescription -> CompilerId -> Portage.Dependency
+cabalDependency overlay pkg (CompilerId GHC ghcVersion@(Cabal.Version versionNumbers _)) =
+ head $ C2E.convertDependency overlay
+ (Portage.Category "dev-haskell")
(Cabal.Dependency (Cabal.PackageName "Cabal")
finalCabalDep)
where
@@ -245,25 +247,25 @@ buildToolsProvided = ["hsc2hs"]
-- pkg-config
---------------------------------------------------------------
-pkgConfigDependencies :: PackageDescription -> [Portage.Dependency]
-pkgConfigDependencies (PackageDescription { library = lib, executables = exes }) = nub $ resolvePkgConfigs cabalDeps
+pkgConfigDependencies :: Portage.Overlay -> PackageDescription -> [Portage.Dependency]
+pkgConfigDependencies overlay (PackageDescription { library = lib, executables = exes }) = nub $ resolvePkgConfigs overlay cabalDeps
where
cabalDeps = depL ++ depE
depL = maybe [] (pkgconfigDepends.libBuildInfo) lib
depE = concatMap pkgconfigDepends (filter buildable (map buildInfo exes))
-resolvePkgConfigs :: [Cabal.Dependency] -> [Portage.Dependency]
-resolvePkgConfigs cdeps =
- [ case resolvePkgConfig pkg of
+resolvePkgConfigs :: Portage.Overlay -> [Cabal.Dependency] -> [Portage.Dependency]
+resolvePkgConfigs overlay cdeps =
+ [ case resolvePkgConfig overlay pkg of
Just d -> d
Nothing -> trace ("WARNING: Could not resolve pkg-config: " ++ pn ++ ". Check generated ebuild.")
(Portage.AnyVersionOf (Portage.mkPackageName "unknown-pkg-config" pn))
| pkg@(Cabal.Dependency (Cabal.PackageName pn) _range) <- cdeps ]
-resolvePkgConfig :: Cabal.Dependency -> Maybe Portage.Dependency
-resolvePkgConfig (Cabal.Dependency (Cabal.PackageName pn) _cabalVersion) = do
+resolvePkgConfig :: Portage.Overlay -> Cabal.Dependency -> Maybe Portage.Dependency
+resolvePkgConfig overlay (Cabal.Dependency (Cabal.PackageName pn) _cabalVersion) = do
(cat,portname) <- lookup pn table
- return . head $ (C2E.convertDependency (Portage.Category cat) (Cabal.Dependency (Cabal.PackageName portname) _cabalVersion))
+ return . head $ (C2E.convertDependency overlay (Portage.Category cat) (Cabal.Dependency (Cabal.PackageName portname) _cabalVersion))
table :: [(String, (String, String))]
table =

0 comments on commit caf3f8f

Please sign in to comment.
Something went wrong with that request. Please try again.