Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stop using HASKELL_DEPS, BUILD_TOOLS, EXTRA_LIBS variables in ebuilds

Introduce a datatype EDep which tracks dependencies of an ebuild
  • Loading branch information...
commit 02aa2fc6554d22d79e9e294364bd41468b9cd150 1 parent ebb2f1b
@kolmodin kolmodin authored
Showing with 82 additions and 49 deletions.
  1. +7 −2 Cabal2Ebuild.hs
  2. +63 −21 Merge.hs
  3. +12 −26 Portage/EBuild.hs
View
9 Cabal2Ebuild.hs
@@ -24,7 +24,8 @@
module Cabal2Ebuild
(cabal2ebuild
,convertDependencies
- ,convertDependency) where
+ ,convertDependency
+ ,default_ghc_dependency) where
import qualified Distribution.PackageDescription as Cabal
(PackageDescription(..))
@@ -43,6 +44,9 @@ import qualified Portage.EBuild as Portage
import qualified Portage.EBuild as E
import Portage.Version
+default_ghc_dependency :: Dependency
+default_ghc_dependency = OrLaterVersionOf (Version [6,8,1] Nothing [] 0) (Portage.mkPackageName "dev-lang" "ghc")
+
cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
cabal2ebuild pkg = Portage.ebuildTemplate {
E.name = map toLower cabalPkgName,
@@ -52,10 +56,11 @@ cabal2ebuild pkg = Portage.ebuildTemplate {
E.homepage = Cabal.homepage pkg,
E.src_uri = Cabal.pkgUrl pkg,
E.license = Cabal.license pkg,
- E.haskell_deps = simplify_deps $ convertDependencies (Portage.Category "dev-haskell") (Cabal.buildDepends pkg),
+ {- E.haskell_deps = simplify_deps $ convertDependencies (Portage.Category "dev-haskell") (Cabal.buildDepends pkg),
E.cabal_dep = head $ convertDependency (Portage.Category "dev-haskell")
(Cabal.Dependency (Cabal.PackageName "Cabal")
(Cabal.descCabalVersion pkg)),
+ -}
E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
E.features = E.features E.ebuildTemplate
++ (if hasExe then ["bin"] else [])
View
84 Merge.hs
@@ -10,11 +10,13 @@ Compile time:
build tools
deps (haskell dependencies)
extra-libs (c-libs)
+ pkg-config (c-libs)
Run time:
ghc
deps (haskell dependencies)
extra-libs (c-libs)
+ pkg-config (c-libs)
RDEPEND="ghc ${DEPS} ${EXTRALIBS}"
DEPEND="${RDEPEND} cabal ${BUILDTOOLS}"
@@ -27,11 +29,13 @@ Compile time:
ghc
cabal
build tools
- deps
+ deps (haskell dependencies)
extra-libs (c-libs)
+ pkg-config (c-libs)
Run time:
extra-libs (c-libs)
+ pkg-config (c-libs)
RDEPEND="${EXTRALIBS}"
DEPEND="${RDEPEND} ghc cabal ${DEPS} ${BUILDTOOLS}"
@@ -221,11 +225,11 @@ merge verbosity repo serverURI args overlayPath = do
return $ Portage.AnyVersionOf (Portage.PackageName p_cat pn)
-- calculate extra-libs
- extra <- findCLibs verbosity packageNameResolver pkgDesc
+ extra_libs <- findCLibs verbosity packageNameResolver pkgDesc
debug verbosity ("Selected flags: " ++ show flags)
debug verbosity ("extra-libs: ")
- mapM_ (debug verbosity . show) extra
+ mapM_ (debug verbosity . show) extra_libs
debug verbosity ("build-tools:")
mapM_ (debug verbosity . show) bt
@@ -234,25 +238,40 @@ merge verbosity repo serverURI args overlayPath = do
-- TODO: more fixes
-- * inherit keywords from previous ebuilds
- let d e = if treatAsLibrary
- then display (E.cabal_dep e)
- : "${RDEPEND}"
- : [ "${BUILDTOOLS}" | not . null $ E.build_tools e ]
- else display (E.cabal_dep e)
- : display (E.ghc_dep e)
- : "${RDEPEND}"
- : [ "${BUILDTOOLS}" | not . null $ E.build_tools e ]
- ++ [ "${HASKELLDEPS}" | not . null $ E.haskell_deps e ]
- rd e = if treatAsLibrary
- then display (E.ghc_dep e)
- : [ "${HASKELLDEPS}" | not . null $ E.haskell_deps e ]
- ++ [ "${EXTRALIBS}" | not . null $ E.extra_libs e ]
- else [ "${EXTRALIBS}" | not . null $ E.extra_libs e ]
+ let cabal_dep = head $ C2E.convertDependency (Portage.Category "dev-haskell")
+ (Cabal.Dependency (Cabal.PackageName "Cabal")
+ (descCabalVersion pkgDesc))
+ ghc_dep = C2E.default_ghc_dependency
+ haskell_deps = Portage.simplify_deps $ C2E.convertDependencies (Portage.Category "dev-haskell") (buildDepends pkgDesc)
+ build_tools = bt
+ pkg_config = []
+
+ let edeps
+ | treatAsLibrary = emptyEDep
+ {
+ dep = cabal_dep
+ : build_tools,
+ dep_e = [ "${RDEPEND}" ],
+ rdep = ghc_dep
+ : haskell_deps
+ ++ extra_libs
+ ++ pkg_config
+ }
+ | otherwise = emptyEDep
+ {
+ dep = ghc_dep
+ : cabal_dep
+ : build_tools
+ ++ haskell_deps,
+ dep_e = [ "${RDEPEND}" ],
+ rdep = extra_libs
+ ++ pkg_config
+ }
let ebuild = fixSrc serverURI (packageId pkgDesc)
- . (\e -> e { E.depend = d e } )
- . (\e -> e { E.rdepend = rd e } )
- . (\e -> e { E.extra_libs = nub (E.extra_libs e ++ extra) } )
- . (\e -> e { E.build_tools = nub (E.build_tools e ++ bt) } )
+ . (\e -> e { E.depend = dep edeps } )
+ . (\e -> e { E.depend_extra = dep_e edeps } )
+ . (\e -> e { E.rdepend = rdep edeps } )
+ . (\e -> e { E.rdepend_extra = rdep_e edeps } )
$ C2E.cabal2ebuild pkgDesc
debug verbosity ("Treat as library: " ++ show treatAsLibrary)
@@ -263,6 +282,29 @@ merge verbosity repo serverURI args overlayPath = do
(display cabal_pkgId <.> "tar.gz")
(mkUri cabal_pkgId)
+
+-- | Dependencies of an ebuild
+data EDep = EDep
+ {
+ rdep :: [Portage.Dependency],
+ rdep_e :: [String],
+ dep :: [Portage.Dependency],
+ dep_e :: [String],
+ extra_libs :: [Portage.Dependency],
+ pkg_conf :: [Portage.Dependency]
+ }
+
+emptyEDep :: EDep
+emptyEDep = EDep
+ {
+ rdep = [],
+ rdep_e = [],
+ dep = [],
+ dep_e = [],
+ extra_libs = [],
+ pkg_conf = []
+ }
+
findCLibs :: Verbosity -> (String -> Maybe Portage.Dependency) -> PackageDescription -> IO [Portage.Dependency]
findCLibs verbosity portageResolver (PackageDescription { library = lib, executables = exes }) = do
debug verbosity "Mapping extra-libraries into portage packages..."
View
38 Portage/EBuild.hs
@@ -22,13 +22,10 @@ data EBuild = EBuild {
slot :: String,
keywords :: [String],
iuse :: [String],
- haskell_deps :: [Dependency],
- build_tools :: [Dependency],
- extra_libs :: [Dependency],
- cabal_dep :: Dependency,
- ghc_dep :: Dependency,
- depend :: [String],
- rdepend :: [String],
+ depend :: [Dependency],
+ depend_extra :: [String],
+ rdepend :: [Dependency],
+ rdepend_extra :: [String],
features :: [String],
my_pn :: Maybe String --If the package's name contains upper-case
}
@@ -44,13 +41,10 @@ ebuildTemplate = EBuild {
slot = "0",
keywords = ["~amd64","~x86"],
iuse = [],
- haskell_deps = [],
- build_tools = [],
- extra_libs = [],
- cabal_dep = AnyVersionOf (mkPackageName "dev-haskell" "cabal"),
- ghc_dep = defaultDepGHC,
depend = [],
+ depend_extra = [],
rdepend = [],
+ rdepend_extra = [],
features = [],
my_pn = Nothing
}
@@ -87,20 +81,9 @@ showEBuild ebuild =
ss "KEYWORDS=". quote' (sepBy " " $ keywords ebuild).nl.
ss "IUSE=". quote' (sepBy ", " $ iuse ebuild). nl.
nl.
- ( if (not . null . build_tools $ ebuild)
- then ss "BUILDTOOLS=". quote' (sepBy "\n\t\t" $ map display $ build_tools ebuild). nl
- else id
- ).
- ( if (not . null . extra_libs $ ebuild )
- then ss "EXTRALIBS=". quote' (sepBy "\n\t\t" $ map display $ extra_libs ebuild). nl
- else id
- ).
- ( if (not . null . haskell_deps $ ebuild)
- then ss "HASKELLDEPS=". quote' (sepBy "\n\t\t" $ map display $ haskell_deps ebuild). nl
- else id
- ).
- ss "RDEPEND=". quote' (sepBy "\n\t\t" $ rdepend ebuild). nl.
- ss "DEPEND=". quote' (sepBy "\n\t\t" $ depend ebuild). nl.
+ dep_str "RDEPEND" (rdepend_extra ebuild) (rdepend ebuild).
+ dep_str "DEPEND" ( depend_extra ebuild) ( depend ebuild).
+ nl.
(case my_pn ebuild of
Nothing -> id
Just _ -> nl. ss "S=". quote ("${WORKDIR}/${MY_P}"). nl)
@@ -116,6 +99,9 @@ sc = showChar
nl :: String -> String
nl = sc '\n'
+dep_str :: String -> [String] -> [Dependency] -> (String -> String)
+dep_str var extra deps = ss var. sc '='. quote' (sepBy "\n\t\t" $ extra ++ map display deps). nl
+
quote :: String -> String -> String
quote str = sc '"'. ss str. sc '"'
Please sign in to comment.
Something went wrong with that request. Please try again.