Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (119 sloc) 5.585 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
43 import qualified Portage.EBuild as E
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
44 import Portage.Version
45
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
46 cabal2ebuild :: Cabal.PackageDescription -> Portage.EBuild
47 cabal2ebuild pkg = Portage.ebuildTemplate {
48 E.name = map toLower cabalPkgName,
18b7fbc @trofi caba2ebuild: don't mangle package name as hackage is case sensitive
trofi authored
49 E.hackage_name= cabalPkgName,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
50 E.version = display (Cabal.pkgVersion (Cabal.package pkg)),
51 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
52 else Cabal.synopsis pkg,
59858eb @trofi Added 'metadata.xml' autogeneration for packages where it does not ex…
trofi authored
53 E.long_desc = if null (Cabal.description pkg) then Cabal.synopsis pkg
54 else Cabal.description pkg,
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
55 E.homepage = thisHomepage,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
56 E.license = Cabal.license pkg,
57 E.my_pn = if any isUpper cabalPkgName then Just cabalPkgName else Nothing,
58 E.features = E.features E.ebuildTemplate
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
59 ++ (if hasExe then ["bin"] else [])
2ed012c @trofi cabal2ebuild: adding USE=hoogle by default
trofi authored
60 ++ maybe [] (const (["lib","profile","haddock","hoogle"]
9d28e5b make sure hscolour does not get the hscolour feature
Stephan Friedrichs authored
61 ++ if cabalPkgName == "hscolour" then [] else ["hscolour"])
62 ) (Cabal.library pkg) -- hscolour can't colour its own sources
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
63 } where
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
64 cabalPkgName = display $ Cabal.pkgName (Cabal.package pkg)
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
65 hasExe = (not . null) (Cabal.executables pkg)
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
66 thisHomepage = if (null $ Cabal.homepage pkg)
67 then E.homepage E.ebuildTemplate
68 else Cabal.homepage pkg
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
69
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
70 convertDependencies :: Portage.Category -> [Cabal.Dependency] -> [Dependency]
23fbd30 @kolmodin allow deps to not be in the dev-haskell/ category
kolmodin authored
71 convertDependencies category = concatMap (convertDependency category)
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
72
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
73 convertDependency :: Portage.Category -> Cabal.Dependency -> [Dependency]
23fbd30 @kolmodin allow deps to not be in the dev-haskell/ category
kolmodin authored
74 convertDependency _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
75 | pname `elem` coreLibs = [] -- no explicit dep on core libs
23fbd30 @kolmodin allow deps to not be in the dev-haskell/ category
kolmodin authored
76 convertDependency category (Cabal.Dependency pname versionRange)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
77 = convert versionRange
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
78 where
decf164 @kolmodin Bump Copyright header
kolmodin authored
79 -- XXX: not always true, we should look properly for deps in the overlay
80 -- to find the correct category
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
81 pn = Portage.PackageName category (Portage.normalizeCabalPackageName pname)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
82 convert :: Cabal.VersionRange -> [Dependency]
83 convert = Cabal.foldVersionRange'
0a5a285 @qnikst UseFlag handling
qnikst authored
84 ( [AnyVersionOf pn []] -- ^ @\"-any\"@ version
85 )(\v -> [ThisVersionOf (fromCabalVersion v) pn []] -- ^ @\"== v\"@
86 )(\v -> [LaterVersionOf (fromCabalVersion v) pn []] -- ^ @\"> v\"@
87 )(\v -> [EarlierVersionOf (fromCabalVersion v) pn []] -- ^ @\"< v\"@
88 )(\v -> [OrLaterVersionOf (fromCabalVersion v) pn []] -- ^ @\">= v\"@
89 )(\v -> [OrEarlierVersionOf (fromCabalVersion v) pn []] -- ^ @\"<= v\"@
90 )(\v _ -> [ThisMajorOf (fromCabalVersion v) pn []] -- ^ @\"== v.*\"@ wildcard. (incl lower, excl upper)
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
91 )(\g1 g2 -> [DependEither (flatten g1 ++ flatten g2) ] -- ^ @\"_ || _\"@ union
33ecc29 @kolmodin Support cabal's new (_) dependency, with parantheses
kolmodin authored
92 )(\r1 r2 -> r1 ++ r2 -- ^ @\"_ && _\"@ intersection
93 )(\dp -> [AllOf dp ] -- ^ @\"(_)\"@ parentheses
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
94 )
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
95 where
96 flatten :: [Dependency] -> [[Dependency]]
97 flatten [DependEither ds] = concatMap flatten ds
98 flatten other = [other]
99
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
100 coreLibs :: [Cabal.PackageName]
101 coreLibs = map Cabal.PackageName
61f04b0 Update list of core libs
Duncan Coutts authored
102 ["array"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
103 ,"base"
eb77d89 @trofi wipe bytestring as a explicit dependency once again
trofi authored
104 ,"bytestring" -- intentionally no ebuild. use ghc's version
105 -- to avoid dreaded 'diamond dependency' problem
61f04b0 Update list of core libs
Duncan Coutts authored
106 ,"containers"
107 ,"directory"
136cbd4 @kolmodin We do need editline dependencies
kolmodin authored
108 --,"editline"
fe19025 @trofi ban one more core package: filepath this time
trofi authored
109 ,"filepath" -- intentionally no ebuild. use ghc's version
61f04b0 Update list of core libs
Duncan Coutts authored
110 ,"ghc"
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
111 ,"ghc-prim"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
112 ,"haskell98"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
113 ,"hpc" --has ebuild, but only in the overlay
ed7c596 @trofi core libraries: add 'integer-gmp' to list of core ones
trofi authored
114 ,"integer" -- up to ghc-6.10
115 ,"integer-gmp" -- ghc-6.12+
61f04b0 Update list of core libs
Duncan Coutts authored
116 ,"old-locale"
117 ,"old-time"
118 ,"packedstring"
119 ,"pretty"
120 ,"process"
b45538a @trofi Cabal2Ebuild: don't hide 'random' and 'readline' depends
trofi authored
121 -- ,"random" -- not a core package since ghc-7.2
61f04b0 Update list of core libs
Duncan Coutts authored
122 ,"rts"
5a4179b @trofi depends: treat syb as external depend again
trofi authored
123 -- ,"syb" -- was splitted off from ghc again
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
124 ,"template-haskell"
b45538a @trofi Cabal2Ebuild: don't hide 'random' and 'readline' depends
trofi authored
125 ,"unix" -- unsafe to upgrade
61f04b0 Update list of core libs
Duncan Coutts authored
126 ]
Something went wrong with that request. Please try again.