Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 131 lines (123 sloc) 5.832 kB
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
1 -- A program for generating a Gentoo ebuild from a .cabal file
2 --
3 -- Author : Duncan Coutts <dcoutts@gentoo.org>
4 --
5 -- Created: 21 July 2005
6 --
7 -- Copyright (C) 2005 Duncan Coutts
8 --
9 -- This library is free software; you can redistribute it and/or
10 -- modify it under the terms of the GNU General Public License
11 -- as published by the Free Software Foundation; either version 2
12 -- of the License, or (at your option) any later version.
13 --
14 -- This library is distributed in the hope that it will be useful,
15 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 -- General Public License for more details.
18 --
19 -- |
20 -- Maintainer : haskell@gentoo.org
21 --
22 -- cabal2ebuild - a program for generating a Gentoo ebuild from a .cabal file
23 --
24 module Cabal2Ebuild
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
25 (cabal2ebuild
cb4a7bb @kolmodin Start on translating extra-libraries into ebuild deps
kolmodin authored
26 ,convertDependencies
4f6ec6f @kolmodin guess-ghc-version: Integrate GHC guessing into 'hackport merge'
kolmodin authored
27 ,convertDependency) where
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
28
29 import qualified Distribution.PackageDescription as Cabal
87d875b @kolmodin Wall police
kolmodin authored
30 (PackageDescription(..))
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
31 import qualified Distribution.Package as Cabal (PackageIdentifier(..)
32 , Dependency(..)
33 , PackageName(..))
2d84418 @jkarlson Remove useless imports and variables.
jkarlson authored
34 import qualified Distribution.Version as Cabal (VersionRange, foldVersionRange')
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
35 import Distribution.Text (display)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
36
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
37 import Data.Char (toLower,isUpper)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
38
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
39 import Portage.Dependency
0a5a285 @qnikst UseFlag handling
qnikst authored
40 import Portage.Use
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
41 import qualified Portage.PackageId as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
42 import qualified Portage.EBuild as Portage
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
43 import qualified Portage.Resolve as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
44 import qualified Portage.EBuild as E
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
45 import qualified Portage.Overlay as O
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
46 import Portage.Version
47
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
48 cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
49 cabal2ebuild pkg = Portage.ebuildTemplate {
50 E.name = map toLower cabalPkgName,
18b7fbc @trofi caba2ebuild: don't mangle package name as hackage is case sensitive
trofi authored
51 E.hackage_name= cabalPkgName,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
52 E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
53 E.description = if null (Cabal.synopsis pkg) then Cabal.description pkg
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
54 else Cabal.synopsis pkg,
59858eb @trofi Added 'metadata.xml' autogeneration for packages where it does not ex…
trofi authored
55 E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
56 else Cabal.description pkg,
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
57 E.homepage = thisHomepage,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
58 E.license = Cabal.license pkg,
59 E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
60 E.features = E.features E.ebuildTemplate
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
61 ++ (if hasExe then ["bin"] else [])
2ed012c @trofi cabal2ebuild: adding USE=hoogle by default
trofi authored
62 ++ maybe [] (const (["lib","profile","haddock","hoogle"]
9d28e5b make sure hscolour does not get the hscolour feature
Stephan Friedrichs authored
63 ++ if cabalPkgName == "hscolour" then [] else ["hscolour"])
64 ) (Cabal.library pkg) -- hscolour can't colour its own sources
bacaeb6 @trofi Cabal2Ebuild: move 'test-suite' to the end of features
trofi authored
65 ++ (if hasTests then ["test-suite"] else [])
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
66 } where
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
67 cabalPkgName = display $ Cabal.pkgName (Cabal.package pkg)
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
68 hasExe = (not . null) (Cabal.executables pkg)
c1c12ae @renegat96 Add test-suite support
renegat96 authored
69 hasTests = (not . null) (Cabal.testSuites pkg)
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
70 thisHomepage = if (null $ Cabal.homepage pkg)
71 then E.homepage E.ebuildTemplate
72 else Cabal.homepage pkg
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
73
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
74 convertDependencies :: O.Overlay -> Portage.Category -> [Cabal.Dependency] -> [Dependency]
75 convertDependencies overlay category = concatMap (convertDependency overlay category)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
76
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
77 convertDependency :: O.Overlay -> Portage.Category -> Cabal.Dependency -> [Dependency]
78 convertDependency overlay _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
79 | pname `elem` coreLibs = [] -- no explicit dep on core libs
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
80 convertDependency overlay category (Cabal.Dependency pname versionRange)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
81 = convert versionRange
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
82 where
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
83 pn = case Portage.resolveFullPortageName overlay pname of
84 Just r -> r
85 Nothing -> Portage.PackageName category (Portage.normalizeCabalPackageName pname)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
86 convert :: Cabal.VersionRange -> [Dependency]
87 convert = Cabal.foldVersionRange'
0a5a285 @qnikst UseFlag handling
qnikst authored
88 ( [AnyVersionOf pn []] -- ^ @\"-any\"@ version
89 )(\v -> [ThisVersionOf (fromCabalVersion v) pn []] -- ^ @\"== v\"@
90 )(\v -> [LaterVersionOf (fromCabalVersion v) pn []] -- ^ @\"> v\"@
91 )(\v -> [EarlierVersionOf (fromCabalVersion v) pn []] -- ^ @\"< v\"@
92 )(\v -> [OrLaterVersionOf (fromCabalVersion v) pn []] -- ^ @\">= v\"@
93 )(\v -> [OrEarlierVersionOf (fromCabalVersion v) pn []] -- ^ @\"<= v\"@
94 )(\v _ -> [ThisMajorOf (fromCabalVersion v) pn []] -- ^ @\"== v.*\"@ wildcard. (incl lower, excl upper)
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
95 )(\g1 g2 -> [DependEither (flatten g1 ++ flatten g2) ] -- ^ @\"_ || _\"@ union
33ecc29 @kolmodin Support cabal's new (_) dependency, with parantheses
kolmodin authored
96 )(\r1 r2 -> r1 ++ r2 -- ^ @\"_ && _\"@ intersection
97 )(\dp -> [AllOf dp ] -- ^ @\"(_)\"@ parentheses
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
98 )
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
99 where
100 flatten :: [Dependency] -> [[Dependency]]
101 flatten [DependEither ds] = concatMap flatten ds
102 flatten other = [other]
103
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
104 coreLibs :: [Cabal.PackageName]
105 coreLibs = map Cabal.PackageName
61f04b0 Update list of core libs
Duncan Coutts authored
106 ["array"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
107 ,"base"
eb77d89 @trofi wipe bytestring as a explicit dependency once again
trofi authored
108 ,"bytestring" -- intentionally no ebuild. use ghc's version
109 -- to avoid dreaded 'diamond dependency' problem
61f04b0 Update list of core libs
Duncan Coutts authored
110 ,"containers"
111 ,"directory"
136cbd4 @kolmodin We do need editline dependencies
kolmodin authored
112 --,"editline"
fe19025 @trofi ban one more core package: filepath this time
trofi authored
113 ,"filepath" -- intentionally no ebuild. use ghc's version
61f04b0 Update list of core libs
Duncan Coutts authored
114 ,"ghc"
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
115 ,"ghc-prim"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
116 ,"haskell98"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
117 ,"hpc" --has ebuild, but only in the overlay
ed7c596 @trofi core libraries: add 'integer-gmp' to list of core ones
trofi authored
118 ,"integer" -- up to ghc-6.10
119 ,"integer-gmp" -- ghc-6.12+
61f04b0 Update list of core libs
Duncan Coutts authored
120 ,"old-locale"
121 ,"old-time"
122 ,"packedstring"
123 ,"pretty"
124 ,"process"
b45538a @trofi Cabal2Ebuild: don't hide 'random' and 'readline' depends
trofi authored
125 -- ,"random" -- not a core package since ghc-7.2
61f04b0 Update list of core libs
Duncan Coutts authored
126 ,"rts"
5a4179b @trofi depends: treat syb as external depend again
trofi authored
127 -- ,"syb" -- was splitted off from ghc again
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
128 ,"template-haskell"
b45538a @trofi Cabal2Ebuild: don't hide 'random' and 'readline' depends
trofi authored
129 ,"unix" -- unsafe to upgrade
61f04b0 Update list of core libs
Duncan Coutts authored
130 ]
Something went wrong with that request. Please try again.