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