Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 126 lines (118 sloc) 5.672 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
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
40 import qualified Portage.PackageId as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
41 import qualified Portage.EBuild as Portage
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
42 import qualified Portage.Resolve as Portage
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
43 import qualified Portage.EBuild as E
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
44 import qualified Portage.Overlay as O
6956e2f @kolmodin Tiny cleanup about different Version structures. Add rdepend to ebuild.
kolmodin authored
45 import Portage.Version
46
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
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
50 E.hackage_name= cabalPkgName,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
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
53 else Cabal.synopsis pkg,
59858eb @trofi Added 'metadata.xml' autogeneration for packages where it does not ex…
trofi authored
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
56 E.homepage = thisHomepage,
b44fb9d @kolmodin Move datatype EBuild to Portage.EBuild
kolmodin authored
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
60 ++ (if hasExe then ["bin"] else [])
2ed012c @trofi cabal2ebuild: adding USE=hoogle by default
trofi authored
61 ++ maybe [] (const (["lib","profile","haddock","hoogle"]
9d28e5b make sure hscolour does not get the hscolour feature
Stephan Friedrichs authored
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
64 ++ (if hasTests then ["test-suite"] else [])
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
65 } where
9e6e1bc @kolmodin Make Portage.Dependency use PackageName instead of just a String
kolmodin authored
66 cabalPkgName = display $ Cabal.pkgName (Cabal.package pkg)
bd75ad0 @kolmodin first stab at DEPEND / RDEPEND tracking
kolmodin authored
67 hasExe = (not . null) (Cabal.executables pkg)
c1c12ae @renegat96 Add test-suite support
renegat96 authored
68 hasTests = (not . null) (Cabal.testSuites pkg)
8bc201b @jkarlson Add silly default homepage and src_uri.
jkarlson authored
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
72
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
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
75
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
76 convertDependency :: O.Overlay -> Portage.Category -> Cabal.Dependency -> [Dependency]
ea3f66b @trofi Portage/Dependency.hs: don't put doule braces around 'test? ( ( like-…
trofi authored
77 convertDependency _overlay _category (Cabal.Dependency pname@(Cabal.PackageName _name) _)
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
78 | pname `elem` coreLibs = [] -- no explicit dep on core libs
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
79 convertDependency overlay category (Cabal.Dependency pname versionRange)
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
80 = convert versionRange
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
81 where
caf3f8f @trofi merge: search DEPENDS in according categories instead of hardcoding d…
trofi authored
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
85 convert :: Cabal.VersionRange -> [Dependency]
86 convert = Cabal.foldVersionRange'
0a5a285 @qnikst UseFlag handling
qnikst authored
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
94 )(\g1 g2 -> [DependEither (g1 ++ g2)] -- ^ @\"_ || _\"@ union
33ecc29 @kolmodin Support cabal's new (_) dependency, with parantheses
kolmodin authored
95 )(\r1 r2 -> r1 ++ r2 -- ^ @\"_ && _\"@ intersection
96 )(\dp -> [AllOf dp ] -- ^ @\"(_)\"@ parentheses
1585cc6 @trofi Cabal2Ebuild.hs: migrated to foldVersionRange
trofi authored
97 )
fbf5eb0 @kolmodin Properly handle portage's "||" operator, it takes multiple arguments
kolmodin authored
98
8273e68 @kolmodin Update the CLI and start using cabal-install features
kolmodin authored
99 coreLibs :: [Cabal.PackageName]
100 coreLibs = map Cabal.PackageName
61f04b0 Update list of core libs
Duncan Coutts authored
101 ["array"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
102 ,"base"
eb77d89 @trofi wipe bytestring as a explicit dependency once again
trofi authored
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
105 ,"containers"
106 ,"directory"
136cbd4 @kolmodin We do need editline dependencies
kolmodin authored
107 --,"editline"
fe19025 @trofi ban one more core package: filepath this time
trofi authored
108 ,"filepath" -- intentionally no ebuild. use ghc's version
61f04b0 Update list of core libs
Duncan Coutts authored
109 ,"ghc"
285f6b1 @kolmodin Add missing core libs to list
kolmodin authored
110 ,"ghc-prim"
8022ddc Adding support for variable substitution in generated ebuilds
der_eq@freenet.de authored
111 ,"haskell98"
2f85f14 @kolmodin Write comments about core packages
kolmodin authored
112 ,"hpc" --has ebuild, but only in the overlay
ed7c596 @trofi core libraries: add 'integer-gmp' to list of core ones
trofi authored
113 ,"integer" -- up to ghc-6.10
114 ,"integer-gmp" -- ghc-6.12+
61f04b0 Update list of core libs
Duncan Coutts authored
115 ,"old-locale"
116 ,"old-time"
117 ,"packedstring"
118 ,"pretty"
119 ,"process"
b45538a @trofi Cabal2Ebuild: don't hide 'random' and 'readline' depends
trofi authored
120 -- ,"random" -- not a core package since ghc-7.2
61f04b0 Update list of core libs
Duncan Coutts authored
121 ,"rts"
5a4179b @trofi depends: treat syb as external depend again
trofi authored
122 -- ,"syb" -- was splitted off from ghc again
aff37c2 First release of HackPort, the Hackage tool for Portage
der_eq@freenet.de authored
123 ,"template-haskell"
b45538a @trofi Cabal2Ebuild: don't hide 'random' and 'readline' depends
trofi authored
124 ,"unix" -- unsafe to upgrade
61f04b0 Update list of core libs
Duncan Coutts authored
125 ]
Something went wrong with that request. Please try again.